forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1674845 - part4 : add 'browser' subfolder for autoplay browser te…
…sts. r=bryce subsuite media for browser tests. Differential Revision: https://phabricator.services.mozilla.com/D95881
- Loading branch information
1 parent
89a2733
commit af08036
Showing
19 changed files
with
169 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
[DEFAULT] | ||
skip-if = (os == "win" && processor == "aarch64") # aarch64 due to 1536573 | ||
subsuite = media | ||
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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
...ser/browser_autoplay_policy_play_twice.js → ...ser/browser_autoplay_policy_play_twice.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
.../browser_autoplay_policy_user_gestures.js → .../browser_autoplay_policy_user_gestures.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
3 changes: 1 addition & 2 deletions
3
...browser/browser_autoplay_videoDocument.js → ...browser/browser_autoplay_videoDocument.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Page left intentionally blank...</title> | ||
</head> | ||
<body> | ||
</body> | ||
</html> |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>video</title> | ||
</head> | ||
<body> | ||
<video id="v" src="gizmo.mp4" controls loop></video> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters