Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: Javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* vim: set ts=2 et sw=2 tw=80: */ |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | let doc; |
michael@0 | 7 | let salutation; |
michael@0 | 8 | let closing; |
michael@0 | 9 | |
michael@0 | 10 | const NEWHEIGHT = 226; |
michael@0 | 11 | |
michael@0 | 12 | function createDocument() |
michael@0 | 13 | { |
michael@0 | 14 | doc.body.innerHTML = '<div id="first" style="{ margin: 10em; ' + |
michael@0 | 15 | 'font-size: 14pt; font-family: helvetica, sans-serif; color: #AAA}">\n' + |
michael@0 | 16 | '<h1>Some header text</h1>\n' + |
michael@0 | 17 | '<p id="salutation" style="{font-size: 12pt}">hi.</p>\n' + |
michael@0 | 18 | '<p id="body" style="{font-size: 12pt}">I am a test-case. This text exists ' + |
michael@0 | 19 | 'solely to provide some things to test the inspector initialization.</p>\n' + |
michael@0 | 20 | 'If you are reading this, you should go do something else instead. Maybe ' + |
michael@0 | 21 | 'read a book. Or better yet, write some test-cases for another bit of code. ' + |
michael@0 | 22 | '<span style="{font-style: italic}">Maybe more inspector test-cases!</span></p>\n' + |
michael@0 | 23 | '<p id="closing">end transmission</p>\n' + |
michael@0 | 24 | '</div>'; |
michael@0 | 25 | doc.title = "Inspector Initialization Test"; |
michael@0 | 26 | startInspectorTests(); |
michael@0 | 27 | } |
michael@0 | 28 | |
michael@0 | 29 | function startInspectorTests() |
michael@0 | 30 | { |
michael@0 | 31 | ok(InspectorUI, "InspectorUI variable exists"); |
michael@0 | 32 | Services.obs.addObserver(runInspectorTests, |
michael@0 | 33 | InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED, false); |
michael@0 | 34 | InspectorUI.toggleInspectorUI(); |
michael@0 | 35 | } |
michael@0 | 36 | |
michael@0 | 37 | function runInspectorTests() |
michael@0 | 38 | { |
michael@0 | 39 | Services.obs.removeObserver(runInspectorTests, |
michael@0 | 40 | InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED); |
michael@0 | 41 | |
michael@0 | 42 | if (InspectorUI.treePanelEnabled) { |
michael@0 | 43 | Services.obs.addObserver(treePanelTests, |
michael@0 | 44 | InspectorUI.INSPECTOR_NOTIFICATIONS.TREEPANELREADY, false); |
michael@0 | 45 | |
michael@0 | 46 | InspectorUI.stopInspecting(); |
michael@0 | 47 | |
michael@0 | 48 | InspectorUI.treePanel.open(); |
michael@0 | 49 | } else |
michael@0 | 50 | finishInspectorTests(); |
michael@0 | 51 | } |
michael@0 | 52 | |
michael@0 | 53 | function treePanelTests() |
michael@0 | 54 | { |
michael@0 | 55 | Services.obs.removeObserver(treePanelTests, |
michael@0 | 56 | InspectorUI.INSPECTOR_NOTIFICATIONS.TREEPANELREADY); |
michael@0 | 57 | Services.obs.addObserver(treePanelTests2, |
michael@0 | 58 | InspectorUI.INSPECTOR_NOTIFICATIONS.TREEPANELREADY, false); |
michael@0 | 59 | |
michael@0 | 60 | ok(InspectorUI.treePanel.isOpen(), "Inspector Tree Panel is open"); |
michael@0 | 61 | |
michael@0 | 62 | let height = Services.prefs.getIntPref("devtools.inspector.htmlHeight"); |
michael@0 | 63 | |
michael@0 | 64 | is(InspectorUI.treePanel.container.height, height, |
michael@0 | 65 | "Container height is " + height); |
michael@0 | 66 | |
michael@0 | 67 | InspectorUI.treePanel.container.height = NEWHEIGHT; |
michael@0 | 68 | |
michael@0 | 69 | executeSoon(function() { |
michael@0 | 70 | InspectorUI.treePanel.close(); |
michael@0 | 71 | InspectorUI.treePanel.open(); |
michael@0 | 72 | }); |
michael@0 | 73 | } |
michael@0 | 74 | |
michael@0 | 75 | function treePanelTests2() |
michael@0 | 76 | { |
michael@0 | 77 | Services.obs.removeObserver(treePanelTests2, |
michael@0 | 78 | InspectorUI.INSPECTOR_NOTIFICATIONS.TREEPANELREADY); |
michael@0 | 79 | |
michael@0 | 80 | ok(InspectorUI.treePanel.isOpen(), "Inspector Tree Panel is open"); |
michael@0 | 81 | |
michael@0 | 82 | let height = Services.prefs.getIntPref("devtools.inspector.htmlHeight"); |
michael@0 | 83 | |
michael@0 | 84 | is(InspectorUI.treePanel.container.height, NEWHEIGHT, |
michael@0 | 85 | "Container height is now " + height); |
michael@0 | 86 | |
michael@0 | 87 | InspectorUI.treePanel.close(); |
michael@0 | 88 | executeSoon(function() { |
michael@0 | 89 | finishInspectorTests() |
michael@0 | 90 | }); |
michael@0 | 91 | } |
michael@0 | 92 | |
michael@0 | 93 | function finishInspectorTests() |
michael@0 | 94 | { |
michael@0 | 95 | gBrowser.removeCurrentTab(); |
michael@0 | 96 | finish(); |
michael@0 | 97 | } |
michael@0 | 98 | |
michael@0 | 99 | function test() |
michael@0 | 100 | { |
michael@0 | 101 | waitForExplicitFinish(); |
michael@0 | 102 | gBrowser.selectedTab = gBrowser.addTab(); |
michael@0 | 103 | gBrowser.selectedBrowser.addEventListener("load", function() { |
michael@0 | 104 | gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); |
michael@0 | 105 | doc = content.document; |
michael@0 | 106 | waitForFocus(createDocument, content); |
michael@0 | 107 | }, true); |
michael@0 | 108 | |
michael@0 | 109 | content.location = "data:text/html;charset=utf-8,browser_inspector_tree_height.js"; |
michael@0 | 110 | } |
michael@0 | 111 |