1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/inspector/test/browser_inspector_scrolling.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,77 @@ 1.4 +/* -*- Mode: Javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim: set ts=2 et sw=2 tw=80: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +let doc; 1.11 +let div; 1.12 +let iframe; 1.13 +let inspector; 1.14 + 1.15 +function createDocument() 1.16 +{ 1.17 + doc.title = "Inspector scrolling Tests"; 1.18 + 1.19 + iframe = doc.createElement("iframe"); 1.20 + 1.21 + iframe.addEventListener("load", function () { 1.22 + iframe.removeEventListener("load", arguments.callee, false); 1.23 + 1.24 + div = iframe.contentDocument.createElement("div"); 1.25 + div.textContent = "big div"; 1.26 + div.setAttribute("style", "height:500px; width:500px; border:1px solid gray;"); 1.27 + iframe.contentDocument.body.appendChild(div); 1.28 + openInspector(inspectNode); 1.29 + }, false); 1.30 + 1.31 + iframe.src = "data:text/html,foo bar"; 1.32 + doc.body.appendChild(iframe); 1.33 +} 1.34 + 1.35 +function inspectNode(aInspector) 1.36 +{ 1.37 + inspector = aInspector; 1.38 + 1.39 + let highlighter = inspector.toolbox.highlighter; 1.40 + highlighter.showBoxModel(getNodeFront(div)).then(performScrollingTest); 1.41 +} 1.42 + 1.43 +function performScrollingTest() 1.44 +{ 1.45 + gBrowser.selectedBrowser.addEventListener("scroll", function() { 1.46 + gBrowser.selectedBrowser.removeEventListener("scroll", arguments.callee, 1.47 + false); 1.48 + let isRetina = devicePixelRatio === 2; 1.49 + is(iframe.contentDocument.body.scrollTop, 1.50 + isRetina ? 25 : 50, "inspected iframe scrolled"); 1.51 + 1.52 + finishUp(); 1.53 + }, false); 1.54 + 1.55 + EventUtils.synthesizeWheel(div, 10, 10, 1.56 + { deltaY: 50.0, deltaMode: WheelEvent.DOM_DELTA_PIXEL }, 1.57 + iframe.contentWindow); 1.58 +} 1.59 + 1.60 +function finishUp() 1.61 +{ 1.62 + inspector = div = iframe = doc = null; 1.63 + let target = TargetFactory.forTab(gBrowser.selectedTab); 1.64 + gDevTools.closeToolbox(target); 1.65 + gBrowser.removeCurrentTab(); 1.66 + finish(); 1.67 +} 1.68 + 1.69 +function test() 1.70 +{ 1.71 + waitForExplicitFinish(); 1.72 + gBrowser.selectedTab = gBrowser.addTab(); 1.73 + gBrowser.selectedBrowser.addEventListener("load", function() { 1.74 + gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); 1.75 + doc = content.document; 1.76 + waitForFocus(createDocument, content); 1.77 + }, true); 1.78 + 1.79 + content.location = "data:text/html,mouse scrolling test for inspector"; 1.80 +}