Changeset 211280 in webkit
- Timestamp:
- Jan 27, 2017 2:49:23 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 70 added
- 41 edited
- 10 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r211254 r211280 1 2017-01-27 Yusuke Suzuki <utatane.tea@gmail.com> 2 3 Implement dynamic-import for WebCore 4 https://bugs.webkit.org/show_bug.cgi?id=166926 5 6 Reviewed by Ryosuke Niwa. 7 8 * http/tests/misc/import-absolute-url-expected.txt: Added. 9 * http/tests/misc/import-absolute-url.html: Added. 10 * http/tests/security/contentSecurityPolicy/1.1/import-scriptnonce-expected.txt: Added. 11 * http/tests/security/contentSecurityPolicy/1.1/import-scriptnonce.html: Added. 12 * http/tests/security/contentSecurityPolicy/1.1/resources/import-scriptnonce-allowed1.js: Added. 13 * http/tests/security/contentSecurityPolicy/1.1/resources/import-scriptnonce-allowed2.js: Added. 14 * http/tests/security/contentSecurityPolicy/1.1/resources/import-scriptnonce-allowed3.js: Added. 15 * http/tests/security/contentSecurityPolicy/1.1/resources/import-scriptnonce-allowed4.js: Added. 16 * http/tests/security/contentSecurityPolicy/1.1/resources/import-scriptnonce-allowed5.js: Added. 17 * http/tests/security/contentSecurityPolicy/1.1/resources/import-scriptnonce-allowed6.js: Added. 18 * http/tests/security/contentSecurityPolicy/1.1/resources/import-scriptnonce-blocked1.js: Added. 19 * http/tests/security/contentSecurityPolicy/1.1/resources/import-scriptnonce-blocked2.js: Added. 20 * http/tests/security/contentSecurityPolicy/1.1/resources/import-scriptnonce-blocked3.js: Added. 21 * http/tests/security/contentSecurityPolicy/1.1/resources/import-scriptnonce-blocked4.js: Added. 22 * http/tests/security/contentSecurityPolicy/1.1/resources/import-scriptnonce-blocked5.js: Added. 23 * http/tests/security/contentSecurityPolicy/1.1/resources/import-scriptnonce-blocked6.js: Added. 24 * http/tests/security/import-module-crossorigin-loads-error-expected.txt: Added. 25 * http/tests/security/import-module-crossorigin-loads-error-src-expected.txt: Added. 26 * http/tests/security/import-module-crossorigin-loads-error-src.html: Added. 27 * http/tests/security/import-module-crossorigin-loads-error.html: Added. 28 * http/tests/security/import-module-crossorigin-loads-expected.txt: Added. 29 * http/tests/security/import-module-crossorigin-loads-src-expected.txt: Added. 30 * http/tests/security/import-module-crossorigin-loads-src.html: Added. 31 * http/tests/security/import-module-crossorigin-loads.html: Added. 32 * http/tests/security/import-script-crossorigin-loads-error-expected.txt: Added. 33 * http/tests/security/import-script-crossorigin-loads-error.html: Added. 34 * http/tests/security/import-script-crossorigin-loads-omit-expected.txt: Added. 35 * http/tests/security/import-script-crossorigin-loads-omit.html: Added. 36 * http/tests/security/resources/cors-deny.php: Added. 37 * http/tests/security/resources/import-module-crossorigin-loads-error-src.js: Added. 38 (import.string_appeared_here.then): 39 * http/tests/security/resources/import-module-crossorigin-loads-src.js: Added. 40 (import.string_appeared_here.then): 41 * js/dom/modules/import-execution-order-expected.txt: Added. 42 * js/dom/modules/import-execution-order.html: Copied from LayoutTests/js/dom/modules/module-execution-error-inside-dependent-module-should-be-propagated-to-onerror.html. 43 * js/dom/modules/import-from-handler-expected.txt: Added. 44 * js/dom/modules/import-from-handler.html: Copied from LayoutTests/js/dom/modules/module-src-simple.html. 45 * js/dom/modules/import-from-javascript-url-expected.txt: Added. 46 * js/dom/modules/import-from-javascript-url.html: Copied from LayoutTests/js/dom/modules/module-execution-error-inside-dependent-module-should-be-propagated-to-onerror.html. 47 * js/dom/modules/import-from-loaded-classic-expected.txt: Added. 48 * js/dom/modules/import-from-loaded-classic.html: Copied from LayoutTests/js/dom/modules/module-src-simple.html. 49 * js/dom/modules/import-from-loaded-module-expected.txt: Added. 50 * js/dom/modules/import-from-loaded-module.html: Copied from LayoutTests/js/dom/modules/module-src-simple.html. 51 * js/dom/modules/import-from-module-expected.txt: Added. 52 * js/dom/modules/import-from-module.html: Copied from LayoutTests/js/dom/modules/module-src-simple.html. 53 * js/dom/modules/import-incorrect-relative-specifier-expected.txt: Added. 54 * js/dom/modules/import-incorrect-relative-specifier.html: Copied from LayoutTests/js/dom/modules/module-src-simple.html. 55 * js/dom/modules/import-simple-expected.txt: Added. 56 * js/dom/modules/import-simple.html: Copied from LayoutTests/js/dom/modules/module-src-simple.html. 57 * js/dom/modules/module-document-write-src.html: 58 * js/dom/modules/module-execution-error-inside-dependent-module-should-be-propagated-to-onerror.html: 59 * js/dom/modules/module-execution-order-mixed-with-classic-scripts.html: 60 * js/dom/modules/module-execution-order-mixed.html: 61 * js/dom/modules/module-inline-dynamic.html: 62 * js/dom/modules/module-inline-simple.html: 63 * js/dom/modules/module-load-event-with-src.html: 64 * js/dom/modules/module-load-same-module-from-different-entry-point-dynamic.html: 65 * js/dom/modules/module-load-same-module-from-different-entry-point-in-src.html: 66 * js/dom/modules/module-load-same-module-from-different-entry-point.html: 67 * js/dom/modules/module-not-found-error-event-with-src-and-import.html: 68 * js/dom/modules/module-src-current-script.html: 69 * js/dom/modules/module-src-dynamic.html: 70 * js/dom/modules/module-src-simple.html: 71 * js/dom/modules/module-type-case-insensitive.html: 72 * js/dom/modules/module-will-fire-beforeload.html: 73 * js/dom/modules/nomodule-dynamic-classic-src.html: 74 * js/dom/modules/nomodule-has-no-effect-on-module-inline.html: 75 * js/dom/modules/nomodule-has-no-effect-on-module-src.html: 76 * js/dom/modules/nomodule-prevents-execution-classic-script-src.html: 77 * js/dom/modules/nomodule-reflect.html: 78 * js/dom/modules/resources/error-classic-script.js: Renamed from LayoutTests/js/dom/modules/script-tests/error-classic-script.js. 79 * js/dom/modules/resources/import-from-loaded-classic-finish.js: Added. 80 * js/dom/modules/resources/import-from-loaded-classic.js: Added. 81 * js/dom/modules/resources/import-from-loaded-module-finish.js: Added. 82 * js/dom/modules/resources/import-from-loaded-module.js: Added. 83 * js/dom/modules/resources/module-document-write-src.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-document-write-src.js. 84 * js/dom/modules/resources/module-execution-error-inside-dependent-module-should-be-propagated-to-onerror-throw.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-execution-error-inside-dependent-module-should-be-propagated-to-onerror-throw.js. 85 * js/dom/modules/resources/module-execution-error-inside-dependent-module-should-be-propagated-to-onerror.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-execution-error-inside-dependent-module-should-be-propagated-to-onerror.js. 86 * js/dom/modules/resources/module-execution-order-mixed-2.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-execution-order-mixed-2.js. 87 * js/dom/modules/resources/module-execution-order-mixed-cappuccino.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-execution-order-mixed-cappuccino.js. 88 * js/dom/modules/resources/module-execution-order-mixed-cocoa.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-execution-order-mixed-cocoa.js. 89 * js/dom/modules/resources/module-execution-order-mixed-matcha.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-execution-order-mixed-matcha.js. 90 * js/dom/modules/resources/module-execution-order-mixed-with-classic-scripts-2.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-execution-order-mixed-with-classic-scripts-2.js. 91 * js/dom/modules/resources/module-execution-order-mixed-with-classic-scripts-cappuccino.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-execution-order-mixed-with-classic-scripts-cappuccino.js. 92 * js/dom/modules/resources/module-execution-order-mixed-with-classic-scripts-cocoa.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-execution-order-mixed-with-classic-scripts-cocoa.js. 93 * js/dom/modules/resources/module-execution-order-mixed-with-classic-scripts-matcha.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-execution-order-mixed-with-classic-scripts-matcha.js. 94 * js/dom/modules/resources/module-execution-order-mixed-with-classic-scripts.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-execution-order-mixed-with-classic-scripts.js. 95 * js/dom/modules/resources/module-execution-order-mixed.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-execution-order-mixed.js. 96 * js/dom/modules/resources/module-inline-dynamic.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-inline-dynamic.js. 97 * js/dom/modules/resources/module-inline-simple.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-inline-simple.js. 98 * js/dom/modules/resources/module-load-event-with-src.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-load-event-with-src.js. 99 * js/dom/modules/resources/module-load-same-module-from-different-entry-point.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-load-same-module-from-different-entry-point.js. 100 * js/dom/modules/resources/module-not-found-error-event-with-src-and-import.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-not-found-error-event-with-src-and-import.js. 101 * js/dom/modules/resources/module-src-current-script.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-src-current-script.js. 102 * js/dom/modules/resources/module-src-dynamic-cocoa.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-src-dynamic-cocoa.js. 103 * js/dom/modules/resources/module-src-dynamic.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-src-dynamic.js. 104 * js/dom/modules/resources/module-src-simple-cocoa.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-src-simple-cocoa.js. 105 * js/dom/modules/resources/module-src-simple.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-src-simple.js. 106 * js/dom/modules/resources/module-will-fire-beforeload.js: Renamed from LayoutTests/js/dom/modules/script-tests/module-will-fire-beforeload.js. 107 1 108 2017-01-26 Chris Dumez <cdumez@apple.com> 2 109 -
trunk/LayoutTests/js/dom/modules/import-execution-order.html
r211277 r211280 6 6 <body> 7 7 <script> 8 description('Test window.onerror will be fired when the dependent module throw an error.'); 8 description('Test import execution order.'); 9 window.count = 0; 10 9 11 // Module will be executed asynchronously. 10 12 window.jsTestIsAsync = true; 11 13 debug('Module is not executed yet.'); 12 window.onerror = function () {13 finishJSTest();14 }15 14 </script> 16 15 <script src="../../../resources/js-test-post.js"></script> 17 <script type="module"> 18 import "./script-tests/module-execution-error-inside-dependent-module-should-be-propagated-to-onerror.js" 19 testFailed("executed"); 16 <script> 17 (async function () { 18 await import(`./resources/module-execution-order-mixed.js`); 19 shouldBe("count++", "4"); 20 await import(`./resources/module-execution-order-mixed-2.js`); 21 shouldBe("count++", "6"); 22 finishJSTest(); 23 }()); 20 24 </script> 21 25 </body> -
trunk/LayoutTests/js/dom/modules/import-from-handler.html
r211277 r211280 6 6 <body> 7 7 <script> 8 description('Test module with "src" attribute.');8 description('Test import from handler.'); 9 9 10 10 // Module will be executed asynchronously. … … 12 12 </script> 13 13 <script> 14 debug('Module is not executed yet.');15 14 </script> 16 15 <script src="../../../resources/js-test-post.js"></script> 17 <script type="module" src="./script-tests/module-src-simple.js"></script> 16 <a id="target" onclick="(import(`./resources/module-src-simple.js`)).then(() => finishJSTest())">MODULE</a> 17 <script type="module"> 18 debug('Module is not executed yet.'); 19 let anchor = document.getElementById('target'); 20 anchor.dispatchEvent(new MouseEvent('click')); 21 </script> 18 22 </body> 19 23 </html> -
trunk/LayoutTests/js/dom/modules/import-from-javascript-url.html
r211277 r211280 6 6 <body> 7 7 <script> 8 description('Test window.onerror will be fired when the dependent module throw an error.'); 8 description('Test import from javascript URL.'); 9 9 10 // Module will be executed asynchronously. 10 11 window.jsTestIsAsync = true; 11 debug('Module is not executed yet.'); 12 window.onerror = function () { 13 finishJSTest(); 14 } 12 </script> 13 <script> 15 14 </script> 16 15 <script src="../../../resources/js-test-post.js"></script> 16 <a id="target" href="javascript:void((import(`./resources/module-src-simple.js`)).then(() => finishJSTest()))">MODULE</a> 17 17 <script type="module"> 18 import "./script-tests/module-execution-error-inside-dependent-module-should-be-propagated-to-onerror.js" 19 testFailed("executed"); 18 debug('Module is not executed yet.'); 19 let anchor = document.getElementById('target'); 20 anchor.dispatchEvent(new MouseEvent('click')); 20 21 </script> 21 22 </body> -
trunk/LayoutTests/js/dom/modules/import-from-loaded-classic.html
r211277 r211280 6 6 <body> 7 7 <script> 8 description('Test nomodule does not have any effect on module script.');8 description('Test import from loaded classic.'); 9 9 10 10 // Module will be executed asynchronously. 11 11 window.jsTestIsAsync = true; 12 13 function loaded() 14 { 15 shouldBeTrue(`window.imported`); 16 finishJSTest(); 17 } 12 18 </script> 13 19 <script> 14 debug('Module is not executed yet.');15 20 </script> 16 21 <script src="../../../resources/js-test-post.js"></script> 17 <script nomodule type="module" src="./script-tests/module-src-simple.js"></script>22 <script src="./resources/import-from-loaded-classic.js"></script> 18 23 </body> 19 24 </html> -
trunk/LayoutTests/js/dom/modules/import-from-loaded-module.html
r211277 r211280 6 6 <body> 7 7 <script> 8 description('Test nomodule does not have any effect on module script.');8 description('Test import from loaded module.'); 9 9 10 10 // Module will be executed asynchronously. 11 11 window.jsTestIsAsync = true; 12 13 function loaded() 14 { 15 shouldBeTrue(`window.imported`); 16 finishJSTest(); 17 } 18 12 19 </script> 13 20 <script> 14 debug('Module is not executed yet.');15 21 </script> 16 22 <script src="../../../resources/js-test-post.js"></script> 17 <script nomodule type="module" src="./script-tests/module-src-simple.js"></script>23 <script type="module" src="./resources/import-from-loaded-module.js"></script> 18 24 </body> 19 25 </html> -
trunk/LayoutTests/js/dom/modules/import-incorrect-relative-specifier.html
r211277 r211280 6 6 <body> 7 7 <script> 8 description('Test module with "src" attribute.'); 9 8 description('Test import rejects the incorrect relative specifiers.'); 10 9 // Module will be executed asynchronously. 11 10 window.jsTestIsAsync = true; 12 11 </script> 12 <script src="../../../resources/js-test-post.js"></script> 13 13 <script> 14 debug('Module is not executed yet.'); 14 (async function () { 15 await shouldReject(`import("incorrect")`); 16 await shouldReject(`import("$hello")`); 17 await shouldReject(`import(".../test")`); 18 finishJSTest(); 19 }()); 15 20 </script> 16 <script src="../../../resources/js-test-post.js"></script>17 <script type="module" src="./script-tests/module-src-simple.js"></script>18 21 </body> 19 22 </html> -
trunk/LayoutTests/js/dom/modules/import-simple.html
r211277 r211280 6 6 <body> 7 7 <script> 8 description('Test module with "src" attribute.');8 description('Test import simple.'); 9 9 10 10 // Module will be executed asynchronously. … … 12 12 </script> 13 13 <script> 14 debug('Module is not executed yet.');15 14 </script> 16 15 <script src="../../../resources/js-test-post.js"></script> 17 <script type="module" src="./script-tests/module-src-simple.js"></script> 16 <script> 17 (async function() { 18 debug('Module is not executed yet.'); 19 await import(`./resources/module-src-simple.js`); 20 finishJSTest(); 21 }()); 22 </script> 18 23 </body> 19 24 </html> -
trunk/LayoutTests/js/dom/modules/module-document-write-src.html
r208788 r211280 15 15 </script> 16 16 <script src="../../../resources/js-test-post.js"></script> 17 <script type="module" src=" script-tests/module-document-write-src.js"></script>17 <script type="module" src="resources/module-document-write-src.js"></script> 18 18 </body> 19 19 </html> -
trunk/LayoutTests/js/dom/modules/module-execution-error-inside-dependent-module-should-be-propagated-to-onerror.html
r208788 r211280 16 16 <script src="../../../resources/js-test-post.js"></script> 17 17 <script type="module"> 18 import "./ script-tests/module-execution-error-inside-dependent-module-should-be-propagated-to-onerror.js"18 import "./resources/module-execution-error-inside-dependent-module-should-be-propagated-to-onerror.js" 19 19 testFailed("executed"); 20 20 </script> -
trunk/LayoutTests/js/dom/modules/module-execution-order-mixed-with-classic-scripts.html
r208788 r211280 21 21 shouldBe("count++", "1"); 22 22 </script> 23 <script type="module" src=" script-tests/module-execution-order-mixed-with-classic-scripts.js"></script>23 <script type="module" src="resources/module-execution-order-mixed-with-classic-scripts.js"></script> 24 24 <script> 25 25 shouldBe("count++", "2"); … … 31 31 shouldBe("count++", "3"); 32 32 </script> 33 <script type="module" src=" script-tests/module-execution-order-mixed-with-classic-scripts-2.js"></script>33 <script type="module" src="resources/module-execution-order-mixed-with-classic-scripts-2.js"></script> 34 34 <script> 35 35 shouldBe("count++", "4"); -
trunk/LayoutTests/js/dom/modules/module-execution-order-mixed.html
r208788 r211280 15 15 </script> 16 16 <script src="../../../resources/js-test-post.js"></script> 17 <script type="module" src=" script-tests/module-execution-order-mixed.js"></script>17 <script type="module" src="resources/module-execution-order-mixed.js"></script> 18 18 <script type="module"> 19 19 shouldBe("count++", "4"); 20 20 </script> 21 <script type="module" src=" script-tests/module-execution-order-mixed-2.js"></script>21 <script type="module" src="resources/module-execution-order-mixed-2.js"></script> 22 22 <script type="module"> 23 23 shouldBe("count++", "6"); -
trunk/LayoutTests/js/dom/modules/module-inline-dynamic.html
r208788 r211280 17 17 var element = document.createElement("script"); 18 18 element.textContent = ` 19 import Cocoa from "./ script-tests/module-inline-dynamic.js";19 import Cocoa from "./resources/module-inline-dynamic.js"; 20 20 var cocoa = new Cocoa(); 21 21 -
trunk/LayoutTests/js/dom/modules/module-inline-simple.html
r208788 r211280 16 16 <script src="../../../resources/js-test-post.js"></script> 17 17 <script type="module"> 18 import Cocoa from "./ script-tests/module-inline-simple.js";18 import Cocoa from "./resources/module-inline-simple.js"; 19 19 var cocoa = new Cocoa(); 20 20 -
trunk/LayoutTests/js/dom/modules/module-load-event-with-src.html
r208788 r211280 17 17 </script> 18 18 <script src="../../../resources/js-test-post.js"></script> 19 <script type="module" onload="onLoad()" src=" script-tests/module-load-event-with-src.js"></script>19 <script type="module" onload="onLoad()" src="resources/module-load-event-with-src.js"></script> 20 20 </body> 21 21 </html> -
trunk/LayoutTests/js/dom/modules/module-load-same-module-from-different-entry-point-dynamic.html
r208788 r211280 21 21 <script src="../../../resources/js-test-post.js"></script> 22 22 <script type="module"> 23 import "./ script-tests/module-load-same-module-from-different-entry-point.js"23 import "./resources/module-load-same-module-from-different-entry-point.js" 24 24 debug('Executing the module.'); 25 25 shouldBe(`window.moduleExecutedCount`, `1`); 26 26 var element = document.createElement("script"); 27 27 element.type = "module"; 28 element.innerText = `import "./ script-tests/module-load-same-module-from-different-entry-point.js"`;28 element.innerText = `import "./resources/module-load-same-module-from-different-entry-point.js"`; 29 29 element.onload = onLoad; 30 30 document.body.appendChild(element); -
trunk/LayoutTests/js/dom/modules/module-load-same-module-from-different-entry-point-in-src.html
r209172 r211280 23 23 </script> 24 24 <script src="../../../resources/js-test-post.js"></script> 25 <script type="module" src="./ script-tests/module-load-same-module-from-different-entry-point.js" onload="onLoad()"></script>26 <script type="module" src="./ script-tests/module-load-same-module-from-different-entry-point.js" onload="onLoad()"></script>25 <script type="module" src="./resources/module-load-same-module-from-different-entry-point.js" onload="onLoad()"></script> 26 <script type="module" src="./resources/module-load-same-module-from-different-entry-point.js" onload="onLoad()"></script> 27 27 <script type="module"> 28 28 finish(); -
trunk/LayoutTests/js/dom/modules/module-load-same-module-from-different-entry-point.html
r208788 r211280 25 25 <script src="../../../resources/js-test-post.js"></script> 26 26 <script type="module" onload="onLoad()"> 27 import "./ script-tests/module-load-same-module-from-different-entry-point.js"27 import "./resources/module-load-same-module-from-different-entry-point.js" 28 28 debug('Executing the module.'); 29 29 window.firstModuleIsExecuted = true; 30 30 </script> 31 31 <script type="module" onload="onLoad()"> 32 import "./ script-tests/module-load-same-module-from-different-entry-point.js"32 import "./resources/module-load-same-module-from-different-entry-point.js" 33 33 debug('Executing the module.'); 34 34 window.secondModuleIsExecuted = true; -
trunk/LayoutTests/js/dom/modules/module-not-found-error-event-with-src-and-import.html
r208788 r211280 17 17 </script> 18 18 <script src="../../../resources/js-test-post.js"></script> 19 <script type="module" src=" script-tests/module-not-found-error-event-with-src-and-import.js" onerror="onError()"></script>19 <script type="module" src="resources/module-not-found-error-event-with-src-and-import.js" onerror="onError()"></script> 20 20 <script type="module"> 21 21 shouldNotBe(`error`, `null`); -
trunk/LayoutTests/js/dom/modules/module-src-current-script.html
r208788 r211280 15 15 </script> 16 16 <script src="../../../resources/js-test-post.js"></script> 17 <script type="module" src="./ script-tests/module-src-current-script.js"></script>17 <script type="module" src="./resources/module-src-current-script.js"></script> 18 18 </body> 19 19 </html> -
trunk/LayoutTests/js/dom/modules/module-src-dynamic.html
r208788 r211280 17 17 var element = document.createElement('script'); 18 18 element.type = 'module'; 19 element.src = './ script-tests/module-src-dynamic.js';19 element.src = './resources/module-src-dynamic.js'; 20 20 document.body.appendChild(element); 21 21 }()); -
trunk/LayoutTests/js/dom/modules/module-src-simple.html
r208788 r211280 15 15 </script> 16 16 <script src="../../../resources/js-test-post.js"></script> 17 <script type="module" src="./ script-tests/module-src-simple.js"></script>17 <script type="module" src="./resources/module-src-simple.js"></script> 18 18 </body> 19 19 </html> -
trunk/LayoutTests/js/dom/modules/module-type-case-insensitive.html
r208788 r211280 27 27 28 28 <script type="MoDuLe"> 29 import Cocoa from "./ script-tests/module-inline-simple.js";29 import Cocoa from "./resources/module-inline-simple.js"; 30 30 window.resolve1(); 31 31 </script> 32 32 33 33 <script type="MODULE"> 34 import Cocoa from "./ script-tests/module-inline-simple.js";34 import Cocoa from "./resources/module-inline-simple.js"; 35 35 window.resolve2(); 36 36 </script> -
trunk/LayoutTests/js/dom/modules/module-will-fire-beforeload.html
r208788 r211280 12 12 </script> 13 13 <script src="../../../resources/js-test-post.js"></script> 14 <script type="module" onbeforeload="finishJSTest()" src=" script-tests/module-will-fire-beforeload.js"></script>14 <script type="module" onbeforeload="finishJSTest()" src="resources/module-will-fire-beforeload.js"></script> 15 15 </body> 16 16 </html> -
trunk/LayoutTests/js/dom/modules/nomodule-dynamic-classic-src.html
r211078 r211280 17 17 var element = document.createElement('script'); 18 18 element.noModule = true; 19 element.src = './ script-tests/error-classic-script.js';19 element.src = './resources/error-classic-script.js'; 20 20 document.body.appendChild(element); 21 21 setTimeout(function () { -
trunk/LayoutTests/js/dom/modules/nomodule-has-no-effect-on-module-inline.html
r211078 r211280 16 16 <script src="../../../resources/js-test-post.js"></script> 17 17 <script nomodule type="module"> 18 import Cocoa from "./ script-tests/module-inline-simple.js";18 import Cocoa from "./resources/module-inline-simple.js"; 19 19 var cocoa = new Cocoa(); 20 20 -
trunk/LayoutTests/js/dom/modules/nomodule-has-no-effect-on-module-src.html
r211078 r211280 15 15 </script> 16 16 <script src="../../../resources/js-test-post.js"></script> 17 <script nomodule type="module" src="./ script-tests/module-src-simple.js"></script>17 <script nomodule type="module" src="./resources/module-src-simple.js"></script> 18 18 </body> 19 19 </html> -
trunk/LayoutTests/js/dom/modules/nomodule-prevents-execution-classic-script-src.html
r211078 r211280 9 9 window.executed = false; 10 10 </script> 11 <script nomodule src="./ script-tests/module-src-simple.js"></script>11 <script nomodule src="./resources/module-src-simple.js"></script> 12 12 <script> 13 13 shouldBeFalse(`executed`); -
trunk/LayoutTests/js/dom/modules/nomodule-reflect.html
r211078 r211280 14 14 </script> 15 15 <script src="../../../resources/js-test-post.js"></script> 16 <script id="target" src="./ script-tests/error-classic-script.js" nomodule></script>16 <script id="target" src="./resources/error-classic-script.js" nomodule></script> 17 17 <script id="target2"> 18 18 window.executed2 = true; -
trunk/LayoutTests/js/dom/modules/script-tests/error-classic-script.js
r211078 r211280 1 window.executed = true;2 testFailed("error");3 -
trunk/Source/WebCore/CMakeLists.txt
r211161 r211280 1476 1476 dom/ScopedEventQueue.cpp 1477 1477 dom/ScriptElement.cpp 1478 dom/ScriptElementCachedScriptFetcher.cpp 1478 1479 dom/ScriptExecutionContext.cpp 1479 1480 dom/ScriptRunner.cpp -
trunk/Source/WebCore/ChangeLog
r211256 r211280 1 2017-01-27 Yusuke Suzuki <utatane.tea@gmail.com> 2 3 Implement dynamic-import for WebCore 4 https://bugs.webkit.org/show_bug.cgi?id=166926 5 6 Reviewed by Ryosuke Niwa. 7 8 This patch introduces browser side dynamic-import implementation. 9 The dynamic-import is new ES feature which is now stage 3. 10 The JSC shell already implements it. 11 12 The dynamic-import allows us to kick module loading in a dynamic manner. 13 For example, you can write, 14 15 await module = import(`${HOST}/hello.js`); 16 17 The dynamic `import` operator (this is not a function) returns a promise with 18 module namespace object if the module loading succeeds. Otherwise, it returns 19 a rejected promise. 20 21 And importantly, this feature allows us to kick module loading from classic script. 22 Previously, module loading can be only used from <script type="module"> tag. And 23 all the module loading is done statically. 24 25 * CMakeLists.txt: 26 * WebCore.xcodeproj/project.pbxproj: 27 * bindings/js/CachedModuleScriptLoader.cpp: 28 (WebCore::CachedModuleScriptLoader::load): 29 * bindings/js/CachedScriptFetcher.cpp: 30 (WebCore::CachedScriptFetcher::create): 31 (WebCore::CachedScriptFetcher::requestModuleScript): 32 requestModuleScript function is used only when loading a new module script. 33 So, LoadableClassicScript should use requestScriptWithCache to load itself. 34 We pass String() for cross origin mode for null cross origin attribute as 35 specified. 36 37 (WebCore::CachedScriptFetcher::requestScriptWithCache): 38 * bindings/js/CachedScriptFetcher.h: 39 (WebCore::CachedScriptFetcher::CachedScriptFetcher): 40 * bindings/js/JSDOMWindowBase.cpp: 41 (WebCore::JSDOMWindowBase::moduleLoaderImportModule): 42 * bindings/js/JSDOMWindowBase.h: 43 * bindings/js/JSLazyEventListener.cpp: 44 (WebCore::JSLazyEventListener::initializeJSFunction): 45 * bindings/js/ScriptController.cpp: 46 (WebCore::ScriptController::executeScript): 47 * bindings/js/ScriptModuleLoader.cpp: 48 (WebCore::resolveModuleSpecifier): 49 Extract the part of resolving module specifier to a static function to use 50 it in ScriptModuleLoader::resolve and ScriptModuleLoader::importModule. 51 52 (WebCore::ScriptModuleLoader::resolve): 53 (WebCore::rejectPromise): 54 (WebCore::ScriptModuleLoader::importModule): 55 New hook moduleLoaderImportModule is implemented. This hook is called when 56 `import` operator is used. This hook is responsible to 57 1. resolve the module name to obtain module specifier. (like, resolve the 58 relative URL to get absolute URL.) 59 2. kick module loading with the resolved specifier. 60 When resolving the module name, the referrer information is needed. 61 For example, "./script.js" will be resolved to "http://example.com/script.js" if 62 the referrer module specifier is "http://example.com/". 63 If `import("./script.js")` is executed in the classic script 64 src="http://example.com/test.js", it starts loading "http://example.com/script.js". 65 So the information of the caller of `import` operator is necessary here. 66 This appropriate referrer is propagated by SourceOrigin. 67 68 * bindings/js/ScriptModuleLoader.h: 69 * dom/InlineClassicScript.h: 70 * dom/LoadableClassicScript.cpp: 71 (WebCore::LoadableClassicScript::load): 72 * dom/LoadableClassicScript.h: 73 * dom/LoadableModuleScript.h: 74 * dom/LoadableScript.h: 75 (WebCore::LoadableScript::LoadableScript): 76 (WebCore::LoadableScript::isClassicScript): Deleted. 77 (WebCore::LoadableScript::isModuleScript): Deleted. 78 * dom/ScriptElement.h: 79 * dom/ScriptElementCachedScriptFetcher.cpp: Copied from Source/WebCore/dom/InlineClassicScript.h. 80 (WebCore::ScriptElementCachedScriptFetcher::requestModuleScript): 81 This requestModuleScript will be used when the script tag (or modules imported from the script tag) uses `import` operator. 82 In classic scripts, `crossorigin` mode always becomes "omit" while module scripts 83 propagate the original `crossorigin` value. 84 85 * dom/ScriptElementCachedScriptFetcher.h: Copied from Source/WebCore/bindings/js/CachedScriptFetcher.h. 86 (WebCore::ScriptElementCachedScriptFetcher::crossOriginMode): 87 (WebCore::ScriptElementCachedScriptFetcher::ScriptElementCachedScriptFetcher): 88 1 89 2017-01-26 Chris Dumez <cdumez@apple.com> 2 90 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r211255 r211280 6328 6328 E3B7C0631DC34160001FB0B8 /* JSDocumentDOMJIT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E3B7C0621DC3415A001FB0B8 /* JSDocumentDOMJIT.cpp */; }; 6329 6329 E3C99A091DC3D41C00794AD3 /* DOMJITCheckDOM.h in Headers */ = {isa = PBXBuildFile; fileRef = E3C99A081DC3D41700794AD3 /* DOMJITCheckDOM.h */; }; 6330 E3E4E2A71E3B17100023BB8A /* ScriptElementCachedScriptFetcher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E3E4E2A51E3B16FC0023BB8A /* ScriptElementCachedScriptFetcher.cpp */; }; 6331 E3E4E2A81E3B17100023BB8A /* ScriptElementCachedScriptFetcher.h in Headers */ = {isa = PBXBuildFile; fileRef = E3E4E2A61E3B16FC0023BB8A /* ScriptElementCachedScriptFetcher.h */; settings = {ATTRIBUTES = (Private, ); }; }; 6330 6332 E3FA38641D71812D00AA5950 /* PendingScriptClient.h in Headers */ = {isa = PBXBuildFile; fileRef = E3FA38611D716E7600AA5950 /* PendingScriptClient.h */; }; 6331 6333 E401C27517CE53EC00C41A35 /* ElementIteratorAssertions.h in Headers */ = {isa = PBXBuildFile; fileRef = E401C27417CE53EC00C41A35 /* ElementIteratorAssertions.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 14379 14381 E3C99A081DC3D41700794AD3 /* DOMJITCheckDOM.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMJITCheckDOM.h; sourceTree = "<group>"; }; 14380 14382 E3D049931DADC04500718F3C /* NodeConstants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NodeConstants.h; sourceTree = "<group>"; }; 14383 E3E4E2A51E3B16FC0023BB8A /* ScriptElementCachedScriptFetcher.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptElementCachedScriptFetcher.cpp; sourceTree = "<group>"; }; 14384 E3E4E2A61E3B16FC0023BB8A /* ScriptElementCachedScriptFetcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptElementCachedScriptFetcher.h; sourceTree = "<group>"; }; 14381 14385 E3FA38611D716E7600AA5950 /* PendingScriptClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PendingScriptClient.h; sourceTree = "<group>"; }; 14382 14386 E401C27417CE53EC00C41A35 /* ElementIteratorAssertions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ElementIteratorAssertions.h; sourceTree = "<group>"; }; … … 24412 24416 08A484750E5272C500C3FE76 /* ScriptElement.cpp */, 24413 24417 08A484760E5272C500C3FE76 /* ScriptElement.h */, 24418 E3E4E2A51E3B16FC0023BB8A /* ScriptElementCachedScriptFetcher.cpp */, 24419 E3E4E2A61E3B16FC0023BB8A /* ScriptElementCachedScriptFetcher.h */, 24414 24420 E11C9DAF0EB3699500E409DB /* ScriptExecutionContext.cpp */, 24415 24421 E11C9D9A0EB3681200E409DB /* ScriptExecutionContext.h */, … … 25864 25870 8482B7461198C35400BFB005 /* HashChangeEvent.h in Headers */, 25865 25871 A8748BE012CBF2DC001FBA41 /* HashTools.h in Headers */, 25872 E3E4E2A81E3B17100023BB8A /* ScriptElementCachedScriptFetcher.h in Headers */, 25866 25873 F55B3DC01251F12D003EF269 /* HiddenInputType.h in Headers */, 25867 25874 515BE19C1D54F6C100DD7C68 /* HIDGamepad.h in Headers */, … … 31848 31855 AAA728F816D1D8BC00D3BBC6 /* WebAccessibilityObjectWrapperIOS.mm in Sources */, 31849 31856 AA478A8016CD70C3007D1BB4 /* WebAccessibilityObjectWrapperMac.mm in Sources */, 31857 E3E4E2A71E3B17100023BB8A /* ScriptElementCachedScriptFetcher.cpp in Sources */, 31850 31858 2D3EF4491917915C00034184 /* WebActionDisablingCALayerDelegate.mm in Sources */, 31851 31859 120DE3ED1C86CA3E00B6D4DD /* WebAnimation.cpp in Sources */, -
trunk/Source/WebCore/bindings/js/CachedModuleScriptLoader.cpp
r210627 r211280 62 62 { 63 63 ASSERT(!m_cachedScript); 64 m_cachedScript = m_scriptFetcher->request ScriptWithCache(document, sourceURL);64 m_cachedScript = m_scriptFetcher->requestModuleScript(document, sourceURL); 65 65 if (!m_cachedScript) 66 66 return false; -
trunk/Source/WebCore/bindings/js/CachedScriptFetcher.cpp
r210627 r211280 35 35 namespace WebCore { 36 36 37 CachedResourceHandle<CachedScript> CachedScriptFetcher::requestScriptWithCache(Document& document, const URL& sourceURL) const 37 Ref<CachedScriptFetcher> CachedScriptFetcher::create(const String& charset) 38 { 39 return adoptRef(*new CachedScriptFetcher(charset)); 40 } 41 42 CachedResourceHandle<CachedScript> CachedScriptFetcher::requestModuleScript(Document& document, const URL& sourceURL) const 43 { 44 return requestScriptWithCache(document, sourceURL, String()); 45 } 46 47 CachedResourceHandle<CachedScript> CachedScriptFetcher::requestScriptWithCache(Document& document, const URL& sourceURL, const String& crossOriginMode) const 38 48 { 39 49 auto* settings = document.settings(); … … 47 57 48 58 CachedResourceRequest request(ResourceRequest(sourceURL), options); 49 request.setAsPotentiallyCrossOrigin( m_crossOriginMode, document);59 request.setAsPotentiallyCrossOrigin(crossOriginMode, document); 50 60 request.upgradeInsecureRequestIfNeeded(document); 51 61 52 62 request.setCharset(m_charset); 53 request.setInitiator(m_initiatorName); 63 if (!m_initiatorName.isNull()) 64 request.setInitiator(m_initiatorName); 54 65 55 66 return document.cachedResourceLoader().requestScript(WTFMove(request)); -
trunk/Source/WebCore/bindings/js/CachedScriptFetcher.h
r210627 r211280 38 38 class CachedScriptFetcher : public JSC::ScriptFetcher { 39 39 public: 40 CachedResourceHandle<CachedScript> requestScriptWithCache(Document&, const URL& sourceURL) const; 40 virtual CachedResourceHandle<CachedScript> requestModuleScript(Document&, const URL& sourceURL) const; 41 42 static Ref<CachedScriptFetcher> create(const String& charset); 41 43 42 44 protected: 43 CachedScriptFetcher(const String& nonce, const String& c rossOriginMode, const String& charset, const AtomicString& initiatorName, bool isInUserAgentShadowTree)45 CachedScriptFetcher(const String& nonce, const String& charset, const AtomicString& initiatorName, bool isInUserAgentShadowTree) 44 46 : m_nonce(nonce) 45 , m_crossOriginMode(crossOriginMode)46 47 , m_charset(charset) 47 48 , m_initiatorName(initiatorName) … … 50 51 } 51 52 53 CachedScriptFetcher(const String& charset) 54 : m_charset(charset) 55 { 56 } 57 58 CachedResourceHandle<CachedScript> requestScriptWithCache(Document&, const URL& sourceURL, const String& crossOriginMode) const; 59 52 60 private: 53 61 String m_nonce; 54 String m_crossOriginMode;55 62 String m_charset; 56 63 AtomicString m_initiatorName; -
trunk/Source/WebCore/bindings/js/JSDOMWindowBase.cpp
r211247 r211280 65 65 &queueTaskToEventLoop, 66 66 &shouldInterruptScriptBeforeTimeout, 67 nullptr,67 &moduleLoaderImportModule, 68 68 &moduleLoaderResolve, 69 69 &moduleLoaderFetch, … … 333 333 } 334 334 335 JSC::JSInternalPromise* JSDOMWindowBase::moduleLoaderImportModule(JSC::JSGlobalObject* globalObject, JSC::ExecState* exec, JSC::JSModuleLoader* moduleLoader, JSC::JSString* moduleName, const JSC::SourceOrigin& sourceOrigin) 336 { 337 JSDOMWindowBase* thisObject = JSC::jsCast<JSDOMWindowBase*>(globalObject); 338 if (RefPtr<Document> document = thisObject->wrapped().document()) 339 return document->moduleLoader()->importModule(globalObject, exec, moduleLoader, moduleName, sourceOrigin); 340 JSC::JSInternalPromiseDeferred* deferred = JSC::JSInternalPromiseDeferred::create(exec, globalObject); 341 return deferred->reject(exec, jsUndefined()); 342 } 343 335 344 } // namespace WebCore -
trunk/Source/WebCore/bindings/js/JSDOMWindowBase.h
r211247 r211280 80 80 static JSC::JSInternalPromise* moduleLoaderFetch(JSC::JSGlobalObject*, JSC::ExecState*, JSC::JSModuleLoader*, JSC::JSValue, JSC::JSValue); 81 81 static JSC::JSValue moduleLoaderEvaluate(JSC::JSGlobalObject*, JSC::ExecState*, JSC::JSModuleLoader*, JSC::JSValue, JSC::JSValue, JSC::JSValue); 82 static JSC::JSInternalPromise* moduleLoaderImportModule(JSC::JSGlobalObject*, JSC::ExecState*, JSC::JSModuleLoader*, JSC::JSString*, const JSC::SourceOrigin&); 82 83 83 84 RefPtr<DOMWindow> m_wrapped; -
trunk/Source/WebCore/bindings/js/JSLazyEventListener.cpp
r210149 r211280 21 21 #include "JSLazyEventListener.h" 22 22 23 #include "CachedScriptFetcher.h" 23 24 #include "ContentSecurityPolicy.h" 24 25 #include "Frame.h" … … 113 114 JSObject* jsFunction = constructFunctionSkippingEvalEnabledCheck( 114 115 exec, exec->lexicalGlobalObject(), args, Identifier::fromString(exec, m_functionName), 115 SourceOrigin { m_sourceURL }, m_sourceURL, m_sourcePosition, overrideLineNumber);116 SourceOrigin { m_sourceURL, CachedScriptFetcher::create(document.charset()) }, m_sourceURL, m_sourcePosition, overrideLineNumber); 116 117 117 118 if (UNLIKELY(scope.exception())) { -
trunk/Source/WebCore/bindings/js/ScriptController.cpp
r211247 r211280 676 676 { 677 677 UserGestureIndicator gestureIndicator(forceUserGesture ? std::optional<ProcessingUserGestureState>(ProcessingUserGesture) : std::nullopt); 678 return executeScript(ScriptSourceCode(script, m_frame.document()->url() ), exceptionDetails);678 return executeScript(ScriptSourceCode(script, m_frame.document()->url(), TextPosition(), JSC::SourceProviderSourceType::Program, CachedScriptFetcher::create(m_frame.document()->charset())), exceptionDetails); 679 679 } 680 680 -
trunk/Source/WebCore/bindings/js/ScriptModuleLoader.cpp
r211247 r211280 29 29 #include "CachedModuleScriptLoader.h" 30 30 #include "CachedScript.h" 31 #include "CachedScriptFetcher.h" 31 32 #include "Document.h" 32 33 #include "Frame.h" … … 36 37 #include "ScriptController.h" 37 38 #include "ScriptSourceCode.h" 39 #include <runtime/Completion.h> 38 40 #include <runtime/JSInternalPromise.h> 39 41 #include <runtime/JSInternalPromiseDeferred.h> … … 62 64 } 63 65 66 static Expected<URL, ASCIILiteral> resolveModuleSpecifier(Document& document, const String& specifier, const URL& baseURL) 67 { 68 // https://html.spec.whatwg.org/multipage/webappapis.html#resolve-a-module-specifier 69 70 URL absoluteURL(URL(), specifier); 71 if (absoluteURL.isValid()) 72 return absoluteURL; 73 74 if (!specifier.startsWith('/') && !specifier.startsWith("./") && !specifier.startsWith("../")) 75 return makeUnexpected(ASCIILiteral("Module specifier does not start with \"/\", \"./\", or \"../\".")); 76 77 auto result = document.completeURL(specifier, baseURL); 78 if (!result.isValid()) 79 return makeUnexpected(ASCIILiteral("Module name does not resolve to a valid URL.")); 80 return result; 81 } 82 64 83 JSC::JSInternalPromise* ScriptModuleLoader::resolve(JSC::JSGlobalObject* jsGlobalObject, JSC::ExecState* exec, JSC::JSModuleLoader*, JSC::JSValue moduleNameValue, JSC::JSValue importerModuleKey, JSC::JSValue) 65 84 { … … 76 95 } 77 96 78 // https://html.spec.whatwg.org/multipage/webappapis.html#resolve-a-module-specifier79 80 97 if (!moduleNameValue.isString()) { 81 promise->reject(TypeError, ASCIILiteral(" Module specifier is not Symbol orString."));98 promise->reject(TypeError, ASCIILiteral("Importer module key is not a Symbol or a String.")); 82 99 return jsPromise.promise(); 83 100 } 84 101 85 102 String specifier = asString(moduleNameValue)->value(exec); 86 87 // 1. Apply the URL parser to specifier. If the result is not failure, return the result. 88 URL absoluteURL(URL(), specifier); 89 if (absoluteURL.isValid()) { 90 promise->resolve<IDLDOMString>(absoluteURL.string()); 91 return jsPromise.promise(); 92 } 93 94 // 2. If specifier does not start with the character U+002F SOLIDUS (/), the two-character sequence U+002E FULL STOP, U+002F SOLIDUS (./), 95 // or the three-character sequence U+002E FULL STOP, U+002E FULL STOP, U+002F SOLIDUS (../), return failure and abort these steps. 96 if (!specifier.startsWith('/') && !specifier.startsWith("./") && !specifier.startsWith("../")) { 97 promise->reject(TypeError, ASCIILiteral("Module specifier does not start with \"/\", \"./\", or \"../\".")); 98 return jsPromise.promise(); 99 } 100 101 // 3. Return the result of applying the URL parser to specifier with script's base URL as the base URL. 102 103 URL completedURL; 104 103 URL baseURL; 105 104 if (isRootModule(importerModuleKey)) 106 completedURL = m_document.completeURL(specifier); 107 else if (importerModuleKey.isString()) { 105 baseURL = m_document.baseURL(); 106 else { 107 ASSERT(importerModuleKey.isString()); 108 108 URL importerModuleRequestURL(URL(), asString(importerModuleKey)->value(exec)); 109 if (!importerModuleRequestURL.isValid()) { 110 promise->reject(TypeError, ASCIILiteral("Importer module key is an invalid URL.")); 111 return jsPromise.promise(); 112 } 113 114 URL importerModuleResponseURL = m_requestURLToResponseURLMap.get(importerModuleRequestURL); 115 if (!importerModuleResponseURL.isValid()) { 116 promise->reject(TypeError, ASCIILiteral("Importer module has an invalid response URL.")); 117 return jsPromise.promise(); 118 } 119 120 completedURL = m_document.completeURL(specifier, importerModuleResponseURL); 121 } else { 122 promise->reject(TypeError, ASCIILiteral("Importer module key is not Symbol or String.")); 123 return jsPromise.promise(); 124 } 125 126 if (!completedURL.isValid()) { 127 promise->reject(TypeError, ASCIILiteral("Module name constructs an invalid URL.")); 128 return jsPromise.promise(); 129 } 130 131 promise->resolve<IDLDOMString>(completedURL.string()); 109 ASSERT_WITH_MESSAGE(importerModuleRequestURL.isValid(), "Invalid module referrer never starts importing dependent modules."); 110 111 auto iterator = m_requestURLToResponseURLMap.find(importerModuleRequestURL); 112 ASSERT_WITH_MESSAGE(iterator != m_requestURLToResponseURLMap.end(), "Module referrer must register itself to the map before starting importing dependent modules."); 113 baseURL = iterator->value; 114 } 115 116 auto result = resolveModuleSpecifier(m_document, specifier, baseURL); 117 if (!result) { 118 promise->reject(TypeError, result.error()); 119 return jsPromise.promise(); 120 } 121 122 promise->resolve<IDLDOMString>(result->string()); 132 123 return jsPromise.promise(); 133 124 } … … 200 191 } 201 192 193 static JSC::JSInternalPromise* rejectPromise(JSC::ExecState& state, JSDOMGlobalObject& globalObject, ExceptionCode ec, ASCIILiteral message) 194 { 195 auto& jsPromise = *JSC::JSInternalPromiseDeferred::create(&state, &globalObject); 196 auto deferred = DeferredPromise::create(globalObject, jsPromise); 197 deferred->reject(ec, WTFMove(message)); 198 return jsPromise.promise(); 199 } 200 201 JSC::JSInternalPromise* ScriptModuleLoader::importModule(JSC::JSGlobalObject* jsGlobalObject, JSC::ExecState* exec, JSC::JSModuleLoader*, JSC::JSString* moduleName, const JSC::SourceOrigin& sourceOrigin) 202 { 203 auto& state = *exec; 204 JSC::VM& vm = exec->vm(); 205 auto& globalObject = *JSC::jsCast<JSDOMGlobalObject*>(jsGlobalObject); 206 207 // FIXME: setTimeout and setInterval with "string()" should propagate SourceOrigin. 208 // https://webkit.org/b/167097 209 ASSERT_WITH_MESSAGE(!sourceOrigin.isNull(), "If SourceOrigin is null, this function is not invoked."); 210 if (!sourceOrigin.fetcher()) 211 return rejectPromise(state, globalObject, TypeError, ASCIILiteral("Could not use import operator in this context.")); 212 213 URL baseURL(URL(), sourceOrigin.string()); 214 if (!baseURL.isValid()) 215 return rejectPromise(state, globalObject, TypeError, ASCIILiteral("Importer module key is not Symbol or String.")); 216 217 auto specifier = moduleName->value(exec); 218 auto result = resolveModuleSpecifier(m_document, specifier, baseURL); 219 if (!result) 220 return rejectPromise(state, globalObject, TypeError, result.error()); 221 222 return JSC::importModule(exec, JSC::Identifier::fromString(&vm, result->string()), JSC::JSScriptFetcher::create(vm, sourceOrigin.fetcher() )); 223 } 224 202 225 void ScriptModuleLoader::notifyFinished(CachedModuleScriptLoader& loader, RefPtr<DeferredPromise> promise) 203 226 { -
trunk/Source/WebCore/bindings/js/ScriptModuleLoader.h
r210585 r211280 39 39 class JSInternalPromise; 40 40 class JSModuleLoader; 41 class SourceOrigin; 41 42 42 43 } … … 58 59 JSC::JSInternalPromise* fetch(JSC::JSGlobalObject*, JSC::ExecState*, JSC::JSModuleLoader*, JSC::JSValue moduleKey, JSC::JSValue scriptFetcher); 59 60 JSC::JSValue evaluate(JSC::JSGlobalObject*, JSC::ExecState*, JSC::JSModuleLoader*, JSC::JSValue moduleKey, JSC::JSValue moduleRecord, JSC::JSValue scriptFetcher); 61 JSC::JSInternalPromise* importModule(JSC::JSGlobalObject*, JSC::ExecState*, JSC::JSModuleLoader*, JSC::JSString*, const JSC::SourceOrigin&); 60 62 61 63 private: -
trunk/Source/WebCore/dom/InlineClassicScript.h
r210627 r211280 26 26 #pragma once 27 27 28 #include " CachedScriptFetcher.h"28 #include "ScriptElementCachedScriptFetcher.h" 29 29 30 30 namespace WebCore { … … 32 32 class ScriptElement; 33 33 34 class InlineClassicScript final : public CachedScriptFetcher {34 class InlineClassicScript final : public ScriptElementCachedScriptFetcher { 35 35 public: 36 36 static Ref<InlineClassicScript> create(ScriptElement&); 37 37 38 bool isClassicScript() const final { return true; } 39 bool isModuleScript() const final { return false; } 40 38 41 private: 39 42 InlineClassicScript(const String& nonce, const String& crossOriginMode, const String& charset, const AtomicString& initiatorName, bool isInUserAgentShadowTree) 40 : CachedScriptFetcher(nonce, crossOriginMode, charset, initiatorName, isInUserAgentShadowTree)43 : ScriptElementCachedScriptFetcher(nonce, crossOriginMode, charset, initiatorName, isInUserAgentShadowTree) 41 44 { 42 45 } -
trunk/Source/WebCore/dom/LoadableClassicScript.cpp
r210627 r211280 111 111 { 112 112 ASSERT(!m_cachedScript); 113 m_cachedScript = requestScriptWithCache(document, sourceURL );113 m_cachedScript = requestScriptWithCache(document, sourceURL, crossOriginMode()); 114 114 if (!m_cachedScript) 115 115 return false; -
trunk/Source/WebCore/dom/LoadableClassicScript.h
r210828 r211280 48 48 49 49 CachedScript& cachedScript() { return *m_cachedScript; } 50 50 51 bool isClassicScript() const final { return true; } 52 bool isModuleScript() const final { return false; } 51 53 52 54 void execute(ScriptElement&) final; -
trunk/Source/WebCore/dom/LoadableModuleScript.h
r210585 r211280 44 44 45 45 CachedModuleScript& moduleScript() { return m_moduleScript.get(); } 46 47 bool isClassicScript() const final { return false; } 46 48 bool isModuleScript() const final { return true; } 47 49 -
trunk/Source/WebCore/dom/LoadableScript.h
r210627 r211280 26 26 #pragma once 27 27 28 #include " CachedScriptFetcher.h"28 #include "ScriptElementCachedScriptFetcher.h" 29 29 #include <runtime/ConsoleTypes.h> 30 30 #include <wtf/HashCountedSet.h> … … 37 37 class ScriptElement; 38 38 39 class LoadableScript : public CachedScriptFetcher {39 class LoadableScript : public ScriptElementCachedScriptFetcher { 40 40 public: 41 41 enum class ErrorType { … … 67 67 void removeClient(LoadableScriptClient&); 68 68 69 virtual bool isClassicScript() const { return false; }70 virtual bool isModuleScript() const { return false; }71 72 69 protected: 73 70 LoadableScript(const String& nonce, const String& crossOriginMode, const String& charset, const AtomicString& initiatorName, bool isInUserAgentShadowTree) 74 : CachedScriptFetcher(nonce, crossOriginMode, charset, initiatorName, isInUserAgentShadowTree)71 : ScriptElementCachedScriptFetcher(nonce, crossOriginMode, charset, initiatorName, isInUserAgentShadowTree) 75 72 { 76 73 } -
trunk/Source/WebCore/dom/ScriptElement.h
r211078 r211280 96 96 bool isScriptForEventSupported() const; 97 97 98 CachedResourceHandle<CachedScript> requestScriptWithCache(const URL&, const String& nonceAttribute, const String& crossoriginAttribute);99 100 98 bool requestClassicScript(const String& sourceURL); 101 99 bool requestModuleScript(const TextPosition& scriptStartPosition); -
trunk/Source/WebCore/dom/ScriptElementCachedScriptFetcher.cpp
r211277 r211280 24 24 */ 25 25 26 #pragma once 26 #include "config.h" 27 #include "ScriptElementCachedScriptFetcher.h" 27 28 28 #include "CachedScriptFetcher.h" 29 #include "Element.h" 30 #include "ScriptElement.h" 29 31 30 32 namespace WebCore { 31 33 32 class ScriptElement; 34 CachedResourceHandle<CachedScript> ScriptElementCachedScriptFetcher::requestModuleScript(Document& document, const URL& sourceURL) const 35 { 36 // https://github.com/tc39/proposal-dynamic-import/blob/master/HTML Integration.md 37 // If the fetcher is not module script, credential mode is always "omit". 33 38 34 class InlineClassicScript final : public CachedScriptFetcher { 35 public: 36 static Ref<InlineClassicScript> create(ScriptElement&); 37 38 private: 39 InlineClassicScript(const String& nonce, const String& crossOriginMode, const String& charset, const AtomicString& initiatorName, bool isInUserAgentShadowTree) 40 : CachedScriptFetcher(nonce, crossOriginMode, charset, initiatorName, isInUserAgentShadowTree) 41 { 42 } 43 }; 39 return requestScriptWithCache(document, sourceURL, isClassicScript() ? ASCIILiteral("omit") : m_crossOriginMode); 40 } 44 41 45 42 } -
trunk/Source/WebCore/dom/ScriptElementCachedScriptFetcher.h
r211277 r211280 26 26 #pragma once 27 27 28 #include "CachedResourceHandle.h" 29 #include <runtime/ScriptFetcher.h> 30 #include <wtf/text/WTFString.h> 28 #include "CachedScriptFetcher.h" 31 29 32 30 namespace WebCore { 33 31 34 class CachedScript;35 class Document; 36 class URL;32 class ScriptElementCachedScriptFetcher : public CachedScriptFetcher { 33 public: 34 virtual CachedResourceHandle<CachedScript> requestModuleScript(Document&, const URL& sourceURL) const; 37 35 38 class CachedScriptFetcher : public JSC::ScriptFetcher { 39 public: 40 CachedResourceHandle<CachedScript> requestScriptWithCache(Document&, const URL& sourceURL) const; 36 virtual bool isClassicScript() const = 0; 37 virtual bool isModuleScript() const = 0; 38 39 const String& crossOriginMode() const { return m_crossOriginMode; } 41 40 42 41 protected: 43 CachedScriptFetcher(const String& nonce, const String& crossOriginMode, const String& charset, const AtomicString& initiatorName, bool isInUserAgentShadowTree)44 : m_nonce(nonce)42 ScriptElementCachedScriptFetcher(const String& nonce, const String& crossOriginMode, const String& charset, const AtomicString& initiatorName, bool isInUserAgentShadowTree) 43 : CachedScriptFetcher(nonce, charset, initiatorName, isInUserAgentShadowTree) 45 44 , m_crossOriginMode(crossOriginMode) 46 , m_charset(charset)47 , m_initiatorName(initiatorName)48 , m_isInUserAgentShadowTree(isInUserAgentShadowTree)49 45 { 50 46 } 51 47 52 48 private: 53 String m_nonce;54 49 String m_crossOriginMode; 55 String m_charset;56 AtomicString m_initiatorName;57 bool m_isInUserAgentShadowTree { false };58 50 }; 59 51
Note: See TracChangeset
for help on using the changeset viewer.