tenfourfox/webapprt/test/chrome/browser_getUserMedia.js
Cameron Kaiser c9b2922b70 hello FPR
2017-04-19 00:56:45 -07:00

44 lines
1.3 KiB
JavaScript

Cu.import("resource://gre/modules/Services.jsm");
function test() {
waitForExplicitFinish();
Services.prefs.setBoolPref("media.navigator.permission.fake", true);
let getUserMediaDialogOpened = false;
let winObserver = function(win, topic) {
if (topic == "domwindowopened") {
win.addEventListener("load", function onLoadWindow() {
win.removeEventListener("load", onLoadWindow, false);
if (win.document.documentURI == "chrome://webapprt/content/getUserMediaDialog.xul") {
getUserMediaDialogOpened = true;
win.close();
}
}, false);
}
}
Services.ww.registerNotification(winObserver);
let mutObserver = null;
loadWebapp("getUserMedia.webapp", undefined, function onLoad() {
let msg = gAppBrowser.contentDocument.getElementById("msg");
mutObserver = new MutationObserver(function(mutations) {
is(msg.textContent, "SecurityError: The operation is insecure.",
"getUserMedia permission denied.");
ok(getUserMediaDialogOpened, "Prompt shown.");
finish();
});
mutObserver.observe(msg, { childList: true });
});
registerCleanupFunction(function() {
Services.ww.unregisterNotification(winObserver);
mutObserver.disconnect();
Services.prefs.clearUserPref("media.navigator.permission.fake");
});
}