browser/devtools/inspector/test/browser_inspector_bug_674871.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial