| <!doctype html> |
| <html> |
| <head> |
| <script src="../../http/tests/inspector/resources/inspector-test.js"></script> |
| <script> |
| function test() |
| { |
| let suite = InspectorTest.createAsyncSuite("DOM.highlightFrame"); |
| |
| let mainFrame = WI.frameResourceManager.mainFrame; |
| let childFrames = mainFrame.childFrameCollection.toArray(); |
| InspectorTest.expectEqual(childFrames.length, 2, "Page should have subframes."); |
| |
| function getHighlight(callback) { |
| InspectorTest.evaluateInPage("window.internals.inspectorHighlightObject()", (error, value, wasThrown) => { |
| InspectorTest.assert(!error, "Unexpected error dumping highlight: " + error); |
| InspectorTest.assert(!wasThrown, "Unexpected exception when dumping highlight."); |
| callback(JSON.parse(value)); |
| }); |
| } |
| |
| function dumpHighlight(callback) { |
| getHighlight((highlightObjectPayload) => { |
| InspectorTest.log("Highlight Object: " + JSON.stringify(highlightObjectPayload)); |
| callback(); |
| }); |
| } |
| |
| suite.addTestCase({ |
| name: "CheckEmptyHighlight", |
| description: "Should not be a highlight yet.", |
| test(resolve, reject) { |
| getHighlight((highlightObjectPayload) => { |
| InspectorTest.expectThat(highlightObjectPayload.length === 0, "Should not be a highlight yet."); |
| resolve(); |
| }); |
| } |
| }); |
| |
| suite.addTestCase({ |
| name: "HighlightMainFrame", |
| description: "Main frame does not have an owner element, so there will be no highlight.", |
| test(resolve, reject) { |
| DOMAgent.highlightFrame(mainFrame.id, undefined, undefined, (error) => { |
| getHighlight((highlightObjectPayload) => { |
| InspectorTest.expectThat(highlightObjectPayload.length === 0, "Should not be a highlight for the main frame."); |
| resolve(); |
| }); |
| }); |
| } |
| }); |
| |
| suite.addTestCase({ |
| name: "HighlightChildFrame1", |
| description: "Should highlight child frame 1.", |
| test(resolve, reject) { |
| DOMAgent.highlightFrame(childFrames[0].id, undefined, undefined, (error) => { |
| InspectorTest.assert(!error, "Should not have an error."); |
| dumpHighlight(resolve); |
| }); |
| } |
| }); |
| |
| suite.addTestCase({ |
| name: "HighlightChildFrame2", |
| description: "Should highlight child frame 2.", |
| test(resolve, reject) { |
| DOMAgent.highlightFrame(childFrames[1].id, undefined, undefined, (error) => { |
| InspectorTest.assert(!error, "Should not have an error."); |
| dumpHighlight(resolve); |
| }); |
| } |
| }); |
| |
| // ------ |
| |
| suite.addTestCase({ |
| name: "BadFrameId", |
| description: "Bad frame id should cause an error.", |
| test(resolve, reject) { |
| DOMAgent.highlightFrame("bad-frame-id", undefined, undefined, (error) => { |
| InspectorTest.expectThat(error, "Should produce an error."); |
| InspectorTest.log("Error: " + error); |
| resolve(); |
| }); |
| } |
| }); |
| |
| suite.runTestCasesAndFinish(); |
| } |
| </script> |
| </head> |
| <body onload="runTest()"> |
| <p>Tests for the DOM.highlightFrame command.</p> |
| <div> |
| <iframe id="frame-1" src="resources/highlight-iframe.html"></iframe> |
| <iframe id="frame-2" src="resources/highlight-iframe.html"></iframe> |
| </div> |
| </body> |
| </html> |