Commit cc652315 authored by Florin Strugariu's avatar Florin Strugariu
Browse files

Bug 1593674 - remove marionette VideoStream YouTube test as it's duplicated...

Bug 1593674 - remove marionette VideoStream  YouTube test as it's duplicated in raptor r=tarek,marionette-reviewers,whimboo

Differential Revision: https://phabricator.services.mozilla.com/D52820

--HG--
extra : moz-landing-system : lando
parent f6563c0c
......@@ -149,8 +149,6 @@ dom/encoding/test/file_utf16_be_bom.js
dom/encoding/test/file_utf16_le_bom.js
# Not parsable
dom/media/test/marionette/yttest/duration_test.js
dom/media/test/marionette/yttest/until_end_test.js
dom/tests/mochitest/general/test_focusrings.xul
dom/html/test/test_bug677658.html
......
......@@ -380,7 +380,3 @@ if CONFIG['CC_TYPE'] in ('clang', 'gcc'):
]
FINAL_LIBRARY = 'xul'
MARIONETTE_DOM_MEDIA_MANIFESTS += [
'test/marionette/manifest.ini'
]
[DEFAULT]
run-if = buildapp == 'browser'
[test_youtube.py]
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
import sys
import os
sys.path.append(os.path.dirname(__file__))
from yttest.support import VideoStreamTestCase
class YoutubeTest(VideoStreamTestCase):
# bug 1513511
def test_stream_4K(self):
with self.youtube_video("uR0N3DrybGQ", duration=15) as page:
res = page.run_test()
self.assertVideoQuality(res)
def test_stream_480p(self):
with self.youtube_video("BZP1rYjoBgI", duration=15) as page:
res = page.run_test()
self.assertVideoQuality(res)
[
{
"size": 20396656,
"visibility": "public",
"digest": "ccdecb515cadd243608898f38d74c23162fccb9246fee3084834c23d3a57710ed24c7c5dcc9b8bc6f5c3acb5fc0f3be144de08aa14d93e7dbbd372ec6166c138",
"algorithm": "sha512",
"filename": "BZP1rYjoBgI.tar.gz",
"unpack": true
}
]
/* global video, result, resolve */
video.mozRequestDebugInfo().then(debugInfo => {
// The parsing won't be necessary once we have bug 1542674
try {
debugInfo = debugInfo.replace(/\t/g, "").split(/\n/g);
var JSONDebugInfo = "{";
for (let g = 0; g < debugInfo.length - 1; g++) {
var pair = debugInfo[g].split(": ");
JSONDebugInfo += '"' + pair[0] + '":"' + pair[1] + '",';
}
JSONDebugInfo = JSONDebugInfo.slice(0, JSONDebugInfo.length - 1);
JSONDebugInfo += "}";
result.mozRequestDebugInfo = JSON.parse(JSONDebugInfo);
} catch (err) {
console.log(`Error '${err.toString()} in JSON.parse(${debugInfo})`);
result.mozRequestDebugInfo = debugInfo;
}
resolve(result);
});
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
import sys
from pytube import YouTube
def download_streams(video_id, output_path="data"):
yt = YouTube("https://youtube.com/watch?v=%s" % video_id)
for stream in yt.streams.all():
fn = "%s-%s-%s.%s" % (video_id, stream.itag, stream.type, stream.subtype)
stream.download(output_path="data", filename=fn)
print("%s downloaded" % fn)
if __name__ == "__main__":
download_streams(sys.argv[-1])
%(force_hd)s
const resolve = arguments[arguments.length - 1];
// this script is injected by marionette to collect metrics
var video = document.getElementsByTagName("video")[0];
if (!video) {
return "Can't find the video tag";
}
video.addEventListener("timeupdate", () => {
if (video.currentTime >= %(duration)s) {
%(video_playback_quality)s
%(debug_info)s
// Pausing after we get the debug info so
// we can also look at in/out data in buffers
video.pause();
}
}
);
video.play();
// This parts forces the highest definition
// https://addons.mozilla.org/en-US/firefox/addon/youtube-auto-hd-lq/
// licence: MPL 2.0
var config = {
HD: true,
LQ: false,
ID: "auto-hd-lq-for-ytb",
type(t) {
config.HD = t === "hd";
config.LQ = t === "lq";
},
quality() {
if (config.HD || config.LQ) {
var youtubePlayerListener = function(LQ, HD) {
return function(e) {
if (e === 1) {
var player = document.getElementById("movie_player");
if (player) {
var levels = player.getAvailableQualityLevels();
if (levels.length) {
var q =
// eslint-disable-next-line no-nested-ternary
HD && levels[0]
? levels[0]
: LQ && levels[levels.length - 2]
? levels[levels.length - 2]
: null;
if (q) {
player.setPlaybackQuality(q);
player.setPlaybackQualityRange(q, q);
}
}
}
}
};
};
/* */
var inject = function() {
var action = function() {
var player = document.getElementById("movie_player");
if (player && player.addEventListener && player.getPlayerState) {
player.addEventListener("onStateChange", "youtubePlayerListener");
} else {
window.setTimeout(action, 1000);
}
};
/* */
action();
};
var script = document.getElementById(config.ID);
if (!script) {
script = document.createElement("script");
script.setAttribute("type", "text/javascript");
script.setAttribute("id", config.ID);
document.documentElement.appendChild(script);
}
/* */
script.textContent =
"var youtubePlayerListener = (" +
youtubePlayerListener +
")(" +
config.LQ +
"," +
config.HD +
");(" +
inject +
")();";
}
},
};
if (/^https?:\/\/www\.youtube.com\/watch\?/.test(document.location.href)) {
config.quality();
}
var content = document.getElementById("content");
if (content) {
var observer = new window.MutationObserver(function(e) {
e.forEach(function(m) {
if (m.addedNodes !== null) {
for (var i = 0; i < m.addedNodes.length; i++) {
if (m.addedNodes[i].id === "movie_player") {
config.quality();
return;
}
}
}
});
});
/* */
observer.observe(content, { childList: true, subtree: true });
}
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
"""
MITM Script used to play back media files when a YT video is played.
This is a self-contained script that should not import anything else
except modules from the standard library and mitmproxy modules.
"""
import os
import sys
import datetime
import time
try:
from urllib import unquote
except ImportError:
from urllib.parse import unquote
itags = {
"5": {
"Extension": "flv",
"Resolution": "240p",
"VideoEncoding": "Sorenson H.283",
"AudioEncoding": "mp3",
"Itag": 5,
"AudioBitrate": 64,
},
"6": {
"Extension": "flv",
"Resolution": "270p",
"VideoEncoding": "Sorenson H.263",
"AudioEncoding": "mp3",
"Itag": 6,
"AudioBitrate": 64,
},
"13": {
"Extension": "3gp",
"Resolution": "",
"VideoEncoding": "MPEG-4 Visual",
"AudioEncoding": "aac",
"Itag": 13,
"AudioBitrate": 0,
},
"17": {
"Extension": "3gp",
"Resolution": "144p",
"VideoEncoding": "MPEG-4 Visual",
"AudioEncoding": "aac",
"Itag": 17,
"AudioBitrate": 24,
},
"18": {
"Extension": "mp4",
"Resolution": "360p",
"VideoEncoding": "H.264",
"AudioEncoding": "aac",
"Itag": 18,
"AudioBitrate": 96,
},
"22": {
"Extension": "mp4",
"Resolution": "720p",
"VideoEncoding": "H.264",
"AudioEncoding": "aac",
"Itag": 22,
"AudioBitrate": 192,
},
"34": {
"Extension": "flv",
"Resolution": "480p",
"VideoEncoding": "H.264",
"AudioEncoding": "aac",
"Itag": 34,
"AudioBitrate": 128,
},
"35": {
"Extension": "flv",
"Resolution": "360p",
"VideoEncoding": "H.264",
"AudioEncoding": "aac",
"Itag": 35,
"AudioBitrate": 128,
},
"36": {
"Extension": "3gp",
"Resolution": "240p",
"VideoEncoding": "MPEG-4 Visual",
"AudioEncoding": "aac",
"Itag": 36,
"AudioBitrate": 36,
},
"37": {
"Extension": "mp4",
"Resolution": "1080p",
"VideoEncoding": "H.264",
"AudioEncoding": "aac",
"Itag": 37,
"AudioBitrate": 192,
},
"38": {
"Extension": "mp4",
"Resolution": "3072p",
"VideoEncoding": "H.264",
"AudioEncoding": "aac",
"Itag": 38,
"AudioBitrate": 192,
},
"43": {
"Extension": "webm",
"Resolution": "360p",
"VideoEncoding": "VP8",
"AudioEncoding": "vorbis",
"Itag": 43,
"AudioBitrate": 128,
},
"44": {
"Extension": "webm",
"Resolution": "480p",
"VideoEncoding": "VP8",
"AudioEncoding": "vorbis",
"Itag": 44,
"AudioBitrate": 128,
},
"45": {
"Extension": "webm",
"Resolution": "720p",
"VideoEncoding": "VP8",
"AudioEncoding": "vorbis",
"Itag": 45,
"AudioBitrate": 192,
},
"46": {
"Extension": "webm",
"Resolution": "1080p",
"VideoEncoding": "VP8",
"AudioEncoding": "vorbis",
"Itag": 46,
"AudioBitrate": 192,
},
"82": {
"Extension": "mp4",
"Resolution": "360p",
"VideoEncoding": "H.264",
"Itag": 82,
"AudioBitrate": 96,
},
"83": {
"Extension": "mp4",
"Resolution": "240p",
"VideoEncoding": "H.264",
"AudioEncoding": "aac",
"Itag": 83,
"AudioBitrate": 96,
},
"84": {
"Extension": "mp4",
"Resolution": "720p",
"VideoEncoding": "H.264",
"AudioEncoding": "aac",
"Itag": 84,
"AudioBitrate": 192,
},
"85": {
"Extension": "mp4",
"Resolution": "1080p",
"VideoEncoding": "H.264",
"AudioEncoding": "aac",
"Itag": 85,
"AudioBitrate": 192,
},
"100": {
"Extension": "webm",
"Resolution": "360p",
"VideoEncoding": "VP8",
"AudioEncoding": "vorbis",
"Itag": 100,
"AudioBitrate": 128,
},
"101": {
"Extension": "webm",
"Resolution": "360p",
"VideoEncoding": "VP8",
"AudioEncoding": "vorbis",
"Itag": 101,
"AudioBitrate": 192,
},
"102": {
"Extension": "webm",
"Resolution": "720p",
"VideoEncoding": "VP8",
"AudioEncoding": "vorbis",
"Itag": 102,
"AudioBitrate": 192,
},
"133": {
"Extension": "mp4",
"Resolution": "240p",
"VideoEncoding": "H.264",
"AudioEncoding": "",
"Itag": 133,
"AudioBitrate": 0,
},
"134": {
"Extension": "mp4",
"Resolution": "360p",
"VideoEncoding": "H.264",
"AudioEncoding": "",
"Itag": 134,
"AudioBitrate": 0,
},
"135": {
"Extension": "mp4",
"Resolution": "480p",
"VideoEncoding": "H.264",
"AudioEncoding": "",
"Itag": 135,
"AudioBitrate": 0,
},
"136": {
"Extension": "mp4",
"Resolution": "720p",
"VideoEncoding": "H.264",
"AudioEncoding": "",
"Itag": 136,
"AudioBitrate": 0,
},
"137": {
"Extension": "mp4",
"Resolution": "1080p",
"VideoEncoding": "H.264",
"AudioEncoding": "",
"Itag": 137,
"AudioBitrate": 0,
},
"138": {
"Extension": "mp4",
"Resolution": "2160p",
"VideoEncoding": "H.264",
"AudioEncoding": "",
"Itag": 138,
"AudioBitrate": 0,
},
"160": {
"Extension": "mp4",
"Resolution": "144p",
"VideoEncoding": "H.264",
"AudioEncoding": "",
"Itag": 160,
"AudioBitrate": 0,
},
"242": {
"Extension": "webm",
"Resolution": "240p",
"VideoEncoding": "VP9",
"AudioEncoding": "",
"Itag": 242,
"AudioBitrate": 0,
},
"243": {
"Extension": "webm",
"Resolution": "360p",
"VideoEncoding": "VP9",
"AudioEncoding": "",
"Itag": 243,
"AudioBitrate": 0,
},
"244": {
"Extension": "webm",
"Resolution": "480p",
"VideoEncoding": "VP9",
"AudioEncoding": "",
"Itag": 244,
"AudioBitrate": 0,
},
"247": {
"Extension": "webm",
"Resolution": "720p",
"VideoEncoding": "VP9",
"AudioEncoding": "",
"Itag": 247,
"AudioBitrate": 0,
},
"248": {
"Extension": "webm",
"Resolution": "1080p",
"VideoEncoding": "VP9",
"AudioEncoding": "",
"Itag": 248,
"AudioBitrate": 9,
},
"264": {
"Extension": "mp4",
"Resolution": "1440p",
"VideoEncoding": "H.264",
"AudioEncoding": "",
"Itag": 264,
"AudioBitrate": 0,
},
"266": {
"Extension": "mp4",
"Resolution": "2160p",
"VideoEncoding": "H.264",
"AudioEncoding": "",
"Itag": 266,
"AudioBitrate": 0,
},
"271": {
"Extension": "webm",
"Resolution": "1440p",
"VideoEncoding": "VP9",
"AudioEncoding": "",
"Itag": 271,
"AudioBitrate": 0,
},
"272": {
"Extension": "webm",
"Resolution": "2160p",
"VideoEncoding": "VP9",
"AudioEncoding": "",
"Itag": 272,
"AudioBitrate": 0,
},
"278": {
"Extension": "webm",
"Resolution": "144p",
"VideoEncoding": "VP9",
"AudioEncoding": "",
"Itag": 278,
"AudioBitrate": 0,
},
"298": {
"Extension": "mp4",
"Resolution": "720p",
"VideoEncoding": "H.264",
"AudioEncoding": "",
"Itag": 298,
"AudioBitrate": 0,
},
"299": {
"Extension": "mp4",
"Resolution": "1080p",
"VideoEncoding": "H.264",
"AudioEncoding": "",
"Itag": 299,
"AudioBitrate": 0,
},
"302": {
"Extension": "webm",
"Resolution": "720p",
"VideoEncoding": "VP9",
"AudioEncoding": "",
"Itag": 302,
"AudioBitrate": 0,
},
"303": {
"Extension": "webm",
"Resolution": "1080p",
"VideoEncoding": "VP9",
"AudioEncoding": "",
"Itag": 303,
"AudioBitrate": 0,
},
"139": {
"Extension": "mp4",
"Resolution": "",
"VideoEncoding": "",
"AudioEncoding": "aac",
"Itag": 139,
"AudioBitrate": 48,
},
"140": {
"Extension": "mp4",
"Resolution": "",
"VideoEncoding": "",
"AudioEncoding": "aac",
"Itag": 140,
"AudioBitrate": 128,
},
"141": {
"Extension": "mp4",