Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
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 | * Tests that the function searching works with pretty printed sources. |
michael@0 | 6 | */ |
michael@0 | 7 | |
michael@0 | 8 | const TAB_URL = EXAMPLE_URL + "doc_pretty-print.html"; |
michael@0 | 9 | |
michael@0 | 10 | let gTab, gDebuggee, gPanel, gDebugger; |
michael@0 | 11 | let gSearchBox; |
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 | gSearchBox = gDebugger.DebuggerView.Filtering._searchbox; |
michael@0 | 20 | |
michael@0 | 21 | waitForSourceShown(gPanel, "code_ugly.js") |
michael@0 | 22 | .then(testUglySearch) |
michael@0 | 23 | .then(() => { |
michael@0 | 24 | const finished = waitForSourceShown(gPanel, "code_ugly.js"); |
michael@0 | 25 | clickPrettyPrintButton(); |
michael@0 | 26 | return finished; |
michael@0 | 27 | }) |
michael@0 | 28 | .then(testPrettyPrintedSearch) |
michael@0 | 29 | .then(() => closeDebuggerAndFinish(gPanel)) |
michael@0 | 30 | .then(null, aError => { |
michael@0 | 31 | ok(false, "Got an error: " + aError.message + "\n" + aError.stack); |
michael@0 | 32 | }); |
michael@0 | 33 | }); |
michael@0 | 34 | } |
michael@0 | 35 | |
michael@0 | 36 | function testUglySearch() { |
michael@0 | 37 | const deferred = promise.defer(); |
michael@0 | 38 | |
michael@0 | 39 | once(gDebugger, "popupshown").then(() => { |
michael@0 | 40 | ok(isCaretPos(gPanel, 2, 10), |
michael@0 | 41 | "The bar function's non-pretty-printed location should be shown."); |
michael@0 | 42 | deferred.resolve(); |
michael@0 | 43 | }); |
michael@0 | 44 | |
michael@0 | 45 | setText(gSearchBox, "@bar"); |
michael@0 | 46 | return deferred.promise; |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | function clickPrettyPrintButton() { |
michael@0 | 50 | gDebugger.document.getElementById("pretty-print").click(); |
michael@0 | 51 | } |
michael@0 | 52 | |
michael@0 | 53 | function testPrettyPrintedSearch() { |
michael@0 | 54 | const deferred = promise.defer(); |
michael@0 | 55 | |
michael@0 | 56 | once(gDebugger, "popupshown").then(() => { |
michael@0 | 57 | ok(isCaretPos(gPanel, 6, 10), |
michael@0 | 58 | "The bar function's pretty printed location should be shown."); |
michael@0 | 59 | deferred.resolve(); |
michael@0 | 60 | }); |
michael@0 | 61 | |
michael@0 | 62 | setText(gSearchBox, "@bar"); |
michael@0 | 63 | return deferred.promise; |
michael@0 | 64 | } |
michael@0 | 65 | |
michael@0 | 66 | registerCleanupFunction(function() { |
michael@0 | 67 | gTab = null; |
michael@0 | 68 | gDebuggee = null; |
michael@0 | 69 | gPanel = null; |
michael@0 | 70 | gDebugger = null; |
michael@0 | 71 | gSearchBox = null; |
michael@0 | 72 | }); |