Bug 1281427 - move browser_devices_* tests to a webrtc folder, r=Gijs.

--HG--
rename : browser/base/content/test/general/browser_devices_get_user_media.js => browser/base/content/test/webrtc/browser_devices_get_user_media.js
rename : browser/base/content/test/general/browser_devices_get_user_media_about_urls.js => browser/base/content/test/webrtc/browser_devices_get_user_media_about_urls.js
rename : browser/base/content/test/general/browser_devices_get_user_media_anim.js => browser/base/content/test/webrtc/browser_devices_get_user_media_anim.js
rename : browser/base/content/test/general/browser_devices_get_user_media_in_frame.js => browser/base/content/test/webrtc/browser_devices_get_user_media_in_frame.js
rename : browser/base/content/test/general/get_user_media.html => browser/base/content/test/webrtc/get_user_media.html
rename : browser/base/content/test/general/get_user_media_content_script.js => browser/base/content/test/webrtc/get_user_media_content_script.js
rename : browser/base/content/test/general/get_user_media_helpers.js => browser/base/content/test/webrtc/get_user_media_helpers.js
This commit is contained in:
Florian Quèze 2016-06-27 12:23:57 +02:00
Родитель fa3eb6a9b1
Коммит df052b0efe
12 изменённых файлов: 186 добавлений и 122 удалений

Просмотреть файл

@ -69,9 +69,6 @@ support-files =
file_favicon_change.html
file_favicon_change_not_in_document.html
file_fullscreen-window-open.html
get_user_media.html
get_user_media_content_script.js
get_user_media_helpers.js
head.js
healthreport_pingData.js
healthreport_testRemoteCommands.html
@ -293,12 +290,6 @@ skip-if = !datareporting
[browser_decoderDoctor.js]
skip-if = os == "mac" # decoder doctor isn't implemented on osx
[browser_devedition.js]
[browser_devices_get_user_media.js]
skip-if = buildapp == 'mulet' || (os == "linux" && debug) # linux: bug 976544
[browser_devices_get_user_media_about_urls.js]
skip-if = e10s && debug
[browser_devices_get_user_media_anim.js]
[browser_devices_get_user_media_in_frame.js]
[browser_discovery.js]
[browser_double_close_tab.js]
[browser_documentnavigation.js]

Просмотреть файл

@ -658,119 +658,6 @@ function waitForNewTabEvent(aTabBrowser) {
return promiseWaitForEvent(aTabBrowser.tabContainer, "TabOpen");
}
/**
* Waits for a window with the given URL to exist.
*
* @param url
* The url of the window.
* @return {Promise} resolved when the window exists.
* @resolves to the window
*/
function promiseWindow(url) {
info("expecting a " + url + " window");
return new Promise(resolve => {
Services.obs.addObserver(function obs(win) {
win.QueryInterface(Ci.nsIDOMWindow);
win.addEventListener("load", function loadHandler() {
win.removeEventListener("load", loadHandler);
if (win.location.href !== url) {
info("ignoring a window with this url: " + win.location.href);
return;
}
Services.obs.removeObserver(obs, "domwindowopened");
resolve(win);
});
}, "domwindowopened", false);
});
}
function promiseIndicatorWindow() {
// We don't show the indicator window on Mac.
if ("nsISystemStatusBar" in Ci)
return Promise.resolve();
return promiseWindow("chrome://browser/content/webrtcIndicator.xul");
}
function assertWebRTCIndicatorStatus(expected) {
let ui = Cu.import("resource:///modules/webrtcUI.jsm", {}).webrtcUI;
let expectedState = expected ? "visible" : "hidden";
let msg = "WebRTC indicator " + expectedState;
if (!expected && ui.showGlobalIndicator) {
// It seems the global indicator is not always removed synchronously
// in some cases.
info("waiting for the global indicator to be hidden");
yield promiseWaitForCondition(() => !ui.showGlobalIndicator);
}
is(ui.showGlobalIndicator, !!expected, msg);
let expectVideo = false, expectAudio = false, expectScreen = false;
if (expected) {
if (expected.video)
expectVideo = true;
if (expected.audio)
expectAudio = true;
if (expected.screen)
expectScreen = true;
}
is(ui.showCameraIndicator, expectVideo, "camera global indicator as expected");
is(ui.showMicrophoneIndicator, expectAudio, "microphone global indicator as expected");
is(ui.showScreenSharingIndicator, expectScreen, "screen global indicator as expected");
let windows = Services.wm.getEnumerator("navigator:browser");
while (windows.hasMoreElements()) {
let win = windows.getNext();
let menu = win.document.getElementById("tabSharingMenu");
is(menu && !menu.hidden, !!expected, "WebRTC menu should be " + expectedState);
}
if (!("nsISystemStatusBar" in Ci)) {
if (!expected) {
let win = Services.wm.getMostRecentWindow("Browser:WebRTCGlobalIndicator");
if (win) {
yield new Promise((resolve, reject) => {
win.addEventListener("unload", function listener(e) {
if (e.target == win.document) {
win.removeEventListener("unload", listener);
resolve();
}
}, false);
});
}
}
let indicator = Services.wm.getEnumerator("Browser:WebRTCGlobalIndicator");
let hasWindow = indicator.hasMoreElements();
is(hasWindow, !!expected, "popup " + msg);
if (hasWindow) {
let document = indicator.getNext().document;
let docElt = document.documentElement;
if (document.readyState != "complete") {
info("Waiting for the sharing indicator's document to load");
let deferred = Promise.defer();
document.addEventListener("readystatechange",
function onReadyStateChange() {
if (document.readyState != "complete")
return;
document.removeEventListener("readystatechange", onReadyStateChange);
deferred.resolve();
});
yield deferred.promise;
}
for (let item of ["video", "audio", "screen"]) {
let expectedValue = (expected && expected[item]) ? "true" : "";
is(docElt.getAttribute("sharing" + item), expectedValue,
item + " global indicator attribute as expected");
}
ok(!indicator.hasMoreElements(), "only one global indicator window");
}
}
}
/**
* Test the state of the identity box and control center to make
* sure they are correctly showing the expected mixed content states.

Просмотреть файл

@ -0,0 +1,13 @@
[DEFAULT]
support-files =
get_user_media.html
get_user_media_content_script.js
get_user_media_helpers.js
head.js
[browser_devices_get_user_media.js]
skip-if = buildapp == 'mulet' || (os == "linux" && debug) # linux: bug 976544
[browser_devices_get_user_media_about_urls.js]
skip-if = e10s && debug
[browser_devices_get_user_media_anim.js]
[browser_devices_get_user_media_in_frame.js]

Просмотреть файл

@ -0,0 +1,172 @@
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Promise",
"resource://gre/modules/Promise.jsm");
function waitForCondition(condition, nextTest, errorMsg, retryTimes) {
retryTimes = typeof retryTimes !== 'undefined' ? retryTimes : 30;
var tries = 0;
var interval = setInterval(function() {
if (tries >= retryTimes) {
ok(false, errorMsg);
moveOn();
}
var conditionPassed;
try {
conditionPassed = condition();
} catch (e) {
ok(false, e + "\n" + e.stack);
conditionPassed = false;
}
if (conditionPassed) {
moveOn();
}
tries++;
}, 100);
var moveOn = function() { clearInterval(interval); nextTest(); };
}
function promiseWaitForCondition(aConditionFn) {
let deferred = Promise.defer();
waitForCondition(aConditionFn, deferred.resolve, "Condition didn't pass.");
return deferred.promise;
}
/**
* Waits for a window with the given URL to exist.
*
* @param url
* The url of the window.
* @return {Promise} resolved when the window exists.
* @resolves to the window
*/
function promiseWindow(url) {
info("expecting a " + url + " window");
return new Promise(resolve => {
Services.obs.addObserver(function obs(win) {
win.QueryInterface(Ci.nsIDOMWindow);
win.addEventListener("load", function loadHandler() {
win.removeEventListener("load", loadHandler);
if (win.location.href !== url) {
info("ignoring a window with this url: " + win.location.href);
return;
}
Services.obs.removeObserver(obs, "domwindowopened");
resolve(win);
});
}, "domwindowopened", false);
});
}
function promiseIndicatorWindow() {
// We don't show the indicator window on Mac.
if ("nsISystemStatusBar" in Ci)
return Promise.resolve();
return promiseWindow("chrome://browser/content/webrtcIndicator.xul");
}
function assertWebRTCIndicatorStatus(expected) {
let ui = Cu.import("resource:///modules/webrtcUI.jsm", {}).webrtcUI;
let expectedState = expected ? "visible" : "hidden";
let msg = "WebRTC indicator " + expectedState;
if (!expected && ui.showGlobalIndicator) {
// It seems the global indicator is not always removed synchronously
// in some cases.
info("waiting for the global indicator to be hidden");
yield promiseWaitForCondition(() => !ui.showGlobalIndicator);
}
is(ui.showGlobalIndicator, !!expected, msg);
let expectVideo = false, expectAudio = false, expectScreen = false;
if (expected) {
if (expected.video)
expectVideo = true;
if (expected.audio)
expectAudio = true;
if (expected.screen)
expectScreen = true;
}
is(ui.showCameraIndicator, expectVideo, "camera global indicator as expected");
is(ui.showMicrophoneIndicator, expectAudio, "microphone global indicator as expected");
is(ui.showScreenSharingIndicator, expectScreen, "screen global indicator as expected");
let windows = Services.wm.getEnumerator("navigator:browser");
while (windows.hasMoreElements()) {
let win = windows.getNext();
let menu = win.document.getElementById("tabSharingMenu");
is(menu && !menu.hidden, !!expected, "WebRTC menu should be " + expectedState);
}
if (!("nsISystemStatusBar" in Ci)) {
if (!expected) {
let win = Services.wm.getMostRecentWindow("Browser:WebRTCGlobalIndicator");
if (win) {
yield new Promise((resolve, reject) => {
win.addEventListener("unload", function listener(e) {
if (e.target == win.document) {
win.removeEventListener("unload", listener);
resolve();
}
}, false);
});
}
}
let indicator = Services.wm.getEnumerator("Browser:WebRTCGlobalIndicator");
let hasWindow = indicator.hasMoreElements();
is(hasWindow, !!expected, "popup " + msg);
if (hasWindow) {
let document = indicator.getNext().document;
let docElt = document.documentElement;
if (document.readyState != "complete") {
info("Waiting for the sharing indicator's document to load");
let deferred = Promise.defer();
document.addEventListener("readystatechange",
function onReadyStateChange() {
if (document.readyState != "complete")
return;
document.removeEventListener("readystatechange", onReadyStateChange);
deferred.resolve();
});
yield deferred.promise;
}
for (let item of ["video", "audio", "screen"]) {
let expectedValue = (expected && expected[item]) ? "true" : "";
is(docElt.getAttribute("sharing" + item), expectedValue,
item + " global indicator attribute as expected");
}
ok(!indicator.hasMoreElements(), "only one global indicator window");
}
}
}
function promisePopupEvent(popup, eventSuffix) {
let endState = {shown: "open", hidden: "closed"}[eventSuffix];
if (popup.state == endState)
return Promise.resolve();
let eventType = "popup" + eventSuffix;
let deferred = Promise.defer();
popup.addEventListener(eventType, function onPopupShown(event) {
popup.removeEventListener(eventType, onPopupShown);
deferred.resolve();
});
return deferred.promise;
}
function promiseNotificationShown(notification) {
let win = notification.browser.ownerDocument.defaultView;
if (win.PopupNotifications.panel.state == "open") {
return Promise.resolve();
}
let panelPromise = promisePopupEvent(win.PopupNotifications.panel, "shown");
notification.reshow();
return panelPromise;
}

Просмотреть файл

@ -25,6 +25,7 @@ BROWSER_CHROME_MANIFESTS += [
'content/test/social/browser.ini',
'content/test/tabPrompts/browser.ini',
'content/test/urlbar/browser.ini',
'content/test/webrtc/browser.ini',
]
DEFINES['MOZ_APP_VERSION'] = CONFIG['MOZ_APP_VERSION']