browser/devtools/inspector/test/browser_inspector_scrolling.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 /* -*- 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/. */
     7 let doc;
     8 let div;
     9 let iframe;
    10 let inspector;
    12 function createDocument()
    13 {
    14   doc.title = "Inspector scrolling Tests";
    16   iframe = doc.createElement("iframe");
    18   iframe.addEventListener("load", function () {
    19     iframe.removeEventListener("load", arguments.callee, false);
    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);
    28   iframe.src = "data:text/html,foo bar";
    29   doc.body.appendChild(iframe);
    30 }
    32 function inspectNode(aInspector)
    33 {
    34   inspector = aInspector;
    36   let highlighter = inspector.toolbox.highlighter;
    37   highlighter.showBoxModel(getNodeFront(div)).then(performScrollingTest);
    38 }
    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");
    49     finishUp();
    50   }, false);
    52   EventUtils.synthesizeWheel(div, 10, 10,
    53     { deltaY: 50.0, deltaMode: WheelEvent.DOM_DELTA_PIXEL },
    54     iframe.contentWindow);
    55 }
    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 }
    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);
    76   content.location = "data:text/html,mouse scrolling test for inspector";
    77 }

mercurial