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 | /** |
michael@0 | 5 | * Test that a "this source is blackboxed" message is shown when necessary |
michael@0 | 6 | * and can be properly dismissed. |
michael@0 | 7 | */ |
michael@0 | 8 | |
michael@0 | 9 | const TAB_URL = EXAMPLE_URL + "doc_binary_search.html"; |
michael@0 | 10 | |
michael@0 | 11 | let gTab, gDebuggee, gPanel, gDebugger; |
michael@0 | 12 | let gDeck; |
michael@0 | 13 | |
michael@0 | 14 | function test() { |
michael@0 | 15 | initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { |
michael@0 | 16 | gTab = aTab; |
michael@0 | 17 | gDebuggee = aDebuggee; |
michael@0 | 18 | gPanel = aPanel; |
michael@0 | 19 | gDebugger = gPanel.panelWin; |
michael@0 | 20 | gDeck = gDebugger.document.getElementById("editor-deck"); |
michael@0 | 21 | |
michael@0 | 22 | waitForSourceShown(gPanel, ".coffee") |
michael@0 | 23 | .then(testSourceEditorShown) |
michael@0 | 24 | .then(toggleBlackBoxing.bind(null, gPanel)) |
michael@0 | 25 | .then(testBlackBoxMessageShown) |
michael@0 | 26 | .then(clickStopBlackBoxingButton) |
michael@0 | 27 | .then(testSourceEditorShownAgain) |
michael@0 | 28 | .then(() => closeDebuggerAndFinish(gPanel)) |
michael@0 | 29 | .then(null, aError => { |
michael@0 | 30 | ok(false, "Got an error: " + aError.message + "\n" + aError.stack); |
michael@0 | 31 | }); |
michael@0 | 32 | }); |
michael@0 | 33 | } |
michael@0 | 34 | |
michael@0 | 35 | function testSourceEditorShown() { |
michael@0 | 36 | is(gDeck.selectedIndex, "0", |
michael@0 | 37 | "The first item in the deck should be selected (the source editor)."); |
michael@0 | 38 | } |
michael@0 | 39 | |
michael@0 | 40 | function testBlackBoxMessageShown() { |
michael@0 | 41 | is(gDeck.selectedIndex, "1", |
michael@0 | 42 | "The second item in the deck should be selected (the black box message)."); |
michael@0 | 43 | } |
michael@0 | 44 | |
michael@0 | 45 | function clickStopBlackBoxingButton() { |
michael@0 | 46 | let finished = waitForThreadEvents(gPanel, "blackboxchange"); |
michael@0 | 47 | getEditorBlackboxMessageButton().click(); |
michael@0 | 48 | return finished; |
michael@0 | 49 | } |
michael@0 | 50 | |
michael@0 | 51 | function testSourceEditorShownAgain() { |
michael@0 | 52 | is(gDeck.selectedIndex, "0", |
michael@0 | 53 | "The first item in the deck should be selected again (the source editor)."); |
michael@0 | 54 | } |
michael@0 | 55 | |
michael@0 | 56 | function getEditorBlackboxMessageButton() { |
michael@0 | 57 | return gDebugger.document.getElementById("black-boxed-message-button"); |
michael@0 | 58 | } |
michael@0 | 59 | |
michael@0 | 60 | registerCleanupFunction(function() { |
michael@0 | 61 | gTab = null; |
michael@0 | 62 | gDebuggee = null; |
michael@0 | 63 | gPanel = null; |
michael@0 | 64 | gDebugger = null; |
michael@0 | 65 | gDeck = null; |
michael@0 | 66 | }); |