diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /devtools/client/scratchpad/test/browser_scratchpad_pprint_error_goto_line.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'devtools/client/scratchpad/test/browser_scratchpad_pprint_error_goto_line.js')
-rw-r--r-- | devtools/client/scratchpad/test/browser_scratchpad_pprint_error_goto_line.js | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/devtools/client/scratchpad/test/browser_scratchpad_pprint_error_goto_line.js b/devtools/client/scratchpad/test/browser_scratchpad_pprint_error_goto_line.js new file mode 100644 index 000000000..21f266f61 --- /dev/null +++ b/devtools/client/scratchpad/test/browser_scratchpad_pprint_error_goto_line.js @@ -0,0 +1,78 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2; fill-column: 80 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +function test() +{ + waitForExplicitFinish(); + + gBrowser.selectedTab = gBrowser.addTab(); + gBrowser.selectedBrowser.addEventListener("load", function onLoad() { + gBrowser.selectedBrowser.removeEventListener("load", onLoad, true); + openScratchpad(runTests); + }, true); + + content.location = "data:text/html;charset=utf8," + + "test Scratchpad pretty print error goto line."; +} + +function testJumpToPrettyPrintError(sp, error, remark) { + info("will test jumpToLine after prettyPrint error" + remark); + + // CodeMirror lines and columns are 0-based, Scratchpad UI and error + // stack are 1-based. + is(/Invalid regular expression flag \(3:10\)/.test(error), true, + "prettyPrint expects error in editor text:\n" + error); + + sp.editor.jumpToLine(); + + const editorDoc = sp.editor.container.contentDocument; + const lineInput = editorDoc.querySelector("input"); + const errorLocation = lineInput.value; + const [ inputLine, inputColumn ] = errorLocation.split(":"); + const errorLine = 3, errorColumn = 10; + + is(inputLine, errorLine, + "jumpToLine input field is set from editor selection (line)"); + is(inputColumn, errorColumn, + "jumpToLine input field is set from editor selection (column)"); + + EventUtils.synthesizeKey("VK_RETURN", { }, editorDoc.defaultView); + + // CodeMirror lines and columns are 0-based, Scratchpad UI and error + // stack are 1-based. + const cursor = sp.editor.getCursor(); + is(inputLine, cursor.line + 1, "jumpToLine goto error location (line)"); + is(inputColumn, cursor.ch + 1, "jumpToLine goto error location (column)"); +} + +function runTests(sw, sp) +{ + sp.setText([ + "// line 1", + "// line 2", + "var re = /a bad /regexp/; // line 3 is an obvious syntax error!", + "// line 4", + "// line 5", + "" + ].join("\n")); + + sp.prettyPrint().then(aFulfill => { + ok(false, "Expecting Invalid regexp flag (3:10)"); + finish(); + }, error => { + testJumpToPrettyPrintError(sp, error, " (Bug 1005471, first time)"); + }); + + sp.prettyPrint().then(aFulfill => { + ok(false, "Expecting Invalid regexp flag (3:10)"); + finish(); + }, error => { + // Second time verifies bug in earlier implementation fixed. + testJumpToPrettyPrintError(sp, error, " (second time)"); + finish(); + }); +} |