Web Inspector: CSS Regions: Add layout tests for the new events in the DOMTreeManager
[WebKit-https.git] / LayoutTests / http / tests / inspector-protocol / access-inspected-object.html
1 <html>
2 <head>
3 <script type="text/javascript" src="resources/protocol-test.js"></script>
4 <script>
5 if (window.testRunner) {
6     testRunner.dumpAsText();
7     testRunner.waitUntilDone();
8 }
9
10 function test()
11 {
12     InspectorTest.sendCommand("DOM.getDocument", {}, didGetDocument);
13
14     function didGetDocument(messageObject)
15     {
16         InspectorTest.sendCommand("DOM.querySelector", {
17                 "nodeId": messageObject.result.root.nodeId,
18                 "selector": "iframe#myframe"
19             }, didFindIframe);
20         InspectorTest.eventHandler["DOM.setChildNodes"] = iframeRequestHandler;
21     }
22
23     function didFindIframe(messageObject)
24     {
25         if (messageObject.error) {
26             InspectorTest.log("FAIL: " + messageObject.error);
27             InspectorTest.completeTest();
28         }
29     }
30
31     function iframeRequestHandler(messageObject)
32     {
33         var node = messageObject.params.nodes[0];
34         if (!node || node.nodeName !== "IFRAME")
35             return;
36         InspectorTest.eventHandler["DOM.setChildNodes"] = null;
37         InspectorTest.sendCommand("DOM.querySelector", {
38                 "nodeId": node.contentDocument.nodeId,
39                 "selector": "div#rootDiv"
40             }, didFindDiv);
41     }
42
43     function didFindDiv(messageObject)
44     {
45         InspectorTest.sendCommand("Console.enable", {});
46         InspectorTest.sendCommand("Console.addInspectedNode", {
47                 "nodeId": messageObject.result.nodeId
48             }, didAddInspectedNode);
49     }
50
51     function didAddInspectedNode(messageObject)
52     {
53         InspectorTest.sendCommand("Runtime.evaluate", {
54                 "expression": "$0",
55                 "includeCommandLineAPI": true
56             }, didEvaluate);
57     }
58
59     function didEvaluate(messageObject)
60     {
61         if (messageObject.result.wasThrown)
62             InspectorTest.log("FAIL: unexpected exception: " + JSON.stringify(messageObject, null, 2));
63         if (messageObject.result.result.value !== null)
64             InspectorTest.log("FAIL: unexpected value: " + JSON.stringify(messageObject, null, 2));
65         InspectorTest.completeTest();
66     }
67 }
68
69 </script>
70 </head>
71 <body>
72 <p>Test that code evaluated in the main frame cannot access $0 that resolves into a node in a frame from a different domain. <a href="https://bugs.webkit.org/show_bug.cgi?id=105423">Bug 105423.</p>
73 <iframe id="myframe" src="http://localhost:8000/inspector-protocol/resources/test-page.html" onload="runTest()"></iframe>
74 </body>
75 </html>