blob: 06f7f9607a0bed2328736f98c203697edd490690 [file] [log] [blame]
drousso@apple.com73006212019-10-24 06:54:49 +00001<!DOCTYPE html>
2<html>
3<head>
4<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
5<script>
6function addSubframe() {
7 let iframe = document.body.appendChild(document.createElement("iframe"));
8 iframe.src = "resources/bootstrap-iframe.html";
9}
10
11function test()
12{
13 let suite = InspectorTest.createAsyncSuite("Page.setBootstrapScript");
14
15 suite.addTestCase({
16 name: "Page.setBootstrapScript.SubFrame",
17 description: "Test that the bootstrap script is executed in all sub frames.",
18 async test() {
19 InspectorTest.log("Setting bootstrap script...");
20 await WI.networkManager.createBootstrapScript();
21 WI.networkManager.bootstrapScriptEnabled = true;
22 WI.networkManager.bootstrapScript.currentRevision.updateRevisionContent(`window.valueFromBootstrapScript = 42;`);
23
24 InspectorTest.log("Adding subframe...");
25 let [frameWasAddedEvent] = await Promise.all([
26 WI.networkManager.awaitEvent(WI.NetworkManager.Event.FrameWasAdded),
27 InspectorTest.evaluateInPage(`addSubframe()`),
28 ]);
29
30 let {frame} = frameWasAddedEvent.data;
31
32 await frame.awaitEvent(WI.Frame.Event.PageExecutionContextChanged);
33
34 let {result} = await RuntimeAgent.evaluate.invoke({
35 expression: `window.valueFromBootstrapScript`,
36 contextId: frame.pageExecutionContext.id,
37 returnByValue: true,
38 });
39 InspectorTest.expectEqual(result.value, 42, "'valueFromBootstrapScript' should be '42'.");
40 },
41 });
42
43 suite.runTestCasesAndFinish();
44}
45</script>
46</head>
47<body onload="runTest()">
48<p>Tests for Page.setBootstrapScript command.</p>
49</body>
50</html>