michael@0: /* -*- Mode: Javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim: set ts=2 et sw=2 tw=80: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: let doc; michael@0: let salutation; michael@0: let closing; michael@0: michael@0: const NEWHEIGHT = 226; michael@0: michael@0: function createDocument() michael@0: { michael@0: doc.body.innerHTML = '
\n' + michael@0: '

Some header text

\n' + michael@0: '

hi.

\n' + michael@0: '

I am a test-case. This text exists ' + michael@0: 'solely to provide some things to test the inspector initialization.

\n' + michael@0: 'If you are reading this, you should go do something else instead. Maybe ' + michael@0: 'read a book. Or better yet, write some test-cases for another bit of code. ' + michael@0: 'Maybe more inspector test-cases!

\n' + michael@0: '

end transmission

\n' + michael@0: '
'; michael@0: doc.title = "Inspector Initialization Test"; michael@0: startInspectorTests(); michael@0: } michael@0: michael@0: function startInspectorTests() michael@0: { michael@0: ok(InspectorUI, "InspectorUI variable exists"); michael@0: Services.obs.addObserver(runInspectorTests, michael@0: InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED, false); michael@0: InspectorUI.toggleInspectorUI(); michael@0: } michael@0: michael@0: function runInspectorTests() michael@0: { michael@0: Services.obs.removeObserver(runInspectorTests, michael@0: InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED); michael@0: michael@0: if (InspectorUI.treePanelEnabled) { michael@0: Services.obs.addObserver(treePanelTests, michael@0: InspectorUI.INSPECTOR_NOTIFICATIONS.TREEPANELREADY, false); michael@0: michael@0: InspectorUI.stopInspecting(); michael@0: michael@0: InspectorUI.treePanel.open(); michael@0: } else michael@0: finishInspectorTests(); michael@0: } michael@0: michael@0: function treePanelTests() michael@0: { michael@0: Services.obs.removeObserver(treePanelTests, michael@0: InspectorUI.INSPECTOR_NOTIFICATIONS.TREEPANELREADY); michael@0: Services.obs.addObserver(treePanelTests2, michael@0: InspectorUI.INSPECTOR_NOTIFICATIONS.TREEPANELREADY, false); michael@0: michael@0: ok(InspectorUI.treePanel.isOpen(), "Inspector Tree Panel is open"); michael@0: michael@0: let height = Services.prefs.getIntPref("devtools.inspector.htmlHeight"); michael@0: michael@0: is(InspectorUI.treePanel.container.height, height, michael@0: "Container height is " + height); michael@0: michael@0: InspectorUI.treePanel.container.height = NEWHEIGHT; michael@0: michael@0: executeSoon(function() { michael@0: InspectorUI.treePanel.close(); michael@0: InspectorUI.treePanel.open(); michael@0: }); michael@0: } michael@0: michael@0: function treePanelTests2() michael@0: { michael@0: Services.obs.removeObserver(treePanelTests2, michael@0: InspectorUI.INSPECTOR_NOTIFICATIONS.TREEPANELREADY); michael@0: michael@0: ok(InspectorUI.treePanel.isOpen(), "Inspector Tree Panel is open"); michael@0: michael@0: let height = Services.prefs.getIntPref("devtools.inspector.htmlHeight"); michael@0: michael@0: is(InspectorUI.treePanel.container.height, NEWHEIGHT, michael@0: "Container height is now " + height); michael@0: michael@0: InspectorUI.treePanel.close(); michael@0: executeSoon(function() { michael@0: finishInspectorTests() michael@0: }); michael@0: } michael@0: michael@0: function finishInspectorTests() michael@0: { michael@0: gBrowser.removeCurrentTab(); michael@0: finish(); michael@0: } michael@0: michael@0: function test() michael@0: { michael@0: waitForExplicitFinish(); michael@0: gBrowser.selectedTab = gBrowser.addTab(); michael@0: gBrowser.selectedBrowser.addEventListener("load", function() { michael@0: gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); michael@0: doc = content.document; michael@0: waitForFocus(createDocument, content); michael@0: }, true); michael@0: michael@0: content.location = "data:text/html;charset=utf-8,browser_inspector_tree_height.js"; michael@0: } michael@0: