mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1180824 - Tests for browser-element mozbrowsermediaplaybackchange event. r=fabrice
This commit is contained in:
parent
d78efaf293
commit
3c4be5cb24
@ -0,0 +1,75 @@
|
||||
/* Any copyright is dedicated to the public domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
// Test the mozbrowsermediaplaybackchange event is fired correctly.
|
||||
'use strict';
|
||||
|
||||
const { Services } = SpecialPowers.Cu.import('resource://gre/modules/Services.jsm');
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
browserElementTestHelpers.setEnabledPref(true);
|
||||
browserElementTestHelpers.addPermission();
|
||||
|
||||
/**
|
||||
* Content script passed to the child iframe
|
||||
*/
|
||||
function playMediaScript() {
|
||||
var audio = new content.Audio();
|
||||
content.document.body.appendChild(audio);
|
||||
audio.oncanplay = function() {
|
||||
audio.play();
|
||||
};
|
||||
audio.src = 'audio.ogg';
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a simple mozbrowser frame
|
||||
*/
|
||||
function createFrame() {
|
||||
let iframe = document.createElement('iframe');
|
||||
iframe.setAttribute('mozbrowser', 'true');
|
||||
document.body.appendChild(iframe);
|
||||
return iframe;
|
||||
}
|
||||
|
||||
function runTest() {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
let iframe = createFrame();
|
||||
let iframe2 = createFrame();
|
||||
|
||||
// When the first iframe is finished loading inject a script to create
|
||||
// an audio element and play it.
|
||||
iframe.addEventListener('mozbrowserloadend', () => {
|
||||
let mm = SpecialPowers.getBrowserFrameMessageManager(iframe);
|
||||
mm.loadFrameScript('data:,(' + playMediaScript.toString() + ')();', false);
|
||||
});
|
||||
|
||||
// Two events should come in, when the audio starts, and stops playing.
|
||||
// The first one should have a detail of 'active' and the second one
|
||||
// should have a detail of 'inactive'.
|
||||
let expectedNextData = 'active';
|
||||
iframe.addEventListener('mozbrowsermediaplaybackchange', (e) => {
|
||||
is(e.detail, expectedNextData, 'Audio detail should be correct')
|
||||
is(e.target, iframe, 'event target should be the first iframe')
|
||||
if (e.detail === 'inactive') {
|
||||
SimpleTest.finish();
|
||||
}
|
||||
expectedNextData = 'inactive';
|
||||
});
|
||||
|
||||
// Make sure an event only goes to the first iframe.
|
||||
iframe2.addEventListener('mozbrowsermediaplaybackchange', (e) => {
|
||||
ok(false,
|
||||
'mozbrowsermediaplaybackchange should dispatch to the correct browser');
|
||||
});
|
||||
|
||||
// Load a simple page to get the process started.
|
||||
iframe.src = browserElementTestHelpers.emptyPage1;
|
||||
}
|
||||
|
||||
addEventListener('testready', () => {
|
||||
// Audio channel service is needed for events
|
||||
SpecialPowers.pushPrefEnv({"set": [["media.useAudioChannelService", true]]},
|
||||
runTest);
|
||||
});
|
@ -53,6 +53,7 @@ skip-if = (toolkit == 'gonk' && !debug)
|
||||
[test_browserElement_oop_LoadEvents.html]
|
||||
[test_browserElement_oop_Manifestchange.html]
|
||||
[test_browserElement_oop_Metachange.html]
|
||||
[test_browserElement_oop_MediaPlayback.html]
|
||||
[test_browserElement_oop_OpenMixedProcess.html]
|
||||
skip-if = (toolkit == 'gonk' && !debug)
|
||||
[test_browserElement_oop_OpenNamed.html]
|
||||
|
@ -39,6 +39,7 @@ support-files =
|
||||
browserElement_LoadEvents.js
|
||||
browserElement_Manifestchange.js
|
||||
browserElement_Metachange.js
|
||||
browserElement_MediaPlayback.js
|
||||
browserElement_NextPaint.js
|
||||
browserElement_OpenNamed.js
|
||||
browserElement_OpenTab.js
|
||||
@ -175,6 +176,7 @@ skip-if = (toolkit == 'android' && processor == 'x86') #x86 only
|
||||
[test_browserElement_inproc_LoadEvents.html]
|
||||
[test_browserElement_inproc_Manifestchange.html]
|
||||
[test_browserElement_inproc_Metachange.html]
|
||||
[test_browserElement_inproc_MediaPlayback.html]
|
||||
[test_browserElement_inproc_NextPaint.html]
|
||||
[test_browserElement_inproc_OpenNamed.html]
|
||||
skip-if = (toolkit == 'gonk' && !debug)
|
||||
|
@ -0,0 +1,18 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1180824
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 1180824</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>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1180824">Mozilla Bug 1180824</a>
|
||||
|
||||
<script type="application/javascript;version=1.7" src="browserElement_MediaPlayback.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,18 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1180824
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 1180824</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>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1180824">Mozilla Bug 1180824</a>
|
||||
|
||||
<script type="application/javascript;version=1.7" src="browserElement_MediaPlayback.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user