Bug 1329253 - Add test for source map bug. r=ttromey
authorJason Laster <jason.laster.11@gmail.com>
Fri, 06 Jan 2017 09:49:00 -0500
changeset 328687 22fa3b948119d788d50a02394ab9e3624e8505ef
parent 328686 d54ebcd1a796122e40d2bd3b6cb301aec273accd
child 328688 0df76d4b7a2744ab8ae900b4605dc6c22a93ca26
push id31182
push usercbook@mozilla.com
push dateTue, 10 Jan 2017 11:14:56 +0000
treeherdermozilla-central@7011ed1427de [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersttromey
bugs1329253
milestone53.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1329253 - Add test for source map bug. r=ttromey
devtools/client/debugger/new/test/mochitest/browser.ini
devtools/client/debugger/new/test/mochitest/browser_dbg-sourcemaps2.js
devtools/client/debugger/new/test/mochitest/examples/README.md
devtools/client/debugger/new/test/mochitest/examples/doc-sourcemaps.html
devtools/client/debugger/new/test/mochitest/examples/doc-sourcemaps2.html
devtools/client/debugger/new/test/mochitest/examples/sourcemaps/bundle.js
devtools/client/debugger/new/test/mochitest/examples/sourcemaps/bundle.js.map
devtools/client/debugger/new/test/mochitest/examples/sourcemaps2/main.js
devtools/client/debugger/new/test/mochitest/examples/sourcemaps2/main.js.map
devtools/client/debugger/new/test/mochitest/examples/sourcemaps2/main.min.js
--- a/devtools/client/debugger/new/test/mochitest/browser.ini
+++ b/devtools/client/debugger/new/test/mochitest/browser.ini
@@ -1,26 +1,30 @@
 [DEFAULT]
 tags = devtools
 subsuite = devtools
 skip-if = (os == 'linux' && debug && bits == 32)
 support-files =
   head.js
   !/devtools/client/commandline/test/helpers.js
   !/devtools/client/framework/test/shared-head.js
-  examples/bundle.js
-  examples/bundle.js.map
+  examples/sourcemaps/bundle.js
+  examples/sourcemaps/bundle.js.map
+  examples/sourcemaps2/main.min.js
+  examples/sourcemaps2/main.js
+  examples/sourcemaps2/main.js.map
   examples/doc-scripts.html
   examples/doc-script-switching.html
   examples/doc-exceptions.html
   examples/doc-iframes.html
   examples/doc-frames.html
   examples/doc-debugger-statements.html
   examples/doc-minified.html
   examples/doc-sourcemaps.html
+  examples/doc-sourcemaps2.html
   examples/doc-sourcemap-bogus.html
   examples/doc-sources.html
   examples/bogus-map.js
   examples/entry.js
   examples/exceptions.js
   examples/long.js
   examples/math.min.js
   examples/nested/nested-source.js
@@ -51,10 +55,11 @@ support-files =
 [browser_dbg_keyboard-shortcuts.js]
 [browser_dbg-pause-exceptions.js]
 [browser_dbg-navigation.js]
 [browser_dbg-pretty-print.js]
 [browser_dbg-pretty-print-paused.js]
 [browser_dbg-searching.js]
 skip-if = true
 [browser_dbg-sourcemaps.js]
+[browser_dbg-sourcemaps2.js]
 [browser_dbg-sourcemaps-bogus.js]
-[browser_dbg-sources.js]
\ No newline at end of file
+[browser_dbg-sources.js]
new file mode 100644
--- /dev/null
+++ b/devtools/client/debugger/new/test/mochitest/browser_dbg-sourcemaps2.js
@@ -0,0 +1,30 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+// Tests loading sourcemapped sources, setting breakpoints, and
+// stepping in them.
+
+// This source map does not have source contents, so it's fetched separately
+
+add_task(function* () {
+  const dbg = yield initDebugger("doc-sourcemaps2.html");
+  const { selectors: { getBreakpoint, getBreakpoints }, getState } = dbg;
+
+  yield waitForSources(dbg, "main.js", "main.min.js");
+
+  ok(true, "Original sources exist");
+  const mainSrc = findSource(dbg, "main.js");
+
+  yield selectSource(dbg, mainSrc);
+
+  // Test that breakpoint is not off by a line.
+  yield addBreakpoint(dbg, mainSrc, 4);
+  is(getBreakpoints(getState()).size, 1, "One breakpoint exists");
+  ok(getBreakpoint(getState(), { sourceId: mainSrc.id, line: 4 }),
+     "Breakpoint has correct line");
+
+  invokeInTab("logMessage");
+
+  yield waitForPaused(dbg);
+  assertPausedLocation(dbg, "main.js", 4);
+});
--- a/devtools/client/debugger/new/test/mochitest/examples/README.md
+++ b/devtools/client/debugger/new/test/mochitest/examples/README.md
@@ -1,7 +1,14 @@
 ### Test Examples
 
 ##### Pages
 * **doc_script-switching-01** - includes two scripts that reference each other. The second function has a debugger.
 * **doc-scripts** - includes three sources, a long source and two sources that reference each other.
 * **doc-iframes** - includes an iframe with the debugger statements source.
 * **debugger-statements** - inline script with functions for testing stepping.
+
+
+#### Source Maps
+
+* **sourcemaps** - simple case where the map has source contents
+* **sourcemap-bogus** - simple case where the map has source contents
+* **sourcemaps2** - simple case where the map does not have source contents, so we fetch the source
--- a/devtools/client/debugger/new/test/mochitest/examples/doc-sourcemaps.html
+++ b/devtools/client/debugger/new/test/mochitest/examples/doc-sourcemaps.html
@@ -1,13 +1,13 @@
 <!-- Any copyright is dedicated to the Public Domain.
      http://creativecommons.org/publicdomain/zero/1.0/ -->
 <!DOCTYPE html>
 <html>
   <head>
     <meta charset="utf-8"/>
     <title>Debugger test page</title>
   </head>
- 
+
   <body>
-    <script src="bundle.js"></script>
+    <script src="sourcemaps/bundle.js"></script>
   </body>
 </html>
new file mode 100644
--- /dev/null
+++ b/devtools/client/debugger/new/test/mochitest/examples/doc-sourcemaps2.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <meta charset="UTF-8">
+  </head>
+
+<body>
+
+  <section id="example">
+    <input id ="message" type="text" name="submitButton" value="" />
+    <input id ="log-message" type="button" name="submitButton" value="Log message!" />
+  </section>
+
+  <script type="text/javascript" src="sourcemaps2/main.min.js"></script>
+
+</body>
+
+</html>
new file mode 100644
--- /dev/null
+++ b/devtools/client/debugger/new/test/mochitest/examples/sourcemaps/bundle.js
@@ -0,0 +1,96 @@
+/******/ (function(modules) { // webpackBootstrap
+/******/ 	// The module cache
+/******/ 	var installedModules = {};
+/******/
+/******/ 	// The require function
+/******/ 	function __webpack_require__(moduleId) {
+/******/
+/******/ 		// Check if module is in cache
+/******/ 		if(installedModules[moduleId])
+/******/ 			return installedModules[moduleId].exports;
+/******/
+/******/ 		// Create a new module (and put it into the cache)
+/******/ 		var module = installedModules[moduleId] = {
+/******/ 			exports: {},
+/******/ 			id: moduleId,
+/******/ 			loaded: false
+/******/ 		};
+/******/
+/******/ 		// Execute the module function
+/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
+/******/
+/******/ 		// Flag the module as loaded
+/******/ 		module.loaded = true;
+/******/
+/******/ 		// Return the exports of the module
+/******/ 		return module.exports;
+/******/ 	}
+/******/
+/******/
+/******/ 	// expose the modules object (__webpack_modules__)
+/******/ 	__webpack_require__.m = modules;
+/******/
+/******/ 	// expose the module cache
+/******/ 	__webpack_require__.c = installedModules;
+/******/
+/******/ 	// __webpack_public_path__
+/******/ 	__webpack_require__.p = "";
+/******/
+/******/ 	// Load entry module and return exports
+/******/ 	return __webpack_require__(0);
+/******/ })
+/************************************************************************/
+/******/ ([
+/* 0 */
+/***/ function(module, exports, __webpack_require__) {
+
+	const times2 = __webpack_require__(1);
+	const { output } = __webpack_require__(2);
+	const opts = __webpack_require__(3);
+	
+	output(times2(1));
+	output(times2(2));
+	
+	if(opts.extra) {
+	  output(times2(3));
+	}
+	
+	window.keepMeAlive = function() {
+	  // This function exists to make sure this script is never garbage
+	  // collected. It is also callable from tests.
+	  return times2(4);
+	}
+
+
+/***/ },
+/* 1 */
+/***/ function(module, exports) {
+
+	module.exports = function(x) {
+	  return x * 2;
+	}
+
+
+/***/ },
+/* 2 */
+/***/ function(module, exports) {
+
+	function output(str) {
+	  console.log(str);
+	}
+	
+	module.exports = { output };
+
+
+/***/ },
+/* 3 */
+/***/ function(module, exports) {
+
+	module.exports = {
+	  extra: true
+	};
+
+
+/***/ }
+/******/ ]);
+//# sourceMappingURL=bundle.js.map
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/devtools/client/debugger/new/test/mochitest/examples/sourcemaps/bundle.js.map
@@ -0,0 +1,21 @@
+{
+  "version": 3,
+  "sources": [
+    "webpack:///webpack/bootstrap 4ef8c7ec7c1df790781e",
+    "webpack:///./entry.js",
+    "webpack:///./times2.js",
+    "webpack:///./output.js",
+    "webpack:///./opts.js"
+  ],
+  "names": [],
+  "mappings": ";AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,uBAAe;AACf;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;;;;;;ACtCA;AACA,QAAO,SAAS;AAChB;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;;;;;;ACfA;AACA;AACA;;;;;;;ACFA;AACA;AACA;;AAEA,mBAAkB;;;;;;;ACJlB;AACA;AACA",
+  "file": "bundle.js",
+  "sourcesContent": [
+    " \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 4ef8c7ec7c1df790781e",
+    "const times2 = require(\"./times2\");\nconst { output } = require(\"./output\");\nconst opts = require(\"./opts\");\n\noutput(times2(1));\noutput(times2(2));\n\nif(opts.extra) {\n  output(times2(3));\n}\n\nwindow.keepMeAlive = function() {\n  // This function exists to make sure this script is never garbage\n  // collected. It is also callable from tests.\n  return times2(4);\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./entry.js\n// module id = 0\n// module chunks = 0",
+    "module.exports = function(x) {\n  return x * 2;\n}\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./times2.js\n// module id = 1\n// module chunks = 0",
+    "function output(str) {\n  console.log(str);\n}\n\nmodule.exports = { output };\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./output.js\n// module id = 2\n// module chunks = 0",
+    "module.exports = {\n  extra: true\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./opts.js\n// module id = 3\n// module chunks = 0"
+  ],
+  "sourceRoot": ""
+}
new file mode 100644
--- /dev/null
+++ b/devtools/client/debugger/new/test/mochitest/examples/sourcemaps2/main.js
@@ -0,0 +1,15 @@
+var message = document.getElementById('message');
+
+function logMessage() {
+  console.log('message is: ' + message.value);
+}
+
+message.addEventListener('focus', function() {
+  message.value = '';
+}, false);
+
+var logMessageButton = document.getElementById('log-message');
+
+logMessageButton.addEventListener('click', function() {
+  logMessage();
+}, false);
new file mode 100644
--- /dev/null
+++ b/devtools/client/debugger/new/test/mochitest/examples/sourcemaps2/main.js.map
@@ -0,0 +1,1 @@
+{"version":3,"sources":["main.js"],"names":["message","document","getElementById","logMessage","console","log","value","addEventListener","logMessageButton"],"mappings":"AAAA,GAAIA,SAAUC,SAASC,eAAe,UAEtC,SAASC,cACPC,QAAQC,IAAI,eAAiBL,QAAQM,OAGvCN,QAAQO,iBAAiB,QAAS,WAChCP,QAAQM,MAAQ,IACf,MAEH,IAAIE,kBAAmBP,SAASC,eAAe,cAE/CM,kBAAiBD,iBAAiB,QAAS,WACzCJ,cACC"}
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/devtools/client/debugger/new/test/mochitest/examples/sourcemaps2/main.min.js
@@ -0,0 +1,2 @@
+var message=document.getElementById("message");function logMessage(){console.log("message is: "+message.value)}message.addEventListener("focus",function(){message.value=""},false);var logMessageButton=document.getElementById("log-message");logMessageButton.addEventListener("click",function(){logMessage()},false);
+//# sourceMappingURL=main.js.map