Bug 1375562 - Test the interaction of AudioContext::Suspend and breakpoints. r?jlast draft
authorPaul Adenot <paul@paul.cx>
Tue, 01 Aug 2017 16:13:27 +0200
changeset 619075 b6b2a6deeb2437fcf7f6ed06e63914e372316336
parent 619074 107e94bfdbd25e3aaa3e0c417fed80fcefdde008
child 640289 ea17ea5397c48c6b3db811d4fad3a8dc17738765
push id71564
push userpaul@paul.cx
push dateTue, 01 Aug 2017 14:33:06 +0000
reviewersjlast
bugs1375562
milestone56.0a1
Bug 1375562 - Test the interaction of AudioContext::Suspend and breakpoints. r?jlast MozReview-Commit-ID: Kr0wm999b9S
devtools/client/debugger/test/mochitest/browser2.ini
devtools/client/debugger/test/mochitest/browser_dbg_audiocontext.js
devtools/client/debugger/test/mochitest/doc_audiocontext.html
--- a/devtools/client/debugger/test/mochitest/browser2.ini
+++ b/devtools/client/debugger/test/mochitest/browser2.ini
@@ -122,16 +122,17 @@ support-files =
   doc_watch-expressions.html
   doc_watch-expression-button.html
   doc_whitespace-property-names.html
   doc_with-frame.html
   doc_worker-source-map.html
   doc_WorkerActor.attach-tab1.html
   doc_WorkerActor.attach-tab2.html
   doc_WorkerActor.attachThread-tab.html
+  doc_audiocontext.html
   head.js
   sjs_post-page.sjs
   sjs_random-javascript.sjs
   testactors.js
   !/devtools/client/commandline/test/helpers.js
   !/devtools/client/framework/test/shared-head.js
 
 [browser_dbg_no-dangling-breakpoints.js]
@@ -457,8 +458,10 @@ skip-if = e10s && debug
 [browser_dbg_worker-window.js]
 skip-if = e10s && debug
 [browser_dbg_WorkerActor.attach.js]
 skip-if = e10s && debug
 [browser_dbg_WorkerActor.attachThread.js]
 skip-if = e10s && debug
 [browser_dbg_split-console-keypress.js]
 skip-if = (debug || os == "linux") # Bug 1214439
+[browser_dbg_audiocontext.js]
+skip-if = e10s && debug
new file mode 100644
--- /dev/null
+++ b/devtools/client/debugger/test/mochitest/browser_dbg_audiocontext.js
@@ -0,0 +1,47 @@
+/* -*- 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/ */
+
+// Test the AudioContext are paused and resume appropriately when using the
+// debugger.
+
+function test() {
+  Task.spawn(function* () {
+    const TAB_URL = EXAMPLE_URL + "doc_audiocontext.html";
+    let gDebugger, searchBox;
+
+    let options = {
+      source: TAB_URL,
+      line: 1
+    };
+    let [tab, debuggee, panel] = yield initDebugger(TAB_URL, options);
+    gDebugger = panel.panelWin;
+    searchBox = gDebugger.DebuggerView.Filtering._searchbox;
+
+    let onThreadPaused = ensureThreadClientState(panel, "paused");
+
+    yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
+      content.document.querySelector("#start").click();
+    });
+
+    yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
+      content.document.querySelector("#suspend").click();
+    });
+
+    ContentTask.spawn(tab.linkedBrowser, {}, function* () {
+      content.document.querySelector("#break").click();
+    });
+
+    yield onThreadPaused;
+
+    yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
+      content.document.querySelector("#check").click();
+    });
+
+    yield resumeDebuggerThenCloseAndFinish(panel);
+  }).catch(aError => {
+    ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
+  });
+}
+
new file mode 100644
--- /dev/null
+++ b/devtools/client/debugger/test/mochitest/doc_audiocontext.html
@@ -0,0 +1,48 @@
+<!-- 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 id="start" onclick="myFunction()">start ac</button>
+<button id="suspend" onclick="suspendAC()">suspend ac</button>
+<button id="break" onclick="debuggerStatement()">break</button>
+<button id="check" onclick="checkACState()">check ac state</button>
+<script type="text/javascript">
+var ac = null;
+var suspend_called = false;
+function suspendAC() {
+  suspend_called = true;
+  ac.suspend();
+}
+
+function debuggerStatement() {
+  debugger;
+}
+
+function checkACState() {
+  if (ac.state != "suspended") {
+    throw "AudioContext should be suspended.";
+  }
+}
+
+function myFunction() {
+  ac = new AudioContext();
+  function statechange_suspend() {
+    ac.onstatechange = statechange_fail;
+  }
+  function statechange_fail() {
+    throw "No state change should occur when paused in the debugger.";
+  }
+  ac.onstatechange = function() {
+    ac.onstatechange = statechange_suspend;
+  }
+}
+</script>
+</body>
+</html>