|
1 /* -*- Mode: Javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* vim: set ts=2 et sw=2 tw=80: */ |
|
3 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
4 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
6 |
|
7 let doc; |
|
8 let div; |
|
9 let iframe; |
|
10 let inspector; |
|
11 |
|
12 function createDocument() |
|
13 { |
|
14 doc.title = "Inspector scrolling Tests"; |
|
15 |
|
16 iframe = doc.createElement("iframe"); |
|
17 |
|
18 iframe.addEventListener("load", function () { |
|
19 iframe.removeEventListener("load", arguments.callee, false); |
|
20 |
|
21 div = iframe.contentDocument.createElement("div"); |
|
22 div.textContent = "big div"; |
|
23 div.setAttribute("style", "height:500px; width:500px; border:1px solid gray;"); |
|
24 iframe.contentDocument.body.appendChild(div); |
|
25 openInspector(inspectNode); |
|
26 }, false); |
|
27 |
|
28 iframe.src = "data:text/html,foo bar"; |
|
29 doc.body.appendChild(iframe); |
|
30 } |
|
31 |
|
32 function inspectNode(aInspector) |
|
33 { |
|
34 inspector = aInspector; |
|
35 |
|
36 let highlighter = inspector.toolbox.highlighter; |
|
37 highlighter.showBoxModel(getNodeFront(div)).then(performScrollingTest); |
|
38 } |
|
39 |
|
40 function performScrollingTest() |
|
41 { |
|
42 gBrowser.selectedBrowser.addEventListener("scroll", function() { |
|
43 gBrowser.selectedBrowser.removeEventListener("scroll", arguments.callee, |
|
44 false); |
|
45 let isRetina = devicePixelRatio === 2; |
|
46 is(iframe.contentDocument.body.scrollTop, |
|
47 isRetina ? 25 : 50, "inspected iframe scrolled"); |
|
48 |
|
49 finishUp(); |
|
50 }, false); |
|
51 |
|
52 EventUtils.synthesizeWheel(div, 10, 10, |
|
53 { deltaY: 50.0, deltaMode: WheelEvent.DOM_DELTA_PIXEL }, |
|
54 iframe.contentWindow); |
|
55 } |
|
56 |
|
57 function finishUp() |
|
58 { |
|
59 inspector = div = iframe = doc = null; |
|
60 let target = TargetFactory.forTab(gBrowser.selectedTab); |
|
61 gDevTools.closeToolbox(target); |
|
62 gBrowser.removeCurrentTab(); |
|
63 finish(); |
|
64 } |
|
65 |
|
66 function test() |
|
67 { |
|
68 waitForExplicitFinish(); |
|
69 gBrowser.selectedTab = gBrowser.addTab(); |
|
70 gBrowser.selectedBrowser.addEventListener("load", function() { |
|
71 gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); |
|
72 doc = content.document; |
|
73 waitForFocus(createDocument, content); |
|
74 }, true); |
|
75 |
|
76 content.location = "data:text/html,mouse scrolling test for inspector"; |
|
77 } |