Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | function test() |
michael@0 | 5 | { |
michael@0 | 6 | waitForExplicitFinish(); |
michael@0 | 7 | |
michael@0 | 8 | let doc; |
michael@0 | 9 | let iframeNode, iframeBodyNode; |
michael@0 | 10 | let inspector; |
michael@0 | 11 | |
michael@0 | 12 | let iframeSrc = "<style>" + |
michael@0 | 13 | "body {" + |
michael@0 | 14 | "margin:0;" + |
michael@0 | 15 | "height:100%;" + |
michael@0 | 16 | "background-color:red" + |
michael@0 | 17 | "}" + |
michael@0 | 18 | "</style>" + |
michael@0 | 19 | "<body></body>"; |
michael@0 | 20 | let docSrc = "<style>" + |
michael@0 | 21 | "iframe {" + |
michael@0 | 22 | "height:200px;" + |
michael@0 | 23 | "border: 11px solid black;" + |
michael@0 | 24 | "padding: 13px;" + |
michael@0 | 25 | "}" + |
michael@0 | 26 | "body,iframe {" + |
michael@0 | 27 | "margin:0" + |
michael@0 | 28 | "}" + |
michael@0 | 29 | "</style>" + |
michael@0 | 30 | "<body>" + |
michael@0 | 31 | "<iframe src='data:text/html," + iframeSrc + "'></iframe>" + |
michael@0 | 32 | "</body>"; |
michael@0 | 33 | |
michael@0 | 34 | gBrowser.selectedTab = gBrowser.addTab(); |
michael@0 | 35 | gBrowser.selectedBrowser.addEventListener("load", function onload() { |
michael@0 | 36 | gBrowser.selectedBrowser.removeEventListener("load", onload, true); |
michael@0 | 37 | doc = content.document; |
michael@0 | 38 | waitForFocus(setupTest, content); |
michael@0 | 39 | }, true); |
michael@0 | 40 | |
michael@0 | 41 | content.location = "data:text/html," + docSrc; |
michael@0 | 42 | |
michael@0 | 43 | function setupTest() |
michael@0 | 44 | { |
michael@0 | 45 | iframeNode = doc.querySelector("iframe"); |
michael@0 | 46 | iframeBodyNode = iframeNode.contentDocument.querySelector("body"); |
michael@0 | 47 | ok(iframeNode, "we have the iframe node"); |
michael@0 | 48 | ok(iframeBodyNode, "we have the body node"); |
michael@0 | 49 | openInspector(aInspector => { |
michael@0 | 50 | inspector = aInspector; |
michael@0 | 51 | // Make sure the highlighter is shown so we can disable transitions |
michael@0 | 52 | inspector.toolbox.highlighter.showBoxModel(getNodeFront(doc.body)).then(() => { |
michael@0 | 53 | runTests(); |
michael@0 | 54 | }); |
michael@0 | 55 | }); |
michael@0 | 56 | } |
michael@0 | 57 | |
michael@0 | 58 | function runTests() |
michael@0 | 59 | { |
michael@0 | 60 | inspector.toolbox.highlighterUtils.startPicker().then(() => { |
michael@0 | 61 | moveMouseOver(iframeNode, 1, 1, isTheIframeHighlighted); |
michael@0 | 62 | }); |
michael@0 | 63 | } |
michael@0 | 64 | |
michael@0 | 65 | function isTheIframeHighlighted() |
michael@0 | 66 | { |
michael@0 | 67 | let {p1, p2, p3, p4} = getBoxModelStatus().border.points; |
michael@0 | 68 | let {top, right, bottom, left} = iframeNode.getBoundingClientRect(); |
michael@0 | 69 | |
michael@0 | 70 | is(top, p1.y, "iframeRect.top === boxModelStatus.p1.y"); |
michael@0 | 71 | is(top, p2.y, "iframeRect.top === boxModelStatus.p2.y"); |
michael@0 | 72 | is(right, p2.x, "iframeRect.right === boxModelStatus.p2.x"); |
michael@0 | 73 | is(right, p3.x, "iframeRect.right === boxModelStatus.p3.x"); |
michael@0 | 74 | is(bottom, p3.y, "iframeRect.bottom === boxModelStatus.p3.y"); |
michael@0 | 75 | is(bottom, p4.y, "iframeRect.bottom === boxModelStatus.p4.y"); |
michael@0 | 76 | is(left, p1.x, "iframeRect.left === boxModelStatus.p1.x"); |
michael@0 | 77 | is(left, p4.x, "iframeRect.left === boxModelStatus.p4.x"); |
michael@0 | 78 | |
michael@0 | 79 | iframeNode.style.marginBottom = doc.defaultView.innerHeight + "px"; |
michael@0 | 80 | doc.defaultView.scrollBy(0, 40); |
michael@0 | 81 | |
michael@0 | 82 | moveMouseOver(iframeNode, 40, 40, isTheIframeContentHighlighted); |
michael@0 | 83 | } |
michael@0 | 84 | |
michael@0 | 85 | function isTheIframeContentHighlighted() |
michael@0 | 86 | { |
michael@0 | 87 | is(getHighlitNode(), iframeBodyNode, "highlighter shows the right node"); |
michael@0 | 88 | |
michael@0 | 89 | let outlineRect = getSimpleBorderRect(); |
michael@0 | 90 | is(outlineRect.height, 200, "highlighter height"); |
michael@0 | 91 | |
michael@0 | 92 | inspector.toolbox.highlighterUtils.stopPicker().then(() => { |
michael@0 | 93 | let target = TargetFactory.forTab(gBrowser.selectedTab); |
michael@0 | 94 | gDevTools.closeToolbox(target); |
michael@0 | 95 | finishUp(); |
michael@0 | 96 | }); |
michael@0 | 97 | } |
michael@0 | 98 | |
michael@0 | 99 | function finishUp() |
michael@0 | 100 | { |
michael@0 | 101 | doc = inspector = iframeNode = iframeBodyNode = null; |
michael@0 | 102 | gBrowser.removeCurrentTab(); |
michael@0 | 103 | finish(); |
michael@0 | 104 | } |
michael@0 | 105 | |
michael@0 | 106 | function moveMouseOver(aElement, x, y, cb) |
michael@0 | 107 | { |
michael@0 | 108 | inspector.toolbox.once("picker-node-hovered", cb); |
michael@0 | 109 | EventUtils.synthesizeMouse(aElement, x, y, {type: "mousemove"}, |
michael@0 | 110 | aElement.ownerDocument.defaultView); |
michael@0 | 111 | } |
michael@0 | 112 | } |