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 prettifying HTML sources doesn't do anything. |
michael@0 | 6 | */ |
michael@0 | 7 | |
michael@0 | 8 | const TAB_URL = EXAMPLE_URL + "doc_included-script.html"; |
michael@0 | 9 | |
michael@0 | 10 | let gTab, gDebuggee, gPanel, gDebugger; |
michael@0 | 11 | let gEditor, gSources, gControllerSources; |
michael@0 | 12 | |
michael@0 | 13 | function test() { |
michael@0 | 14 | initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { |
michael@0 | 15 | gTab = aTab; |
michael@0 | 16 | gDebuggee = aDebuggee; |
michael@0 | 17 | gPanel = aPanel; |
michael@0 | 18 | gDebugger = gPanel.panelWin; |
michael@0 | 19 | gEditor = gDebugger.DebuggerView.editor; |
michael@0 | 20 | gSources = gDebugger.DebuggerView.Sources; |
michael@0 | 21 | gControllerSources = gDebugger.DebuggerController.SourceScripts; |
michael@0 | 22 | |
michael@0 | 23 | Task.spawn(function() { |
michael@0 | 24 | yield waitForSourceShown(gPanel, TAB_URL); |
michael@0 | 25 | |
michael@0 | 26 | // From this point onward, the source editor's text should never change. |
michael@0 | 27 | gEditor.once("change", () => { |
michael@0 | 28 | ok(false, "The source editor text shouldn't have changed."); |
michael@0 | 29 | }); |
michael@0 | 30 | |
michael@0 | 31 | is(gSources.selectedValue, TAB_URL, |
michael@0 | 32 | "The correct source is currently selected."); |
michael@0 | 33 | ok(gEditor.getText().contains("myFunction"), |
michael@0 | 34 | "The source shouldn't be pretty printed yet."); |
michael@0 | 35 | |
michael@0 | 36 | clickPrettyPrintButton(); |
michael@0 | 37 | |
michael@0 | 38 | let { source } = gSources.selectedItem.attachment; |
michael@0 | 39 | try { |
michael@0 | 40 | yield gControllerSources.togglePrettyPrint(source); |
michael@0 | 41 | ok(false, "The promise for a prettified source should be rejected!"); |
michael@0 | 42 | } catch ([source, error]) { |
michael@0 | 43 | is(error, "Can't prettify non-javascript files.", |
michael@0 | 44 | "The promise was correctly rejected with a meaningful message."); |
michael@0 | 45 | } |
michael@0 | 46 | |
michael@0 | 47 | let [source, text] = yield gControllerSources.getText(source); |
michael@0 | 48 | is(gSources.selectedValue, TAB_URL, |
michael@0 | 49 | "The correct source is still selected."); |
michael@0 | 50 | ok(gEditor.getText().contains("myFunction"), |
michael@0 | 51 | "The displayed source hasn't changed."); |
michael@0 | 52 | ok(text.contains("myFunction"), |
michael@0 | 53 | "The cached source text wasn't altered in any way."); |
michael@0 | 54 | |
michael@0 | 55 | yield closeDebuggerAndFinish(gPanel); |
michael@0 | 56 | }); |
michael@0 | 57 | }); |
michael@0 | 58 | } |
michael@0 | 59 | |
michael@0 | 60 | function clickPrettyPrintButton() { |
michael@0 | 61 | gDebugger.document.getElementById("pretty-print").click(); |
michael@0 | 62 | } |
michael@0 | 63 | |
michael@0 | 64 | function prepareDebugger(aPanel) { |
michael@0 | 65 | aPanel._view.Sources.preferredSource = TAB_URL; |
michael@0 | 66 | } |
michael@0 | 67 | |
michael@0 | 68 | registerCleanupFunction(function() { |
michael@0 | 69 | gTab = null; |
michael@0 | 70 | gDebuggee = null; |
michael@0 | 71 | gPanel = null; |
michael@0 | 72 | gDebugger = null; |
michael@0 | 73 | gEditor = null; |
michael@0 | 74 | gSources = null; |
michael@0 | 75 | gControllerSources = null; |
michael@0 | 76 | }); |