Bug 1375562 - Test the interaction of AudioContext::Suspend and breakpoints. r?jlast
MozReview-Commit-ID: Kr0wm999b9S
--- 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>