1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/inspector/test/browser_inspector_tree_height.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,111 @@ 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 +let doc; 1.10 +let salutation; 1.11 +let closing; 1.12 + 1.13 +const NEWHEIGHT = 226; 1.14 + 1.15 +function createDocument() 1.16 +{ 1.17 + doc.body.innerHTML = '<div id="first" style="{ margin: 10em; ' + 1.18 + 'font-size: 14pt; font-family: helvetica, sans-serif; color: #AAA}">\n' + 1.19 + '<h1>Some header text</h1>\n' + 1.20 + '<p id="salutation" style="{font-size: 12pt}">hi.</p>\n' + 1.21 + '<p id="body" style="{font-size: 12pt}">I am a test-case. This text exists ' + 1.22 + 'solely to provide some things to test the inspector initialization.</p>\n' + 1.23 + 'If you are reading this, you should go do something else instead. Maybe ' + 1.24 + 'read a book. Or better yet, write some test-cases for another bit of code. ' + 1.25 + '<span style="{font-style: italic}">Maybe more inspector test-cases!</span></p>\n' + 1.26 + '<p id="closing">end transmission</p>\n' + 1.27 + '</div>'; 1.28 + doc.title = "Inspector Initialization Test"; 1.29 + startInspectorTests(); 1.30 +} 1.31 + 1.32 +function startInspectorTests() 1.33 +{ 1.34 + ok(InspectorUI, "InspectorUI variable exists"); 1.35 + Services.obs.addObserver(runInspectorTests, 1.36 + InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED, false); 1.37 + InspectorUI.toggleInspectorUI(); 1.38 +} 1.39 + 1.40 +function runInspectorTests() 1.41 +{ 1.42 + Services.obs.removeObserver(runInspectorTests, 1.43 + InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED); 1.44 + 1.45 + if (InspectorUI.treePanelEnabled) { 1.46 + Services.obs.addObserver(treePanelTests, 1.47 + InspectorUI.INSPECTOR_NOTIFICATIONS.TREEPANELREADY, false); 1.48 + 1.49 + InspectorUI.stopInspecting(); 1.50 + 1.51 + InspectorUI.treePanel.open(); 1.52 + } else 1.53 + finishInspectorTests(); 1.54 +} 1.55 + 1.56 +function treePanelTests() 1.57 +{ 1.58 + Services.obs.removeObserver(treePanelTests, 1.59 + InspectorUI.INSPECTOR_NOTIFICATIONS.TREEPANELREADY); 1.60 + Services.obs.addObserver(treePanelTests2, 1.61 + InspectorUI.INSPECTOR_NOTIFICATIONS.TREEPANELREADY, false); 1.62 + 1.63 + ok(InspectorUI.treePanel.isOpen(), "Inspector Tree Panel is open"); 1.64 + 1.65 + let height = Services.prefs.getIntPref("devtools.inspector.htmlHeight"); 1.66 + 1.67 + is(InspectorUI.treePanel.container.height, height, 1.68 + "Container height is " + height); 1.69 + 1.70 + InspectorUI.treePanel.container.height = NEWHEIGHT; 1.71 + 1.72 + executeSoon(function() { 1.73 + InspectorUI.treePanel.close(); 1.74 + InspectorUI.treePanel.open(); 1.75 + }); 1.76 +} 1.77 + 1.78 +function treePanelTests2() 1.79 +{ 1.80 + Services.obs.removeObserver(treePanelTests2, 1.81 + InspectorUI.INSPECTOR_NOTIFICATIONS.TREEPANELREADY); 1.82 + 1.83 + ok(InspectorUI.treePanel.isOpen(), "Inspector Tree Panel is open"); 1.84 + 1.85 + let height = Services.prefs.getIntPref("devtools.inspector.htmlHeight"); 1.86 + 1.87 + is(InspectorUI.treePanel.container.height, NEWHEIGHT, 1.88 + "Container height is now " + height); 1.89 + 1.90 + InspectorUI.treePanel.close(); 1.91 + executeSoon(function() { 1.92 + finishInspectorTests() 1.93 + }); 1.94 +} 1.95 + 1.96 +function finishInspectorTests() 1.97 +{ 1.98 + gBrowser.removeCurrentTab(); 1.99 + finish(); 1.100 +} 1.101 + 1.102 +function test() 1.103 +{ 1.104 + waitForExplicitFinish(); 1.105 + gBrowser.selectedTab = gBrowser.addTab(); 1.106 + gBrowser.selectedBrowser.addEventListener("load", function() { 1.107 + gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); 1.108 + doc = content.document; 1.109 + waitForFocus(createDocument, content); 1.110 + }, true); 1.111 + 1.112 + content.location = "data:text/html;charset=utf-8,browser_inspector_tree_height.js"; 1.113 +} 1.114 +