Bug 801304 Part 3 - Add test that XHR does not break run-to-completion when paused in the debugger, r=jimb.
authorBrian Hackett <bhackett1024@gmail.com>
Fri, 14 Dec 2018 06:48:13 -1000
changeset 450806 ef37f622e40ebf5b4c23011cab444269b1c6d23e
parent 450805 2e68f8f42eb5568ba00d517fe149580b1e875c5e
child 450807 8ea9cbbd44eb9c236e7323046e203a86cb2da40c
push id35208
push usercsabou@mozilla.com
push dateSat, 15 Dec 2018 02:48:07 +0000
treeherdermozilla-central@d86d184dc7d6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimb
bugs801304
milestone66.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 801304 Part 3 - Add test that XHR does not break run-to-completion when paused in the debugger, r=jimb.
devtools/client/debugger/new/test/mochitest/browser.ini
devtools/client/debugger/new/test/mochitest/browser_dbg-xhr-run-to-completion.js
devtools/client/debugger/new/test/mochitest/examples/doc-xhr-run-to-completion.html
--- a/devtools/client/debugger/new/test/mochitest/browser.ini
+++ b/devtools/client/debugger/new/test/mochitest/browser.ini
@@ -586,16 +586,17 @@ support-files =
   examples/react/build/main.js.map
   examples/doc-react.html
   examples/wasm-sourcemaps/fib.c
   examples/wasm-sourcemaps/fib.wasm
   examples/wasm-sourcemaps/fib.wasm.map
   examples/wasm-sourcemaps/utils.js
   examples/fetch.js
   examples/doc-xhr.html
+  examples/doc-xhr-run-to-completion.html
   examples/sum/sum.js
   examples/sum/sum.min.js
   examples/sum/sum.min.js.map
   examples/big-sourcemap_files/bundle.js
   examples/big-sourcemap_files/bundle.js.map
   examples/reload/code_reload_1.js
   examples/reload/code_reload_2.js
   examples/reload/doc-reload.html
@@ -654,16 +655,17 @@ support-files =
   examples/doc_rr_recovery.html
   examples/doc_rr_error.html
 
 [browser_dbg-asm.js]
 [browser_dbg-async-stepping.js]
 [browser_dbg-sourcemapped-breakpoint-console.js]
 skip-if = (os == "win" && ccov) # Bug 1453549
 [browser_dbg-xhr-breakpoints.js]
+[browser_dbg-xhr-run-to-completion.js]
 [browser_dbg-sourcemapped-scopes.js]
 skip-if = ccov || (verify && debug && (os == 'linux')) # Bug 1441545
 [browser_dbg-sourcemapped-stepping.js]
 skip-if = (os == 'win' && os_version == '10.0' && ccov) # Bug 1480680
 [browser_dbg-sourcemapped-preview.js]
 skip-if = os == "win" # Bug 1448523, Bug 1448450
 [browser_dbg-breaking.js]
 [browser_dbg-breaking-from-console.js]
new file mode 100644
--- /dev/null
+++ b/devtools/client/debugger/new/test/mochitest/browser_dbg-xhr-run-to-completion.js
@@ -0,0 +1,31 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
+
+// Test that XHR handlers are not called when pausing in the debugger.
+add_task(async function() {
+  const dbg = await initDebugger("doc-xhr-run-to-completion.html");
+  invokeInTab("singleRequest", "doc-xhr-run-to-completion.html");
+  await waitForPaused(dbg);
+  assertPausedLocation(dbg);
+  resume(dbg);
+  await once(Services.ppmm, "test passed");
+});
+
+// Test that XHR handlers are not called when pausing in the debugger,
+// including when there are multiple XHRs and multiple times we pause before
+// they can be processed.
+add_task(async function() {
+  const dbg = await initDebugger("doc-xhr-run-to-completion.html");
+  invokeInTab("multipleRequests", "doc-xhr-run-to-completion.html");
+  await waitForPaused(dbg);
+  assertPausedLocation(dbg);
+  resume(dbg);
+  await waitForPaused(dbg);
+  assertPausedLocation(dbg);
+  resume(dbg);
+  await waitForPaused(dbg);
+  assertPausedLocation(dbg);
+  resume(dbg);
+  await once(Services.ppmm, "test passed");
+});
new file mode 100644
--- /dev/null
+++ b/devtools/client/debugger/new/test/mochitest/examples/doc-xhr-run-to-completion.html
@@ -0,0 +1,41 @@
+ <!-- This Source Code Form is subject to the terms of the Mozilla Public
+    - License, v. 2.0. If a copy of the MPL was not distributed with this
+    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
+<!DOCTYPE html>
+<meta charset=UTF-8>
+<script>
+const cpmm = SpecialPowers.Services.cpmm;
+var result;
+
+function newXHR() {
+    var xhr = new XMLHttpRequest();
+    xhr.open('GET', 'doc-xhr-run-to-completion.html', true);
+    xhr.onload = done;
+    xhr.onerror = done;
+    xhr.onreadystatechange = done;
+    xhr.ontimeout = done;
+    xhr.send();
+}
+
+function singleRequest() {
+    result = "test failed";
+    newXHR();
+    debugger;
+    result = "test passed";
+}
+
+function multipleRequests() {
+    result = "test failed";
+    newXHR();
+    newXHR();
+    debugger;
+    newXHR();
+    debugger;
+    debugger;
+    result = "test passed";
+}
+
+function done() {
+    cpmm.sendAsyncMessage(result);
+}
+</script>