OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/dom/ModuleScript.h" | 5 #include "core/dom/ModuleScript.h" |
6 | 6 |
7 #include "bindings/core/v8/ScriptState.h" | 7 #include "bindings/core/v8/ScriptState.h" |
8 #include "bindings/core/v8/ScriptValue.h" | 8 #include "bindings/core/v8/ScriptValue.h" |
| 9 #include "core/dom/ScriptModuleResolver.h" |
9 #include "v8/include/v8.h" | 10 #include "v8/include/v8.h" |
10 | 11 |
11 namespace blink { | 12 namespace blink { |
12 | 13 |
13 ModuleScript* ModuleScript::Create( | 14 ModuleScript* ModuleScript::Create( |
14 const String& source_text, | 15 const String& source_text, |
15 Modulator* modulator, | 16 Modulator* modulator, |
16 const KURL& base_url, | 17 const KURL& base_url, |
17 const String& nonce, | 18 const String& nonce, |
18 ParserDisposition parser_state, | 19 ParserDisposition parser_state, |
(...skipping 25 matching lines...) Expand all Loading... |
44 ParserDisposition parser_state, | 45 ParserDisposition parser_state, |
45 WebURLRequest::FetchCredentialsMode credentials_mode) { | 46 WebURLRequest::FetchCredentialsMode credentials_mode) { |
46 // https://html.spec.whatwg.org/#creating-a-module-script | 47 // https://html.spec.whatwg.org/#creating-a-module-script |
47 // Step 7. Set script's module record to result. | 48 // Step 7. Set script's module record to result. |
48 // Step 8. Set script's base URL to the script base URL provided. | 49 // Step 8. Set script's base URL to the script base URL provided. |
49 // Step 9. Set script's cryptographic nonce to the cryptographic nonce | 50 // Step 9. Set script's cryptographic nonce to the cryptographic nonce |
50 // provided. | 51 // provided. |
51 // Step 10. Set script's parser state to the parser state. | 52 // Step 10. Set script's parser state to the parser state. |
52 // Step 11. Set script's credentials mode to the credentials mode provided. | 53 // Step 11. Set script's credentials mode to the credentials mode provided. |
53 // Step 12. Return script. | 54 // Step 12. Return script. |
54 return new ModuleScript(modulator, result, base_url, nonce, parser_state, | 55 ModuleScript* module_script = new ModuleScript( |
55 credentials_mode); | 56 modulator, result, base_url, nonce, parser_state, credentials_mode); |
| 57 |
| 58 // Step 5, a part of ParseModule(): Passing script as the last parameter |
| 59 // here ensures result.[[HostDefined]] will be script. |
| 60 modulator->GetScriptModuleResolver()->RegisterModuleScript(module_script); |
| 61 |
| 62 return module_script; |
56 } | 63 } |
57 | 64 |
58 ModuleScript* ModuleScript::CreateForTest( | 65 ModuleScript* ModuleScript::CreateForTest( |
59 Modulator* modulator, | 66 Modulator* modulator, |
60 ScriptModule record, | 67 ScriptModule record, |
61 const KURL& base_url, | 68 const KURL& base_url, |
62 const String& nonce, | 69 const String& nonce, |
63 ParserDisposition parser_state, | 70 ParserDisposition parser_state, |
64 WebURLRequest::FetchCredentialsMode credentials_mode) { | 71 WebURLRequest::FetchCredentialsMode credentials_mode) { |
65 return CreateInternal(modulator, record, base_url, nonce, parser_state, | 72 return CreateInternal(modulator, record, base_url, nonce, parser_state, |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 } | 125 } |
119 | 126 |
120 String ModuleScript::InlineSourceTextForCSP() const { | 127 String ModuleScript::InlineSourceTextForCSP() const { |
121 // Currently we don't support inline module scripts. | 128 // Currently we don't support inline module scripts. |
122 // TODO(hiroshige): Implement this. | 129 // TODO(hiroshige): Implement this. |
123 NOTREACHED(); | 130 NOTREACHED(); |
124 return String(); | 131 return String(); |
125 } | 132 } |
126 | 133 |
127 } // namespace blink | 134 } // namespace blink |
OLD | NEW |