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 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | let doc; |
michael@0 | 5 | let inspector; |
michael@0 | 6 | |
michael@0 | 7 | function createDocument() |
michael@0 | 8 | { |
michael@0 | 9 | doc.body.innerHTML = '<h1>Sidebar state test</h1>'; |
michael@0 | 10 | doc.title = "Sidebar State Test"; |
michael@0 | 11 | |
michael@0 | 12 | openInspector(function(panel) { |
michael@0 | 13 | inspector = panel; |
michael@0 | 14 | inspector.sidebar.select("ruleview"); |
michael@0 | 15 | inspectorRuleViewOpened(); |
michael@0 | 16 | }); |
michael@0 | 17 | } |
michael@0 | 18 | |
michael@0 | 19 | function inspectorRuleViewOpened() |
michael@0 | 20 | { |
michael@0 | 21 | is(inspector.sidebar.getCurrentTabID(), "ruleview", "Rule View is selected by default"); |
michael@0 | 22 | |
michael@0 | 23 | // Select the computed view and turn off the inspector. |
michael@0 | 24 | inspector.sidebar.select("computedview"); |
michael@0 | 25 | |
michael@0 | 26 | gDevTools.once("toolbox-destroyed", inspectorClosed); |
michael@0 | 27 | let target = TargetFactory.forTab(gBrowser.selectedTab); |
michael@0 | 28 | gDevTools.closeToolbox(target); |
michael@0 | 29 | } |
michael@0 | 30 | |
michael@0 | 31 | function inspectorClosed() |
michael@0 | 32 | { |
michael@0 | 33 | openInspector(function(panel) { |
michael@0 | 34 | inspector = panel; |
michael@0 | 35 | |
michael@0 | 36 | if (inspector.sidebar.getCurrentTabID()) { |
michael@0 | 37 | info("Default sidebar already selected.") |
michael@0 | 38 | testNewDefaultTab(); |
michael@0 | 39 | } else { |
michael@0 | 40 | info("Default sidebar still to be selected, adding select listener."); |
michael@0 | 41 | inspector.sidebar.once("select", testNewDefaultTab); |
michael@0 | 42 | } |
michael@0 | 43 | }); |
michael@0 | 44 | } |
michael@0 | 45 | |
michael@0 | 46 | function testNewDefaultTab() |
michael@0 | 47 | { |
michael@0 | 48 | is(inspector.sidebar.getCurrentTabID(), "computedview", "Computed view is selected by default."); |
michael@0 | 49 | |
michael@0 | 50 | finishTest(); |
michael@0 | 51 | } |
michael@0 | 52 | |
michael@0 | 53 | |
michael@0 | 54 | function finishTest() |
michael@0 | 55 | { |
michael@0 | 56 | doc = inspector = null; |
michael@0 | 57 | gBrowser.removeCurrentTab(); |
michael@0 | 58 | finish(); |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | function test() |
michael@0 | 62 | { |
michael@0 | 63 | waitForExplicitFinish(); |
michael@0 | 64 | gBrowser.selectedTab = gBrowser.addTab(); |
michael@0 | 65 | gBrowser.selectedBrowser.addEventListener("load", function() { |
michael@0 | 66 | gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true); |
michael@0 | 67 | doc = content.document; |
michael@0 | 68 | waitForFocus(createDocument, content); |
michael@0 | 69 | }, true); |
michael@0 | 70 | |
michael@0 | 71 | content.location = "data:text/html;charset=utf-8,browser_inspector_sidebarstate.js"; |
michael@0 | 72 | } |