File: browser_inspector_bug_674871.js

package info (click to toggle)
iceweasel 31.6.0esr-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 1,368,576 kB
  • sloc: cpp: 3,692,968; ansic: 1,797,194; python: 193,401; java: 180,622; asm: 133,557; xml: 89,288; sh: 71,748; perl: 22,087; makefile: 21,687; objc: 4,014; yacc: 1,995; pascal: 1,292; lex: 950; exp: 449; lisp: 228; awk: 211; php: 113; sed: 43; csh: 31; ada: 16; ruby: 3
file content (112 lines) | stat: -rw-r--r-- 3,576 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

function test()
{
  waitForExplicitFinish();

  let doc;
  let iframeNode, iframeBodyNode;
  let inspector;

  let iframeSrc = "<style>" +
                  "body {" +
                  "margin:0;" +
                  "height:100%;" +
                  "background-color:red" +
                  "}" +
                  "</style>" +
                  "<body></body>";
  let docSrc = "<style>" +
               "iframe {" +
               "height:200px;" +
               "border: 11px solid black;" +
               "padding: 13px;" +
               "}" +
               "body,iframe {" +
               "margin:0" +
               "}" +
               "</style>" +
               "<body>" +
               "<iframe src='data:text/html," + iframeSrc + "'></iframe>" +
               "</body>";

  gBrowser.selectedTab = gBrowser.addTab();
  gBrowser.selectedBrowser.addEventListener("load", function onload() {
    gBrowser.selectedBrowser.removeEventListener("load", onload, true);
    doc = content.document;
    waitForFocus(setupTest, content);
  }, true);

  content.location = "data:text/html," + docSrc;

  function setupTest()
  {
    iframeNode = doc.querySelector("iframe");
    iframeBodyNode = iframeNode.contentDocument.querySelector("body");
    ok(iframeNode, "we have the iframe node");
    ok(iframeBodyNode, "we have the body node");
    openInspector(aInspector => {
      inspector = aInspector;
      // Make sure the highlighter is shown so we can disable transitions
      inspector.toolbox.highlighter.showBoxModel(getNodeFront(doc.body)).then(() => {
        runTests();
      });
    });
  }

  function runTests()
  {
    inspector.toolbox.highlighterUtils.startPicker().then(() => {
      moveMouseOver(iframeNode, 1, 1, isTheIframeHighlighted);
    });
  }

  function isTheIframeHighlighted()
  {
    let {p1, p2, p3, p4} = getBoxModelStatus().border.points;
    let {top, right, bottom, left} = iframeNode.getBoundingClientRect();

    is(top, p1.y, "iframeRect.top === boxModelStatus.p1.y");
    is(top, p2.y, "iframeRect.top === boxModelStatus.p2.y");
    is(right, p2.x, "iframeRect.right === boxModelStatus.p2.x");
    is(right, p3.x, "iframeRect.right === boxModelStatus.p3.x");
    is(bottom, p3.y, "iframeRect.bottom === boxModelStatus.p3.y");
    is(bottom, p4.y, "iframeRect.bottom === boxModelStatus.p4.y");
    is(left, p1.x, "iframeRect.left === boxModelStatus.p1.x");
    is(left, p4.x, "iframeRect.left === boxModelStatus.p4.x");

    iframeNode.style.marginBottom = doc.defaultView.innerHeight + "px";
    doc.defaultView.scrollBy(0, 40);

    moveMouseOver(iframeNode, 40, 40, isTheIframeContentHighlighted);
  }

  function isTheIframeContentHighlighted()
  {
    is(getHighlitNode(), iframeBodyNode, "highlighter shows the right node");

    let outlineRect = getSimpleBorderRect();
    is(outlineRect.height, 200, "highlighter height");

    inspector.toolbox.highlighterUtils.stopPicker().then(() => {
      let target = TargetFactory.forTab(gBrowser.selectedTab);
      gDevTools.closeToolbox(target);
      finishUp();
    });
  }

  function finishUp()
  {
    doc = inspector = iframeNode = iframeBodyNode = null;
    gBrowser.removeCurrentTab();
    finish();
  }

  function moveMouseOver(aElement, x, y, cb)
  {
    inspector.toolbox.once("picker-node-hovered", cb);
    EventUtils.synthesizeMouse(aElement, x, y, {type: "mousemove"},
                               aElement.ownerDocument.defaultView);
  }
}