Implement dynamic-import for WebCore
[WebKit-https.git] / LayoutTests / js / dom / modules / module-inline-dynamic.html
1 <!DOCTYPE HTML>
2 <html>
3 <head>
4 <script src="../../../resources/js-test-pre.js"></script>
5 </head>
6 <body>
7 <script>
8 description('Test inlined module.');
9
10 // Module will be executed asynchronously.
11 window.jsTestIsAsync = true;
12 </script>
13 <script src="../../../resources/js-test-post.js"></script>
14 <script>
15 debug('Module is not executed yet.');
16 (function () {
17     var element = document.createElement("script");
18     element.textContent = `
19         import Cocoa from "./resources/module-inline-dynamic.js";
20         var cocoa = new Cocoa();
21
22         debug("Module execution is confined in the module environment.");
23         shouldBeEqualToString("typeof cocoa", "undefined");
24
25         window.exportedCocoa = cocoa;
26         shouldBeEqualToString("typeof exportedCocoa", "object");
27         shouldBeEqualToString("exportedCocoa.taste()", "awesome");
28         finishJSTest();
29     `;
30     element.type = "module";
31     document.body.appendChild(element);
32 } ());
33 </script>
34 </body>
35 </html>