toolkit/content/tests/widgets/test_videocontrols_standalone.html

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <head>
michael@0 4 <title>Video controls test</title>
michael@0 5 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 6 <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
michael@0 7 <script type="text/javascript" src="head.js"></script>
michael@0 8 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
michael@0 9 </head>
michael@0 10 <body>
michael@0 11 <p id="display"></p>
michael@0 12
michael@0 13 <pre id="test">
michael@0 14 <script class="testbody" type="text/javascript">
michael@0 15
michael@0 16 const videoWidth = 320;
michael@0 17 const videoHeight = 240;
michael@0 18
michael@0 19 function getMediaElement(aWindow) {
michael@0 20 return aWindow.document.getElementsByTagName("video")[0];
michael@0 21 }
michael@0 22
michael@0 23 var popup = window.open("seek_with_sound.ogg");
michael@0 24 popup.addEventListener("load", function onLoad() {
michael@0 25 popup.removeEventListener("load", onLoad);
michael@0 26 var video = getMediaElement(popup);
michael@0 27 if (!video.paused)
michael@0 28 runTestVideo(video);
michael@0 29 else {
michael@0 30 video.addEventListener("play", function onPlay() {
michael@0 31 video.removeEventListener("play", onPlay);
michael@0 32 runTestVideo(video);
michael@0 33 });
michael@0 34 }
michael@0 35 });
michael@0 36
michael@0 37 function runTestVideo(aVideo) {
michael@0 38 var condition = function() {
michael@0 39 var boundingRect = aVideo.getBoundingClientRect();
michael@0 40 return boundingRect.width == videoWidth &&
michael@0 41 boundingRect.height == videoHeight;
michael@0 42 };
michael@0 43 waitForCondition(condition, function() {
michael@0 44 var boundingRect = aVideo.getBoundingClientRect();
michael@0 45 is(boundingRect.width, videoWidth, "Width of the video should match expectation");
michael@0 46 is(boundingRect.height, videoHeight, "Height of video should match expectation");
michael@0 47 popup.close();
michael@0 48 runTestAudioPre();
michael@0 49 }, "The media element should eventually be resized to match the intrinsic size of the video.");
michael@0 50 }
michael@0 51
michael@0 52 function runTestAudioPre() {
michael@0 53 popup = window.open("audio.ogg");
michael@0 54 popup.addEventListener("load", function onLoad() {
michael@0 55 popup.removeEventListener("load", onLoad);
michael@0 56 var audio = getMediaElement(popup);
michael@0 57 if (!audio.paused)
michael@0 58 runTestAudio(audio);
michael@0 59 else {
michael@0 60 audio.addEventListener("play", function onPlay() {
michael@0 61 audio.removeEventListener("play", onPlay);
michael@0 62 runTestAudio(audio);
michael@0 63 })
michael@0 64 }
michael@0 65 })
michael@0 66 }
michael@0 67
michael@0 68 function runTestAudio(aAudio) {
michael@0 69 info("User agent (help diagnose bug #943556): " + navigator.userAgent);
michael@0 70 var isAndroid = navigator.userAgent.contains("Android");
michael@0 71 var expectedHeight = isAndroid ? 123 : 28;
michael@0 72 var condition = function () {
michael@0 73 var boundingRect = aAudio.getBoundingClientRect();
michael@0 74 return boundingRect.height == expectedHeight;
michael@0 75 };
michael@0 76 waitForCondition(condition, function () {
michael@0 77 var boundingRect = aAudio.getBoundingClientRect();
michael@0 78 is(boundingRect.height, expectedHeight,
michael@0 79 "Height of audio element should be " + expectedHeight + ", which is equal to the controls bar.");
michael@0 80 popup.close();
michael@0 81 SimpleTest.finish();
michael@0 82 }, "The media element should eventually be resized to match the height of the audio controls.");
michael@0 83 }
michael@0 84
michael@0 85 SimpleTest.waitForExplicitFinish();
michael@0 86
michael@0 87 </script>
michael@0 88 </pre>
michael@0 89 </body>
michael@0 90 </html>

mercurial