Bug 1225425 - [Testcase] Do not unregister the AudioChannelAgent during seeking. r=baku
☠☠ backed out by 31c319b09ec0 ☠ ☠
authorAlastor Wu <alwu@mozilla.com>
Thu, 07 Jan 2016 01:21:05 +0800
changeset 278913 fc20ecea0409c0434ef50f24cbd28d2ed55d48f3
parent 278912 bedd35d9ebe637a9a06e6c3f1499f3b3a724f1c3
child 278914 a768e46f4e58575950e70eec400bf7bf40dcd40f
push id29860
push usercbook@mozilla.com
push dateThu, 07 Jan 2016 10:51:20 +0000
treeherdermozilla-central@e0bcd16e1d4b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1225425
milestone46.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 1225425 - [Testcase] Do not unregister the AudioChannelAgent during seeking. r=baku
dom/browser-element/mochitest/browserElement_AudioChannelSeeking.js
dom/browser-element/mochitest/file_browserElement_AudioChannelSeeking.html
dom/browser-element/mochitest/mochitest-oop.ini
dom/browser-element/mochitest/mochitest.ini
dom/browser-element/mochitest/test_browserElement_inproc_AudioChannelSeeking.html
dom/browser-element/mochitest/test_browserElement_oop_AudioChannelSeeking.html
new file mode 100644
--- /dev/null
+++ b/dom/browser-element/mochitest/browserElement_AudioChannelSeeking.js
@@ -0,0 +1,118 @@
+"use strict";
+
+SimpleTest.waitForExplicitFinish();
+browserElementTestHelpers.setEnabledPref(true);
+browserElementTestHelpers.addPermission();
+
+var fileURL = 'http://example.org/tests/dom/browser-element/mochitest/file_browserElement_AudioChannelSeeking.html';
+var generator = runTests();
+var testFrame;
+var ac;
+
+function alertListener(e) {
+  var message = e.detail.message
+  if (/^OK/.exec(message)) {
+    ok(true, "Message from file : " + message);
+    continueTest();
+  } else if (/^KO/.exec(message)) {
+    error(message);
+  } else {
+    error("Undefined event.");
+  }
+}
+
+function assert(aVal, aMessage) {
+  return (!aVal) ? error(aMessage) : 0;
+}
+
+function error(aMessage) {
+  ok(false, "Error : " + aMessage);
+  finish();
+}
+
+function continueTest() {
+  try {
+    generator.next();
+  } catch (e if e instanceof StopIteration) {
+    error("Stop test because of exception!");
+  }
+}
+
+function finish() {
+  testFrame.removeEventListener('mozbrowsershowmodalprompt', alertListener);
+  document.body.removeChild(testFrame);
+  SimpleTest.finish();
+}
+
+function setCommand(aArg) {
+  assert(!!ac, "Audio channel doesn't exist!");
+  info("# Command = " + aArg);
+  testFrame.src = fileURL + '#' + aArg;
+
+  switch (aArg) {
+    case 'play':
+      break;
+    case 'seeking':
+      ac.onactivestatechanged = () => {
+        ac.onactivestatechanged = null;
+        error("Should not receive onactivestatechanged!");
+      };
+      break;
+    case 'pause':
+      ac.onactivestatechanged = null;
+      break;
+    default :
+      error("Undefined command!");
+  }
+}
+
+function runTests() {
+  setCommand('play');
+  yield undefined;
+
+  setCommand('seeking');
+  yield undefined;
+
+  setCommand('seeking');
+  yield undefined;
+
+  setCommand('seeking');
+  yield undefined;
+
+  setCommand('pause');
+  yield undefined;
+
+  finish();
+  yield undefined;
+}
+
+function setupTestFrame() {
+  testFrame = document.createElement('iframe');
+  testFrame.setAttribute('mozbrowser', 'true');
+  testFrame.setAttribute('mozapp', 'http://example.org/manifest.webapp');
+  testFrame.src = fileURL;
+
+  function loadend() {
+    testFrame.removeEventListener('mozbrowserloadend', loadend);
+    ok("allowedAudioChannels" in testFrame, "allowedAudioChannels exist");
+    var channels = testFrame.allowedAudioChannels;
+    is(channels.length, 1, "1 audio channel by default");
+
+    ac = channels[0];
+    ok(ac instanceof BrowserElementAudioChannel, "Correct class");
+    ok("onactivestatechanged" in ac, "onactivestatechanged exists");
+
+    continueTest();
+  }
+
+  testFrame.addEventListener('mozbrowsershowmodalprompt', alertListener);
+  testFrame.addEventListener('mozbrowserloadend', loadend);
+  document.body.appendChild(testFrame);
+}
+
+addEventListener('testready', function() {
+  SpecialPowers.pushPrefEnv({'set': [["b2g.system_manifest_url", "http://mochi.test:8888/manifest.webapp"]]},
+                            function() {
+    SimpleTest.executeSoon(setupTestFrame);
+  });
+});
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/dom/browser-element/mochitest/file_browserElement_AudioChannelSeeking.html
@@ -0,0 +1,58 @@
+<!DOCTYPE HTML>
+<html>
+<body>
+<script type="application/javascript;version=1.7">
+var audio = new Audio();
+audio.src = "audio.ogg";
+audio.loop = true;
+
+function assert(aVal, aMessage) {
+  return (!aVal) ? ok(false, aMessage) : 0;
+}
+
+function ok(aVal, aMsg) {
+  alert((!!aVal ? "OK" : "KO") + ", " + aMsg);
+}
+
+function randomSeeking() {
+  var seekingPosition = Math.random() * audio.duration;
+  assert(seekingPosition < audio.duration, "Seeking position out of range!")
+  audio.currentTime = seekingPosition;
+  audio.onseeked = () => {
+    audio.onseeked = null;
+    location.hash = '#idle';
+    ok(true, "Seeking complete, position = " + seekingPosition);
+  };
+}
+
+function runCommands()
+{
+  switch(location.hash) {
+    case '#play':
+      audio.play();
+      audio.onplay = () => {
+        audio.onplay = null;
+        ok(true, "Start playing, duration = " + audio.duration);
+      };
+      break;
+    case '#seeking':
+      randomSeeking();
+      break;
+    case '#pause':
+      audio.pause();
+      audio.onpause = () => {
+        audio.onpause = null;
+        ok(true, "Stop playing.");
+      };
+      break;
+    case '#idle':
+      break;
+    default :
+      ok(false, "Undefined command!");
+  }
+}
+
+window.addEventListener('hashchange', runCommands);
+</script>
+</body>
+</html>
\ No newline at end of file
--- a/dom/browser-element/mochitest/mochitest-oop.ini
+++ b/dom/browser-element/mochitest/mochitest-oop.ini
@@ -7,16 +7,17 @@ skip-if = os == "android" || (toolkit ==
 support-files =
   browserElement_OpenMixedProcess.js
   file_browserElement_ExecuteScript.html
   file_browserElement_OpenMixedProcess.html
   browserElement_ExecuteScript.js
   browserElement_Find.js
   browserElement_OpenTab.js
 
+[test_browserElement_oop_AudioChannelSeeking.html]
 [test_browserElement_oop_getStructuredData.html]
 [test_browserElement_oop_Viewmode.html]
 [test_browserElement_oop_ThemeColor.html]
 [test_browserElement_inproc_ErrorSecurity.html]
 skip-if = toolkit=='gonk'
 [test_browserElement_inproc_OpenMixedProcess.html]
 skip-if = toolkit=='gonk' || (toolkit == 'gonk' && !debug)
 [test_browserElement_oop_Alert.html]
--- a/dom/browser-element/mochitest/mochitest.ini
+++ b/dom/browser-element/mochitest/mochitest.ini
@@ -6,16 +6,17 @@ support-files =
   async.js
   browserElementTestHelpers.js
   browserElement_ActiveStateChangeOnChangingMutedOrVolume.js
   browserElement_Alert.js
   browserElement_AlertInFrame.js
   browserElement_AllowEmbedAppsInNestedOOIframe.js
   browserElement_AppFramePermission.js
   browserElement_AppWindowNamespace.js
+  browserElement_AudioChannelSeeking.js
   browserElement_AudioChannelMutedByDefault.js
   browserElement_AudioPlayback.js
   browserElement_Auth.js
   browserElement_BackForward.js
   browserElement_BadScreenshot.js
   browserElement_Viewmode.js
   browserElement_ThemeColor.js
   browserElement_BrowserWindowNamespace.js
@@ -87,16 +88,17 @@ support-files =
   browserElement_AudioChannel.js
   browserElement_AudioChannel_nested.js
   file_browserElement_ActiveStateChangeOnChangingMutedOrVolume.html
   file_browserElement_AlertInFrame.html
   file_browserElement_AlertInFrame_Inner.html
   file_browserElement_AllowEmbedAppsInNestedOOIframe.html
   file_browserElement_AppFramePermission.html
   file_browserElement_AppWindowNamespace.html
+  file_browserElement_AudioChannelSeeking.html
   file_browserElement_AudioChannel_nested.html
   file_browserElement_AudioChannelMutedByDefault.html
   file_browserElement_Viewmode.html
   file_browserElement_ThemeColor.html
   file_browserElement_BrowserWindowNamespace.html
   file_browserElement_CloseApp.html
   file_browserElement_CloseFromOpener.html
   file_browserElement_CookiesNotThirdParty.html
@@ -152,16 +154,17 @@ support-files =
 # Note: browserElementTestHelpers.js looks at the test's filename to determine
 # whether the test should be OOP.  "_oop_" signals OOP, "_inproc_" signals in
 # process.  Default is OOP.
 [test_browserElement_inproc_getWebManifest.html]
 [test_browserElement_NoAttr.html]
 [test_browserElement_NoPref.html]
 [test_browserElement_NoPermission.html]
 [test_browserElement_inproc_Alert.html]
+[test_browserElement_inproc_AudioChannelSeeking.html]
 [test_browserElement_inproc_Viewmode.html]
 [test_browserElement_inproc_ThemeColor.html]
 skip-if = buildapp == 'b2g'
 [test_browserElement_inproc_AlertInFrame.html]
 [test_browserElement_inproc_AppFramePermission.html]
 skip-if = toolkit == 'android' || buildapp == 'b2g'
 [test_browserElement_inproc_AppWindowNamespace.html]
 skip-if = toolkit == 'android' || buildapp == 'b2g' # android(TIMED_OUT, bug 783509) androidx86(TIMED_OUT, bug 783509)
new file mode 100644
--- /dev/null
+++ b/dom/browser-element/mochitest/test_browserElement_inproc_AudioChannelSeeking.html
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Bug 1227051 - Do not unregister the AudioChannelAgent during seeking</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="browserElementTestHelpers.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<script type="application/javascript;version=1.7" src="browserElement_AudioChannelSeeking.js">
+</script>
+</body>
+</html>
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/dom/browser-element/mochitest/test_browserElement_oop_AudioChannelSeeking.html
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <title>Bug 1227051 - Do not unregister the AudioChannelAgent during seeking</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="browserElementTestHelpers.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<script type="application/javascript;version=1.7" src="browserElement_AudioChannelSeeking.js">
+</script>
+</body>
+</html>
\ No newline at end of file