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 | * Make sure that right clicking and selecting the pretty print context menu |
michael@0 | 6 | * item prettifies the source. |
michael@0 | 7 | */ |
michael@0 | 8 | |
michael@0 | 9 | const TAB_URL = EXAMPLE_URL + "doc_pretty-print.html"; |
michael@0 | 10 | |
michael@0 | 11 | let gTab, gDebuggee, gPanel, gDebugger; |
michael@0 | 12 | let gEditor, gContextMenu; |
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 | gEditor = gDebugger.DebuggerView.editor; |
michael@0 | 21 | gContextMenu = gDebugger.document.getElementById("sourceEditorContextMenu"); |
michael@0 | 22 | |
michael@0 | 23 | waitForSourceShown(gPanel, "code_ugly.js") |
michael@0 | 24 | .then(() => { |
michael@0 | 25 | const finished = waitForSourceShown(gPanel, "code_ugly.js"); |
michael@0 | 26 | selectContextMenuItem(); |
michael@0 | 27 | return finished; |
michael@0 | 28 | }) |
michael@0 | 29 | .then(testSourceIsPretty) |
michael@0 | 30 | .then(closeDebuggerAndFinish.bind(null, gPanel)) |
michael@0 | 31 | .then(null, aError => { |
michael@0 | 32 | ok(false, "Got an error: " + DevToolsUtils.safeErrorString(aError)); |
michael@0 | 33 | }); |
michael@0 | 34 | }); |
michael@0 | 35 | } |
michael@0 | 36 | |
michael@0 | 37 | function selectContextMenuItem() { |
michael@0 | 38 | once(gContextMenu, "popupshown").then(() => { |
michael@0 | 39 | const menuItem = gDebugger.document.getElementById("se-dbg-cMenu-prettyPrint"); |
michael@0 | 40 | menuItem.click(); |
michael@0 | 41 | }); |
michael@0 | 42 | gContextMenu.openPopup(gEditor.container, "overlap", 0, 0, true, false); |
michael@0 | 43 | } |
michael@0 | 44 | |
michael@0 | 45 | function testSourceIsPretty() { |
michael@0 | 46 | ok(gEditor.getText().contains("\n "), |
michael@0 | 47 | "The source should be pretty printed.") |
michael@0 | 48 | } |
michael@0 | 49 | |
michael@0 | 50 | registerCleanupFunction(function() { |
michael@0 | 51 | gTab = null; |
michael@0 | 52 | gDebuggee = null; |
michael@0 | 53 | gPanel = null; |
michael@0 | 54 | gDebugger = null; |
michael@0 | 55 | gEditor = null; |
michael@0 | 56 | gContextMenu = null; |
michael@0 | 57 | }); |