diff options
Diffstat (limited to 'devtools/client/debugger/new/test/mochitest/examples')
28 files changed, 498 insertions, 0 deletions
diff --git a/devtools/client/debugger/new/test/mochitest/examples/README.md b/devtools/client/debugger/new/test/mochitest/examples/README.md new file mode 100644 index 000000000..1be42619d --- /dev/null +++ b/devtools/client/debugger/new/test/mochitest/examples/README.md @@ -0,0 +1,7 @@ +### 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. diff --git a/devtools/client/debugger/new/test/mochitest/examples/bogus-map.js b/devtools/client/debugger/new/test/mochitest/examples/bogus-map.js new file mode 100644 index 000000000..20b5bbf7e --- /dev/null +++ b/devtools/client/debugger/new/test/mochitest/examples/bogus-map.js @@ -0,0 +1,8 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ +function runCode(){ + var a=1; + a=a*2; + return a; +} +//# sourceMappingURL=bogus.map diff --git a/devtools/client/debugger/new/test/mochitest/examples/bundle.js b/devtools/client/debugger/new/test/mochitest/examples/bundle.js new file mode 100644 index 000000000..a03ace934 --- /dev/null +++ b/devtools/client/debugger/new/test/mochitest/examples/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 diff --git a/devtools/client/debugger/new/test/mochitest/examples/bundle.js.map b/devtools/client/debugger/new/test/mochitest/examples/bundle.js.map new file mode 100644 index 000000000..ed7336ad1 --- /dev/null +++ b/devtools/client/debugger/new/test/mochitest/examples/bundle.js.map @@ -0,0 +1 @@ +{"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":""}
\ No newline at end of file diff --git a/devtools/client/debugger/new/test/mochitest/examples/doc-debugger-statements.html b/devtools/client/debugger/new/test/mochitest/examples/doc-debugger-statements.html new file mode 100644 index 000000000..967619d31 --- /dev/null +++ b/devtools/client/debugger/new/test/mochitest/examples/doc-debugger-statements.html @@ -0,0 +1,27 @@ +<html> + <head> + <title>Debugger Statements</title> + </head> + + <body> + <script> + debugger; + test(); + + function test() { + debugger; + stepIntoMe(); + } + + function stepIntoMe() { + // step in + stepOverMe(); + // step out + } + + function stepOverMe() { + } + </script> + </body> + +</html> diff --git a/devtools/client/debugger/new/test/mochitest/examples/doc-exceptions.html b/devtools/client/debugger/new/test/mochitest/examples/doc-exceptions.html new file mode 100644 index 000000000..5ca65b755 --- /dev/null +++ b/devtools/client/debugger/new/test/mochitest/examples/doc-exceptions.html @@ -0,0 +1,7 @@ +<html> + <head> + <title>Debugger test page</title> + <script type="text/javascript" src="exceptions.js"></script> + </head> + <body></body> +</html> diff --git a/devtools/client/debugger/new/test/mochitest/examples/doc-frames.html b/devtools/client/debugger/new/test/mochitest/examples/doc-frames.html new file mode 100644 index 000000000..408c55b28 --- /dev/null +++ b/devtools/client/debugger/new/test/mochitest/examples/doc-frames.html @@ -0,0 +1,17 @@ +<html> + <head> + <title>Frames</title> + </head> + + <body> + <script> + debugger; + // This inline script allows this HTML page to show up as a + // source. It also needs to introduce a new global variable so + // it's not immediately garbage collected. + function inline_script() { var x = 5; } + </script> + <script type="text/javascript" src="frames.js"></script> + </body> + +</html> diff --git a/devtools/client/debugger/new/test/mochitest/examples/doc-iframes.html b/devtools/client/debugger/new/test/mochitest/examples/doc-iframes.html new file mode 100644 index 000000000..26446eaa1 --- /dev/null +++ b/devtools/client/debugger/new/test/mochitest/examples/doc-iframes.html @@ -0,0 +1,17 @@ +<html> + <head> + <title>Iframe</title> + </head> + + <body> + <script> + debugger; + // This inline script allows this HTML page to show up as a + // source. It also needs to introduce a new global variable so + // it's not immediately garbage collected. + function inline_script() { var x = 5; } + </script> + <iframe src="doc-debugger-statements.html"></iframe> + </body> + +</html> diff --git a/devtools/client/debugger/new/test/mochitest/examples/doc-minified.html b/devtools/client/debugger/new/test/mochitest/examples/doc-minified.html new file mode 100644 index 000000000..4c95a9b4a --- /dev/null +++ b/devtools/client/debugger/new/test/mochitest/examples/doc-minified.html @@ -0,0 +1,14 @@ +<!-- 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="math.min.js"></script> + </body> +</html> diff --git a/devtools/client/debugger/new/test/mochitest/examples/doc-script-switching.html b/devtools/client/debugger/new/test/mochitest/examples/doc-script-switching.html new file mode 100644 index 000000000..3c71497c2 --- /dev/null +++ b/devtools/client/debugger/new/test/mochitest/examples/doc-script-switching.html @@ -0,0 +1,18 @@ +<!-- 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> + <button onclick="firstCall()">Click me!</button> + + <script type="text/javascript" src="script-switching-01.js"></script> + <script type="text/javascript" src="script-switching-02.js"></script> + </body> + +</html> diff --git a/devtools/client/debugger/new/test/mochitest/examples/doc-scripts.html b/devtools/client/debugger/new/test/mochitest/examples/doc-scripts.html new file mode 100644 index 000000000..212b4802f --- /dev/null +++ b/devtools/client/debugger/new/test/mochitest/examples/doc-scripts.html @@ -0,0 +1,21 @@ +<!-- 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="simple1.js"></script> + <script src="simple2.js"></script> + <script src="long.js"></script> + <script> + // This inline script allows this HTML page to show up as a + // source. It also needs to introduce a new global variable so + // it's not immediately garbage collected. + function inline_script() { var x = 5; } + </script> + </body> +</html> diff --git a/devtools/client/debugger/new/test/mochitest/examples/doc-sourcemap-bogus.html b/devtools/client/debugger/new/test/mochitest/examples/doc-sourcemap-bogus.html new file mode 100644 index 000000000..da448a2cd --- /dev/null +++ b/devtools/client/debugger/new/test/mochitest/examples/doc-sourcemap-bogus.html @@ -0,0 +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="bogus-map.js"></script> + </body> +</html> diff --git a/devtools/client/debugger/new/test/mochitest/examples/doc-sourcemaps.html b/devtools/client/debugger/new/test/mochitest/examples/doc-sourcemaps.html new file mode 100644 index 000000000..10f5da047 --- /dev/null +++ b/devtools/client/debugger/new/test/mochitest/examples/doc-sourcemaps.html @@ -0,0 +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> + </body> +</html> diff --git a/devtools/client/debugger/new/test/mochitest/examples/doc-sources.html b/devtools/client/debugger/new/test/mochitest/examples/doc-sources.html new file mode 100644 index 000000000..14cc86701 --- /dev/null +++ b/devtools/client/debugger/new/test/mochitest/examples/doc-sources.html @@ -0,0 +1,23 @@ +<!-- 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="simple1.js"></script> + <script src="simple2.js"></script> + <script src="long.js"></script> + <script> + // This inline script allows this HTML page to show up as a + // source. It also needs to introduce a new global variable so + // it's not immediately garbage collected. + function inline_script() { var x = 5; } + </script> + <script src="nested/nested-source.js"></script> + <script src="nested/deeper/deeper-source.js"></script> + </body> +</html> diff --git a/devtools/client/debugger/new/test/mochitest/examples/entry.js b/devtools/client/debugger/new/test/mochitest/examples/entry.js new file mode 100644 index 000000000..d397a966b --- /dev/null +++ b/devtools/client/debugger/new/test/mochitest/examples/entry.js @@ -0,0 +1,16 @@ +const times2 = require("./times2"); +const { output } = require("./output"); +const opts = require("./opts"); + +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); +} diff --git a/devtools/client/debugger/new/test/mochitest/examples/exceptions.js b/devtools/client/debugger/new/test/mochitest/examples/exceptions.js new file mode 100644 index 000000000..9523f00ca --- /dev/null +++ b/devtools/client/debugger/new/test/mochitest/examples/exceptions.js @@ -0,0 +1,19 @@ +function uncaughtException() { + throw "unreachable" +} + +function caughtError() { + try { + throw new Error("error"); + } catch (e) { + debugger; + } +} + +function caughtException() { + try { + throw "reachable"; + } catch (e) { + debugger; + } +} diff --git a/devtools/client/debugger/new/test/mochitest/examples/frames.js b/devtools/client/debugger/new/test/mochitest/examples/frames.js new file mode 100644 index 000000000..0f031582e --- /dev/null +++ b/devtools/client/debugger/new/test/mochitest/examples/frames.js @@ -0,0 +1,24 @@ +function recurseA(i) { + if (i == 20) { + debugger; + return; + } + + // down into the rabbit hole we go + return (i % 2) ? recurseA(++i) : recurseB(++i); +} + +function recurseB(i) { + if (i == 20) { + debugger; + return; + } + + // down into the rabbit hole we go + return (i % 2) ? recurseA(++i) : recurseB(++i); +} + + +window.startRecursion = function() { + return recurseA(0); +} diff --git a/devtools/client/debugger/new/test/mochitest/examples/long.js b/devtools/client/debugger/new/test/mochitest/examples/long.js new file mode 100644 index 000000000..58d605b36 --- /dev/null +++ b/devtools/client/debugger/new/test/mochitest/examples/long.js @@ -0,0 +1,76 @@ +var app = {}; + +// Generic "model" object. You can use whatever +// framework you want. For this application it +// may not even be worth separating this logic +// out, but we do this to demonstrate one way to +// separate out parts of your application. +app.TodoModel = function (key) { + this.key = key; + this.todos = []; + this.onChanges = []; +}; + +app.TodoModel.prototype.addTodo = function (title) { + this.todos = this.todos.concat([{ + id: Utils.uuid(), + title: title, + completed: false + }]); +}; + +app.TodoModel.prototype.inform = function() { + // Something changed, but we do nothing + return null; +}; + +app.TodoModel.prototype.toggleAll = function (checked) { + // Note: it's usually better to use immutable data structures since they're + // easier to reason about and React works very well with them. That's why + // we use map() and filter() everywhere instead of mutating the array or + // todo items themselves. + this.todos = this.todos.map(function (todo) { + return Object.assign({}, todo, {completed: checked}); + }); + + this.inform(); +}; + +app.TodoModel.prototype.toggle = function (todoToToggle) { + this.todos = this.todos.map(function (todo) { + return todo !== todoToToggle ? + todo : + Object.assign({}, todo, {completed: !todo.completed}); + }); + + this.inform(); +}; + +app.TodoModel.prototype.destroy = function (todo) { + this.todos = this.todos.filter(function (candidate) { + return candidate !== todo; + }); + + this.inform(); +}; + +app.TodoModel.prototype.save = function (todoToSave, text) { + this.todos = this.todos.map(function (todo) { + return todo !== todoToSave ? todo : Object.assign({}, todo, {title: text}); + }); + + this.inform(); +}; + +app.TodoModel.prototype.clearCompleted = function () { + this.todos = this.todos.filter(function (todo) { + return !todo.completed; + }); + + this.inform(); +}; + +function testModel() { + const model = new app.TodoModel(); + model.clearCompleted(); +} diff --git a/devtools/client/debugger/new/test/mochitest/examples/math.min.js b/devtools/client/debugger/new/test/mochitest/examples/math.min.js new file mode 100644 index 000000000..5a8593345 --- /dev/null +++ b/devtools/client/debugger/new/test/mochitest/examples/math.min.js @@ -0,0 +1,3 @@ +function add(a,b,k){var result=a+b;return k(result)}function sub(a,b,k){var result=a-b;return k(result)}function mul(a,b,k){var result=a*b;return k(result)}function div(a,b,k){var result=a/b;return k(result)}function arithmetic(){ + add(4,4,function(a){ + sub(a,2,function(b){mul(b,3,function(c){div(c,2,function(d){console.log(d)})})})})}; diff --git a/devtools/client/debugger/new/test/mochitest/examples/nested/nested-source.js b/devtools/client/debugger/new/test/mochitest/examples/nested/nested-source.js new file mode 100644 index 000000000..a7b20f015 --- /dev/null +++ b/devtools/client/debugger/new/test/mochitest/examples/nested/nested-source.js @@ -0,0 +1,3 @@ +function computeSomething() { + return 1; +} diff --git a/devtools/client/debugger/new/test/mochitest/examples/opts.js b/devtools/client/debugger/new/test/mochitest/examples/opts.js new file mode 100644 index 000000000..20988fa4a --- /dev/null +++ b/devtools/client/debugger/new/test/mochitest/examples/opts.js @@ -0,0 +1,3 @@ +module.exports = { + extra: true +}; diff --git a/devtools/client/debugger/new/test/mochitest/examples/output.js b/devtools/client/debugger/new/test/mochitest/examples/output.js new file mode 100644 index 000000000..14281fdbf --- /dev/null +++ b/devtools/client/debugger/new/test/mochitest/examples/output.js @@ -0,0 +1,5 @@ +function output(str) { + console.log(str); +} + +module.exports = { output }; diff --git a/devtools/client/debugger/new/test/mochitest/examples/script-switching-01.js b/devtools/client/debugger/new/test/mochitest/examples/script-switching-01.js new file mode 100644 index 000000000..4ba2772de --- /dev/null +++ b/devtools/client/debugger/new/test/mochitest/examples/script-switching-01.js @@ -0,0 +1,6 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +function firstCall() { + secondCall(); +} diff --git a/devtools/client/debugger/new/test/mochitest/examples/script-switching-02.js b/devtools/client/debugger/new/test/mochitest/examples/script-switching-02.js new file mode 100644 index 000000000..feb74315f --- /dev/null +++ b/devtools/client/debugger/new/test/mochitest/examples/script-switching-02.js @@ -0,0 +1,13 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +function secondCall() { + // This comment is useful: ☺ + debugger; + function foo() {} + if (x) { + foo(); + } +} + +var x = true; diff --git a/devtools/client/debugger/new/test/mochitest/examples/simple1.js b/devtools/client/debugger/new/test/mochitest/examples/simple1.js new file mode 100644 index 000000000..87cc50f44 --- /dev/null +++ b/devtools/client/debugger/new/test/mochitest/examples/simple1.js @@ -0,0 +1,31 @@ +function main() { + // A comment so we can test that breakpoint sliding works across + // multiple lines + const func = foo(1, 2); + const result = func(); + return result; +} + +function doEval() { + eval("(" + function() { + debugger; + + window.evaledFunc = function() { + var foo = 1; + var bar = 2; + return foo + bar; + }; + }.toString() + ")()"); +} + +function doNamedEval() { + eval("(" + function() { + debugger; + + window.evaledFunc = function() { + var foo = 1; + var bar = 2; + return foo + bar; + }; + }.toString() + ")();\n //# sourceURL=evaled.js"); +} diff --git a/devtools/client/debugger/new/test/mochitest/examples/simple2.js b/devtools/client/debugger/new/test/mochitest/examples/simple2.js new file mode 100644 index 000000000..40c280edf --- /dev/null +++ b/devtools/client/debugger/new/test/mochitest/examples/simple2.js @@ -0,0 +1,6 @@ +function foo(x, y) { + function bar() { + return x + y; + } + return bar; +} diff --git a/devtools/client/debugger/new/test/mochitest/examples/times2.js b/devtools/client/debugger/new/test/mochitest/examples/times2.js new file mode 100644 index 000000000..2d51ed87a --- /dev/null +++ b/devtools/client/debugger/new/test/mochitest/examples/times2.js @@ -0,0 +1,3 @@ +module.exports = function(x) { + return x * 2; +} diff --git a/devtools/client/debugger/new/test/mochitest/examples/webpack.config.js b/devtools/client/debugger/new/test/mochitest/examples/webpack.config.js new file mode 100644 index 000000000..ff22342ce --- /dev/null +++ b/devtools/client/debugger/new/test/mochitest/examples/webpack.config.js @@ -0,0 +1,8 @@ + +module.exports = { + entry: "./entry.js", + output: { + filename: "bundle.js" + }, + devtool: "sourcemap" +} |