Bug 1394683 - mochitest for fullscreen video orientation lock/unlock. r?ralin
MozReview-Commit-ID: 8VV6TApPSFV
--- a/toolkit/content/tests/widgets/mochitest.ini
+++ b/toolkit/content/tests/widgets/mochitest.ini
@@ -44,8 +44,10 @@ skip-if = toolkit == 'android' # bug 107
[test_videocontrols_video_direction.html]
skip-if = os == 'win'
[test_videocontrols_video_noaudio.html]
skip-if = toolkit == 'android'
[test_bug1319301.html]
skip-if = toolkit == 'android'
[test_bug898940.html]
[test_videocontrols_error.html]
+[test_videocontrols_orientation.html]
+skip-if = toolkit != 'android'
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/toolkit/content/tests/widgets/test_videocontrols_orientation.html
@@ -0,0 +1,62 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <title>Video controls test</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<p id="display"></p>
+
+<div id="content">
+ <video id="video" controls mozNoDynamicControls preload="metadata"></video>
+</div>
+
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+SimpleTest.waitForExplicitFinish();
+var video = document.getElementById("video");
+
+let onLoaded = event => {
+ SpecialPowers.pushPrefEnv(
+ {"set": [["full-screen-api.allow-trusted-requests-only", false]]},
+ startMediaLoad);
+}
+window.addEventListener("load", onLoaded);
+
+let startMediaLoad = () => {
+ // Kick off test once video has loaded, in its canplaythrough event handler.
+ video.src = "video.ogg";
+ video.addEventListener("canplaythrough", runTest);
+}
+
+function runTest() {
+ is(document.fullscreenElement, null, "should not be in fullscreen initially");
+ isnot(window.screen.orientation.type, "landscape-primary", "should not be in landscape");
+ isnot(window.screen.orientation.type, "landscape-secondary", "should not be in landscape");
+
+ let originalOnChange = window.screen.orientation.onchange;
+
+ window.screen.orientation.onchange = () => {
+ is(document.fullscreenElement, video);
+ ok(window.screen.orientation.type === "landscape-primary" ||
+ window.screen.orientation.type === "landscape-secondary", "should be in landscape");
+
+ window.screen.orientation.onchange = () => {
+ window.screen.orientation.onchange = originalOnChange;
+ isnot(window.screen.orientation.type, "landscape-primary", "should not be in landscape");
+ isnot(window.screen.orientation.type, "landscape-secondary", "should not be in landscape");
+ SimpleTest.finish();
+ };
+ document.mozCancelFullScreen();
+ };
+
+ video.mozRequestFullScreen();
+}
+
+</script>
+</pre>
+</body>
+</html>