browser/devtools/inspector/test/browser_inspector_tree_height.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/. */
     6 let doc;
     7 let salutation;
     8 let closing;
    10 const NEWHEIGHT = 226;
    12 function createDocument()
    13 {
    14   doc.body.innerHTML = '<div id="first" style="{ margin: 10em; ' +
    15     'font-size: 14pt; font-family: helvetica, sans-serif; color: #AAA}">\n' +
    16     '<h1>Some header text</h1>\n' +
    17     '<p id="salutation" style="{font-size: 12pt}">hi.</p>\n' +
    18     '<p id="body" style="{font-size: 12pt}">I am a test-case. This text exists ' +
    19     'solely to provide some things to test the inspector initialization.</p>\n' +
    20     'If you are reading this, you should go do something else instead. Maybe ' +
    21     'read a book. Or better yet, write some test-cases for another bit of code. ' +
    22     '<span style="{font-style: italic}">Maybe more inspector test-cases!</span></p>\n' +
    23     '<p id="closing">end transmission</p>\n' +
    24     '</div>';
    25   doc.title = "Inspector Initialization Test";
    26   startInspectorTests();
    27 }
    29 function startInspectorTests()
    30 {
    31   ok(InspectorUI, "InspectorUI variable exists");
    32   Services.obs.addObserver(runInspectorTests,
    33     InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED, false);
    34   InspectorUI.toggleInspectorUI();
    35 }
    37 function runInspectorTests()
    38 {
    39   Services.obs.removeObserver(runInspectorTests,
    40     InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED);
    42   if (InspectorUI.treePanelEnabled) {
    43     Services.obs.addObserver(treePanelTests,
    44       InspectorUI.INSPECTOR_NOTIFICATIONS.TREEPANELREADY, false);
    46     InspectorUI.stopInspecting();
    48     InspectorUI.treePanel.open();
    49   } else
    50     finishInspectorTests();
    51 }
    53 function treePanelTests()
    54 {
    55   Services.obs.removeObserver(treePanelTests,
    56     InspectorUI.INSPECTOR_NOTIFICATIONS.TREEPANELREADY);
    57   Services.obs.addObserver(treePanelTests2,
    58     InspectorUI.INSPECTOR_NOTIFICATIONS.TREEPANELREADY, false);
    60   ok(InspectorUI.treePanel.isOpen(), "Inspector Tree Panel is open");
    62   let height = Services.prefs.getIntPref("devtools.inspector.htmlHeight");
    64   is(InspectorUI.treePanel.container.height, height,
    65      "Container height is " + height);
    67   InspectorUI.treePanel.container.height = NEWHEIGHT;
    69   executeSoon(function() {
    70     InspectorUI.treePanel.close();
    71     InspectorUI.treePanel.open();
    72   });
    73 }
    75 function treePanelTests2()
    76 {
    77   Services.obs.removeObserver(treePanelTests2,
    78     InspectorUI.INSPECTOR_NOTIFICATIONS.TREEPANELREADY);
    80   ok(InspectorUI.treePanel.isOpen(), "Inspector Tree Panel is open");
    82   let height = Services.prefs.getIntPref("devtools.inspector.htmlHeight");
    84   is(InspectorUI.treePanel.container.height, NEWHEIGHT,
    85      "Container height is now " + height);
    87   InspectorUI.treePanel.close();
    88   executeSoon(function() {
    89     finishInspectorTests()
    90   });
    91 }
    93 function finishInspectorTests()
    94 {
    95   gBrowser.removeCurrentTab();
    96   finish();
    97 }
    99 function test()
   100 {
   101   waitForExplicitFinish();
   102   gBrowser.selectedTab = gBrowser.addTab();
   103   gBrowser.selectedBrowser.addEventListener("load", function() {
   104     gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
   105     doc = content.document;
   106     waitForFocus(createDocument, content);
   107   }, true);
   109   content.location = "data:text/html;charset=utf-8,browser_inspector_tree_height.js";
   110 }

mercurial