зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1674845 - part4 : add 'browser' subfolder for autoplay browser tests. r=bryce
subsuite media for browser tests. Differential Revision: https://phabricator.services.mozilla.com/D95881
This commit is contained in:
Родитель
31f03aa534
Коммит
0c0c2f3994
|
@ -25,6 +25,8 @@ XPIDL_SOURCES += [
|
|||
|
||||
MOCHITEST_MANIFESTS += ["test/mochitest/mochitest.ini"]
|
||||
|
||||
BROWSER_CHROME_MANIFESTS += ["test/browser/browser.ini"]
|
||||
|
||||
include("/ipc/chromium/chromium-config.mozbuild")
|
||||
|
||||
FINAL_LIBRARY = "xul"
|
||||
|
|
Двоичный файл не отображается.
|
@ -0,0 +1,22 @@
|
|||
[DEFAULT]
|
||||
skip-if = (os == "win" && processor == "aarch64") # aarch64 due to 1536573
|
||||
tags = autoplay
|
||||
support-files =
|
||||
../../../test/gizmo.mp4
|
||||
audio.ogg
|
||||
file_empty.html
|
||||
file_mediaplayback_frame.html
|
||||
file_nonAutoplayAudio.html
|
||||
file_video.html
|
||||
head.js
|
||||
|
||||
[browser_autoplay_policy.js]
|
||||
[browser_autoplay_policy_play_twice.js]
|
||||
[browser_autoplay_policy_user_gestures.js]
|
||||
[browser_autoplay_policy_request_permission.js]
|
||||
[browser_autoplay_policy_touchScroll.js]
|
||||
[browser_autoplay_policy_web_audio.js]
|
||||
[browser_autoplay_policy_web_audio_with_gum.js]
|
||||
[browser_autoplay_policy_webRTC_permission.js]
|
||||
skip-if = true # Bug 1518429
|
||||
[browser_autoplay_videoDocument.js]
|
|
@ -3,8 +3,7 @@
|
|||
* under different situations.
|
||||
* Spec discussion : https://github.com/WICG/autoplay/issues/1
|
||||
*/
|
||||
const PAGE =
|
||||
"https://example.com/browser/toolkit/content/tests/browser/file_empty.html";
|
||||
const PAGE = GetTestWebBasedURL("file_empty.html");
|
||||
|
||||
function setupTestPreferences(isAllowedAutoplay, isAllowedMuted) {
|
||||
let autoplayDefault = SpecialPowers.Ci.nsIAutoplay.ALLOWED;
|
|
@ -1,5 +1,4 @@
|
|||
const VIDEO_PAGE =
|
||||
"https://example.com/browser/toolkit/content/tests/browser/file_video.html";
|
||||
const VIDEO_PAGE = GetTestWebBasedURL("file_video.html");
|
||||
|
||||
function setup_test_preference(enableUserGesture) {
|
||||
let state = enableUserGesture ? "enable" : "disable";
|
|
@ -8,12 +8,14 @@ const { PermissionTestUtils } = ChromeUtils.import(
|
|||
"resource://testing-common/PermissionTestUtils.jsm"
|
||||
);
|
||||
|
||||
const VIDEO_PAGE_URI =
|
||||
"https://example.com/browser/toolkit/content/tests/browser/file_empty.html";
|
||||
const SAME_ORIGIN_FRAME_URI =
|
||||
"https://example.com/browser/toolkit/content/tests/browser/file_mediaplayback_frame.html";
|
||||
const DIFFERENT_ORIGIN_FRAME_URI =
|
||||
"https://example.org/browser/toolkit/content/tests/browser/file_mediaplayback_frame.html";
|
||||
const VIDEO_PAGE_URI = GetTestWebBasedURL("file_empty.html");
|
||||
const SAME_ORIGIN_FRAME_URI = GetTestWebBasedURL(
|
||||
"file_mediaplayback_frame.html"
|
||||
);
|
||||
const DIFFERENT_ORIGIN_FRAME_URI = GetTestWebBasedURL(
|
||||
"file_mediaplayback_frame.html",
|
||||
{ crossOrigin: true }
|
||||
);
|
||||
|
||||
const gPermissionName = "autoplay-media";
|
||||
|
|
@ -5,8 +5,7 @@
|
|||
/* eslint-disable mozilla/no-arbitrary-setTimeout */
|
||||
"use strict";
|
||||
|
||||
const PAGE =
|
||||
"https://example.com/browser/toolkit/content/tests/browser/file_nonAutoplayAudio.html";
|
||||
const PAGE = GetTestWebBasedURL("file_nonAutoplayAudio.html");
|
||||
|
||||
function checkMediaPlayingState(isPlaying) {
|
||||
let audio = content.document.getElementById("testAudio");
|
|
@ -1,7 +1,6 @@
|
|||
/* eslint-disable mozilla/no-arbitrary-setTimeout */
|
||||
|
||||
const VIDEO_PAGE =
|
||||
"https://example.com/browser/toolkit/content/tests/browser/file_video.html";
|
||||
const VIDEO_PAGE = GetTestWebBasedURL("file_video.html");
|
||||
|
||||
const UserGestures = {
|
||||
MOUSE_CLICK: "mouse-click",
|
|
@ -8,8 +8,7 @@ const { PermissionTestUtils } = ChromeUtils.import(
|
|||
"resource://testing-common/PermissionTestUtils.jsm"
|
||||
);
|
||||
|
||||
const VIDEO_PAGE =
|
||||
"https://example.com/browser/toolkit/content/tests/browser/file_empty.html";
|
||||
const VIDEO_PAGE = GetTestWebBasedURL("file_empty.html");
|
||||
|
||||
add_task(() => {
|
||||
return SpecialPowers.pushPrefEnv({
|
|
@ -12,8 +12,7 @@ const { PermissionTestUtils } = ChromeUtils.import(
|
|||
"resource://testing-common/PermissionTestUtils.jsm"
|
||||
);
|
||||
|
||||
const PAGE =
|
||||
"https://example.com/browser/toolkit/content/tests/browser/file_empty.html";
|
||||
const PAGE = GetTestWebBasedURL("file_empty.html");
|
||||
|
||||
function setup_test_preference() {
|
||||
return SpecialPowers.pushPrefEnv({
|
|
@ -1,7 +1,6 @@
|
|||
"use strict";
|
||||
|
||||
const PAGE =
|
||||
"https://example.com/browser/toolkit/content/tests/browser/audio.ogg";
|
||||
const PAGE = GetTestWebBasedURL("audio.ogg");
|
||||
|
||||
function setup_test_preference() {
|
||||
return SpecialPowers.pushPrefEnv({
|
|
@ -0,0 +1,8 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Page left intentionally blank...</title>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<head>
|
||||
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
|
||||
<meta content="utf-8" http-equiv="encoding">
|
||||
</head>
|
||||
<body>
|
||||
<audio id="testAudio" src="audio.ogg" loop></audio>
|
|
@ -0,0 +1,9 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>video</title>
|
||||
</head>
|
||||
<body>
|
||||
<video id="v" src="gizmo.mp4" controls loop></video>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,105 @@
|
|||
/**
|
||||
* Return a web-based URL for a given file based on the testing directory.
|
||||
* @param {String} fileName
|
||||
* file that caller wants its web-based url
|
||||
* @param {Boolean} crossOrigin [optional]
|
||||
* if set, then return a url with different origin. The default value is
|
||||
* false.
|
||||
*/
|
||||
function GetTestWebBasedURL(fileName, { crossOrigin = false } = {}) {
|
||||
const origin = crossOrigin ? "http://example.org" : "http://example.com";
|
||||
return (
|
||||
getRootDirectory(gTestPath).replace("chrome://mochitests/content", origin) +
|
||||
fileName
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs a content script that creates an autoplay video.
|
||||
* @param {browserElement} browser
|
||||
* the browser to run the script in
|
||||
* @param {object} args
|
||||
* test case definition, required members
|
||||
* {
|
||||
* mode: String, "autoplay attribute" or "call play".
|
||||
* }
|
||||
*/
|
||||
function loadAutoplayVideo(browser, args) {
|
||||
return SpecialPowers.spawn(browser, [args], async args => {
|
||||
info("- create a new autoplay video -");
|
||||
let video = content.document.createElement("video");
|
||||
video.id = "v1";
|
||||
video.didPlayPromise = new Promise((resolve, reject) => {
|
||||
video.addEventListener(
|
||||
"playing",
|
||||
e => {
|
||||
video.didPlay = true;
|
||||
resolve();
|
||||
},
|
||||
{ once: true }
|
||||
);
|
||||
video.addEventListener(
|
||||
"blocked",
|
||||
e => {
|
||||
video.didPlay = false;
|
||||
resolve();
|
||||
},
|
||||
{ once: true }
|
||||
);
|
||||
});
|
||||
if (args.mode == "autoplay attribute") {
|
||||
info("autoplay attribute set to true");
|
||||
video.autoplay = true;
|
||||
} else if (args.mode == "call play") {
|
||||
info("will call play() when reached loadedmetadata");
|
||||
video.addEventListener(
|
||||
"loadedmetadata",
|
||||
e => {
|
||||
video.play().then(
|
||||
() => {
|
||||
info("video play() resolved");
|
||||
},
|
||||
() => {
|
||||
info("video play() rejected");
|
||||
}
|
||||
);
|
||||
},
|
||||
{ once: true }
|
||||
);
|
||||
} else {
|
||||
ok(false, "Invalid 'mode' arg");
|
||||
}
|
||||
video.src = "gizmo.mp4";
|
||||
content.document.body.appendChild(video);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs a content script that checks whether the video created by
|
||||
* loadAutoplayVideo() started playing.
|
||||
* @param {browserElement} browser
|
||||
* the browser to run the script in
|
||||
* @param {object} args
|
||||
* test case definition, required members
|
||||
* {
|
||||
* name: String, description of test.
|
||||
* mode: String, "autoplay attribute" or "call play".
|
||||
* shouldPlay: boolean, whether video should play.
|
||||
* }
|
||||
*/
|
||||
function checkVideoDidPlay(browser, args) {
|
||||
return SpecialPowers.spawn(browser, [args], async args => {
|
||||
let video = content.document.getElementById("v1");
|
||||
await video.didPlayPromise;
|
||||
is(
|
||||
video.didPlay,
|
||||
args.shouldPlay,
|
||||
args.name +
|
||||
" should " +
|
||||
(!args.shouldPlay ? "not " : "") +
|
||||
"be able to autoplay"
|
||||
);
|
||||
video.src = "";
|
||||
content.document.body.remove(video);
|
||||
});
|
||||
}
|
|
@ -8,12 +8,12 @@ support-files =
|
|||
empty.png
|
||||
file_almostSilentAudioTrack.html
|
||||
file_contentTitle.html
|
||||
file_empty.html
|
||||
file_findinframe.html
|
||||
file_mediaPlayback.html
|
||||
file_mediaPlayback2.html
|
||||
file_mediaPlaybackFrame.html
|
||||
file_mediaPlaybackFrame2.html
|
||||
file_mediaplayback_frame.html
|
||||
file_multipleAudio.html
|
||||
file_multiplePlayingAudio.html
|
||||
file_nonAutoplayAudio.html
|
||||
|
@ -27,40 +27,6 @@ support-files =
|
|||
image_page.html
|
||||
silentAudioTrack.webm
|
||||
|
||||
[browser_autoplay_policy.js]
|
||||
support-files =
|
||||
file_empty.html
|
||||
skip-if = (os == "win" && processor == "aarch64") # aarch64 due to 1536573
|
||||
[browser_autoplay_policy_play_twice.js]
|
||||
support-files =
|
||||
gizmo.mp4
|
||||
file_video.html
|
||||
skip-if = (os == "win" && processor == "aarch64") # aarch64 due to 1536573
|
||||
[browser_autoplay_policy_request_permission.js]
|
||||
support-files =
|
||||
file_empty.html
|
||||
gizmo.mp4
|
||||
skip-if = (os == "win" && processor == "aarch64") # aarch64 due to 1536573
|
||||
[browser_autoplay_policy_user_gestures.js]
|
||||
support-files =
|
||||
gizmo.mp4
|
||||
file_video.html
|
||||
skip-if = (os == "win" && processor == "aarch64") # aarch64 due to 1536573
|
||||
[browser_autoplay_policy_touchScroll.js]
|
||||
skip-if = (os == "win" && processor == "aarch64") # aarch64 due to 1536573
|
||||
[browser_autoplay_policy_web_audio.js]
|
||||
support-files =
|
||||
file_empty.html
|
||||
skip-if = (os == "win" && processor == "aarch64") # aarch64 due to 1536573
|
||||
[browser_autoplay_policy_web_audio_with_gum.js]
|
||||
skip-if = (os == "win" && processor == "aarch64") # aarch64 due to 1536573
|
||||
[browser_autoplay_policy_webRTC_permission.js]
|
||||
skip-if = true # Bug 1518429
|
||||
support-files =
|
||||
file_empty.html
|
||||
gizmo.mp4
|
||||
[browser_autoplay_videoDocument.js]
|
||||
skip-if = (os == "win" && processor == "aarch64") # aarch64 due to 1536573
|
||||
[browser_autoscroll_disabled.js]
|
||||
skip-if = true # Bug 1312652
|
||||
[browser_delay_autoplay_media.js]
|
||||
|
|
|
@ -279,87 +279,6 @@ function once(target, name) {
|
|||
return p;
|
||||
}
|
||||
|
||||
// Runs a content script that creates an autoplay video.
|
||||
// browser: the browser to run the script in.
|
||||
// args: test case definition, required members {
|
||||
// mode: String, "autoplay attribute" or "call play".
|
||||
// }
|
||||
function loadAutoplayVideo(browser, args) {
|
||||
return SpecialPowers.spawn(browser, [args], async args => {
|
||||
info("- create a new autoplay video -");
|
||||
let video = content.document.createElement("video");
|
||||
video.id = "v1";
|
||||
video.didPlayPromise = new Promise((resolve, reject) => {
|
||||
video.addEventListener(
|
||||
"playing",
|
||||
e => {
|
||||
video.didPlay = true;
|
||||
resolve();
|
||||
},
|
||||
{ once: true }
|
||||
);
|
||||
video.addEventListener(
|
||||
"blocked",
|
||||
e => {
|
||||
video.didPlay = false;
|
||||
resolve();
|
||||
},
|
||||
{ once: true }
|
||||
);
|
||||
});
|
||||
if (args.mode == "autoplay attribute") {
|
||||
info("autoplay attribute set to true");
|
||||
video.autoplay = true;
|
||||
} else if (args.mode == "call play") {
|
||||
info("will call play() when reached loadedmetadata");
|
||||
video.addEventListener(
|
||||
"loadedmetadata",
|
||||
e => {
|
||||
video.play().then(
|
||||
() => {
|
||||
info("video play() resolved");
|
||||
},
|
||||
() => {
|
||||
info("video play() rejected");
|
||||
}
|
||||
);
|
||||
},
|
||||
{ once: true }
|
||||
);
|
||||
} else {
|
||||
ok(false, "Invalid 'mode' arg");
|
||||
}
|
||||
video.src = "gizmo.mp4";
|
||||
content.document.body.appendChild(video);
|
||||
});
|
||||
}
|
||||
|
||||
// Runs a content script that checks whether the video created by
|
||||
// loadAutoplayVideo() started playing.
|
||||
// Parameters:
|
||||
// browser: the browser to run the script in.
|
||||
// args: test case definition, required members {
|
||||
// name: String, description of test.
|
||||
// mode: String, "autoplay attribute" or "call play".
|
||||
// shouldPlay: boolean, whether video should play.
|
||||
// }
|
||||
function checkVideoDidPlay(browser, args) {
|
||||
return SpecialPowers.spawn(browser, [args], async args => {
|
||||
let video = content.document.getElementById("v1");
|
||||
await video.didPlayPromise;
|
||||
is(
|
||||
video.didPlay,
|
||||
args.shouldPlay,
|
||||
args.name +
|
||||
" should " +
|
||||
(!args.shouldPlay ? "not " : "") +
|
||||
"be able to autoplay"
|
||||
);
|
||||
video.src = "";
|
||||
content.document.body.remove(video);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* check if current wakelock is equal to expected state, if not, then wait until
|
||||
* the wakelock changes its state to expected state.
|
||||
|
|
Загрузка…
Ссылка в новой задаче