mirror of
https://github.com/classilla/tenfourfox.git
synced 2024-11-19 18:38:36 +00:00
44 lines
1.3 KiB
JavaScript
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");
|
|
});
|
|
}
|