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/debugger/test/mochitest/browser_dbg_parser-04.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/debugger/test/mochitest/browser_dbg_parser-04.js')
-rw-r--r-- | devtools/client/debugger/test/mochitest/browser_dbg_parser-04.js | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/devtools/client/debugger/test/mochitest/browser_dbg_parser-04.js b/devtools/client/debugger/test/mochitest/browser_dbg_parser-04.js new file mode 100644 index 000000000..b6ae0dfb6 --- /dev/null +++ b/devtools/client/debugger/test/mochitest/browser_dbg_parser-04.js @@ -0,0 +1,58 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +/** + * Check that faulty JS inside HTML can be separated and identified correctly. + */ + +function test() { + let { Parser } = Cu.import("resource://devtools/shared/Parser.jsm", {}); + + let source = [ + "<!doctype html>", + "<head>", + "<SCRIPT>", + "let a + 42;", + "</SCRIPT>", + "<script type='text/javascript'>", + "let b = 42;", + "</SCRIPT>", + "<script type='text/javascript;version=1.8'>", + "let c + 42;", + "</SCRIPT>", + "</head>" + ].join("\n"); + let parser = new Parser(); + // Don't pollute the logs with exceptions that we are going to check anyhow. + parser.logExceptions = false; + let parsed = parser.get(source); + + ok(parsed, + "HTML code should be parsed correctly."); + is(parser.errors.length, 2, + "There should be two errors logged when parsing."); + + is(parser.errors[0].name, "SyntaxError", + "The correct first exception was caught."); + is(parser.errors[0].message, "missing ; before statement", + "The correct first exception was caught."); + + is(parser.errors[1].name, "SyntaxError", + "The correct second exception was caught."); + is(parser.errors[1].message, "missing ; before statement", + "The correct second exception was caught."); + + is(parsed.scriptCount, 1, + "There should be 1 script parsed in the parent HTML source."); + + is(parsed.getScriptInfo(source.indexOf("let a")).toSource(), "({start:-1, length:-1, index:-1})", + "The first script shouldn't be considered valid."); + is(parsed.getScriptInfo(source.indexOf("let b")).toSource(), "({start:85, length:13, index:0})", + "The second script was located correctly."); + is(parsed.getScriptInfo(source.indexOf("let c")).toSource(), "({start:-1, length:-1, index:-1})", + "The third script shouldn't be considered valid."); + + finish(); +} |