1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/inspector/test/browser_inspector_bug_674871.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,112 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +function test() 1.8 +{ 1.9 + waitForExplicitFinish(); 1.10 + 1.11 + let doc; 1.12 + let iframeNode, iframeBodyNode; 1.13 + let inspector; 1.14 + 1.15 + let iframeSrc = "<style>" + 1.16 + "body {" + 1.17 + "margin:0;" + 1.18 + "height:100%;" + 1.19 + "background-color:red" + 1.20 + "}" + 1.21 + "</style>" + 1.22 + "<body></body>"; 1.23 + let docSrc = "<style>" + 1.24 + "iframe {" + 1.25 + "height:200px;" + 1.26 + "border: 11px solid black;" + 1.27 + "padding: 13px;" + 1.28 + "}" + 1.29 + "body,iframe {" + 1.30 + "margin:0" + 1.31 + "}" + 1.32 + "</style>" + 1.33 + "<body>" + 1.34 + "<iframe src='data:text/html," + iframeSrc + "'></iframe>" + 1.35 + "</body>"; 1.36 + 1.37 + gBrowser.selectedTab = gBrowser.addTab(); 1.38 + gBrowser.selectedBrowser.addEventListener("load", function onload() { 1.39 + gBrowser.selectedBrowser.removeEventListener("load", onload, true); 1.40 + doc = content.document; 1.41 + waitForFocus(setupTest, content); 1.42 + }, true); 1.43 + 1.44 + content.location = "data:text/html," + docSrc; 1.45 + 1.46 + function setupTest() 1.47 + { 1.48 + iframeNode = doc.querySelector("iframe"); 1.49 + iframeBodyNode = iframeNode.contentDocument.querySelector("body"); 1.50 + ok(iframeNode, "we have the iframe node"); 1.51 + ok(iframeBodyNode, "we have the body node"); 1.52 + openInspector(aInspector => { 1.53 + inspector = aInspector; 1.54 + // Make sure the highlighter is shown so we can disable transitions 1.55 + inspector.toolbox.highlighter.showBoxModel(getNodeFront(doc.body)).then(() => { 1.56 + runTests(); 1.57 + }); 1.58 + }); 1.59 + } 1.60 + 1.61 + function runTests() 1.62 + { 1.63 + inspector.toolbox.highlighterUtils.startPicker().then(() => { 1.64 + moveMouseOver(iframeNode, 1, 1, isTheIframeHighlighted); 1.65 + }); 1.66 + } 1.67 + 1.68 + function isTheIframeHighlighted() 1.69 + { 1.70 + let {p1, p2, p3, p4} = getBoxModelStatus().border.points; 1.71 + let {top, right, bottom, left} = iframeNode.getBoundingClientRect(); 1.72 + 1.73 + is(top, p1.y, "iframeRect.top === boxModelStatus.p1.y"); 1.74 + is(top, p2.y, "iframeRect.top === boxModelStatus.p2.y"); 1.75 + is(right, p2.x, "iframeRect.right === boxModelStatus.p2.x"); 1.76 + is(right, p3.x, "iframeRect.right === boxModelStatus.p3.x"); 1.77 + is(bottom, p3.y, "iframeRect.bottom === boxModelStatus.p3.y"); 1.78 + is(bottom, p4.y, "iframeRect.bottom === boxModelStatus.p4.y"); 1.79 + is(left, p1.x, "iframeRect.left === boxModelStatus.p1.x"); 1.80 + is(left, p4.x, "iframeRect.left === boxModelStatus.p4.x"); 1.81 + 1.82 + iframeNode.style.marginBottom = doc.defaultView.innerHeight + "px"; 1.83 + doc.defaultView.scrollBy(0, 40); 1.84 + 1.85 + moveMouseOver(iframeNode, 40, 40, isTheIframeContentHighlighted); 1.86 + } 1.87 + 1.88 + function isTheIframeContentHighlighted() 1.89 + { 1.90 + is(getHighlitNode(), iframeBodyNode, "highlighter shows the right node"); 1.91 + 1.92 + let outlineRect = getSimpleBorderRect(); 1.93 + is(outlineRect.height, 200, "highlighter height"); 1.94 + 1.95 + inspector.toolbox.highlighterUtils.stopPicker().then(() => { 1.96 + let target = TargetFactory.forTab(gBrowser.selectedTab); 1.97 + gDevTools.closeToolbox(target); 1.98 + finishUp(); 1.99 + }); 1.100 + } 1.101 + 1.102 + function finishUp() 1.103 + { 1.104 + doc = inspector = iframeNode = iframeBodyNode = null; 1.105 + gBrowser.removeCurrentTab(); 1.106 + finish(); 1.107 + } 1.108 + 1.109 + function moveMouseOver(aElement, x, y, cb) 1.110 + { 1.111 + inspector.toolbox.once("picker-node-hovered", cb); 1.112 + EventUtils.synthesizeMouse(aElement, x, y, {type: "mousemove"}, 1.113 + aElement.ownerDocument.defaultView); 1.114 + } 1.115 +}