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