michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: function test() michael@0: { michael@0: waitForExplicitFinish(); michael@0: michael@0: let doc; michael@0: let iframeNode, iframeBodyNode; michael@0: let inspector; michael@0: michael@0: let iframeSrc = "" + michael@0: ""; michael@0: let docSrc = "" + michael@0: "" + michael@0: "" + michael@0: ""; michael@0: michael@0: gBrowser.selectedTab = gBrowser.addTab(); michael@0: gBrowser.selectedBrowser.addEventListener("load", function onload() { michael@0: gBrowser.selectedBrowser.removeEventListener("load", onload, true); michael@0: doc = content.document; michael@0: waitForFocus(setupTest, content); michael@0: }, true); michael@0: michael@0: content.location = "data:text/html," + docSrc; michael@0: michael@0: function setupTest() michael@0: { michael@0: iframeNode = doc.querySelector("iframe"); michael@0: iframeBodyNode = iframeNode.contentDocument.querySelector("body"); michael@0: ok(iframeNode, "we have the iframe node"); michael@0: ok(iframeBodyNode, "we have the body node"); michael@0: openInspector(aInspector => { michael@0: inspector = aInspector; michael@0: // Make sure the highlighter is shown so we can disable transitions michael@0: inspector.toolbox.highlighter.showBoxModel(getNodeFront(doc.body)).then(() => { michael@0: runTests(); michael@0: }); michael@0: }); michael@0: } michael@0: michael@0: function runTests() michael@0: { michael@0: inspector.toolbox.highlighterUtils.startPicker().then(() => { michael@0: moveMouseOver(iframeNode, 1, 1, isTheIframeHighlighted); michael@0: }); michael@0: } michael@0: michael@0: function isTheIframeHighlighted() michael@0: { michael@0: let {p1, p2, p3, p4} = getBoxModelStatus().border.points; michael@0: let {top, right, bottom, left} = iframeNode.getBoundingClientRect(); michael@0: michael@0: is(top, p1.y, "iframeRect.top === boxModelStatus.p1.y"); michael@0: is(top, p2.y, "iframeRect.top === boxModelStatus.p2.y"); michael@0: is(right, p2.x, "iframeRect.right === boxModelStatus.p2.x"); michael@0: is(right, p3.x, "iframeRect.right === boxModelStatus.p3.x"); michael@0: is(bottom, p3.y, "iframeRect.bottom === boxModelStatus.p3.y"); michael@0: is(bottom, p4.y, "iframeRect.bottom === boxModelStatus.p4.y"); michael@0: is(left, p1.x, "iframeRect.left === boxModelStatus.p1.x"); michael@0: is(left, p4.x, "iframeRect.left === boxModelStatus.p4.x"); michael@0: michael@0: iframeNode.style.marginBottom = doc.defaultView.innerHeight + "px"; michael@0: doc.defaultView.scrollBy(0, 40); michael@0: michael@0: moveMouseOver(iframeNode, 40, 40, isTheIframeContentHighlighted); michael@0: } michael@0: michael@0: function isTheIframeContentHighlighted() michael@0: { michael@0: is(getHighlitNode(), iframeBodyNode, "highlighter shows the right node"); michael@0: michael@0: let outlineRect = getSimpleBorderRect(); michael@0: is(outlineRect.height, 200, "highlighter height"); michael@0: michael@0: inspector.toolbox.highlighterUtils.stopPicker().then(() => { michael@0: let target = TargetFactory.forTab(gBrowser.selectedTab); michael@0: gDevTools.closeToolbox(target); michael@0: finishUp(); michael@0: }); michael@0: } michael@0: michael@0: function finishUp() michael@0: { michael@0: doc = inspector = iframeNode = iframeBodyNode = null; michael@0: gBrowser.removeCurrentTab(); michael@0: finish(); michael@0: } michael@0: michael@0: function moveMouseOver(aElement, x, y, cb) michael@0: { michael@0: inspector.toolbox.once("picker-node-hovered", cb); michael@0: EventUtils.synthesizeMouse(aElement, x, y, {type: "mousemove"}, michael@0: aElement.ownerDocument.defaultView); michael@0: } michael@0: }