0ec651cd8604f25d516f21e3f53737c622176bac
[WebKit-https.git] / LayoutTests / inspector / controller / runtime-controller-import.html
1 <!doctype html>
2 <html>
3 <head>
4 <script src="../../http/tests/inspector/resources/inspector-test.js"></script>
5 <script>
6
7 function test()
8 {
9     let suite = InspectorTest.createAsyncSuite("RuntimeManager");
10
11     suite.addTestCase({
12         name: "RuntimeManager.prototype.evaluateInInspectedWindow.ImportFromConsole",
13         description: "Test evaluating an import expression from console.",
14         test(resolve, reject) {
15             function testSource(expression, count) {
16                 let promise = WebInspector.logManager.awaitEvent(WebInspector.LogManager.Event.MessageAdded);
17                 return new Promise((resolve, reject) => {
18                     WebInspector.runtimeManager.evaluateInInspectedWindow(expression, {objectGroup: "test"}, (result, wasThrown) => {
19                         promise.then(() => {
20                             InspectorTest.log("Source: " + expression);
21                             InspectorTest.expectThat(result.isUndefined(), "Transformed. Should log the value or an exception.");
22                             resolve();
23                         });
24                     });
25                 })
26             }
27
28             testSource("await import('')", 0)
29             .then(() => {
30                 return testSource("await import('./not-found.js')");
31             })
32             .then(() => {
33                 testSource("await import('./resources/cocoa.js').then((cocoa) => { console.log(`${cocoa.name} is ${cocoa.taste}.`); })");
34             })
35             .then(() => {
36                 testSource("await import('./resources/drink.js').then((ns) => { console.log(`${ns.Cocoa.name} is ${ns.Cocoa.taste}. ${ns.Cappuccino.name} is ${ns.Cappuccino.taste}.`); })");
37             })
38             .then(resolve);
39         }
40     });
41
42     suite.runTestCasesAndFinish();
43 }
44 </script>
45 </head>
46 <body onload="runTest()">
47 <p>Tests for RuntimeManager operations.</p>
48 </body>
49 </html>