Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | Cu.import("resource://gre/modules/Services.jsm"); |
michael@0 | 2 | |
michael@0 | 3 | function test() { |
michael@0 | 4 | waitForExplicitFinish(); |
michael@0 | 5 | |
michael@0 | 6 | Services.prefs.setBoolPref("media.navigator.permission.fake", true); |
michael@0 | 7 | |
michael@0 | 8 | let getUserMediaDialogOpened = false; |
michael@0 | 9 | |
michael@0 | 10 | let winObserver = function(win, topic) { |
michael@0 | 11 | if (topic == "domwindowopened") { |
michael@0 | 12 | win.addEventListener("load", function onLoadWindow() { |
michael@0 | 13 | win.removeEventListener("load", onLoadWindow, false); |
michael@0 | 14 | |
michael@0 | 15 | if (win.document.documentURI == "chrome://webapprt/content/getUserMediaDialog.xul") { |
michael@0 | 16 | getUserMediaDialogOpened = true; |
michael@0 | 17 | win.close(); |
michael@0 | 18 | } |
michael@0 | 19 | }, false); |
michael@0 | 20 | } |
michael@0 | 21 | } |
michael@0 | 22 | |
michael@0 | 23 | Services.ww.registerNotification(winObserver); |
michael@0 | 24 | |
michael@0 | 25 | let mutObserver = null; |
michael@0 | 26 | |
michael@0 | 27 | loadWebapp("getUserMedia.webapp", undefined, function onLoad() { |
michael@0 | 28 | let msg = gAppBrowser.contentDocument.getElementById("msg"); |
michael@0 | 29 | mutObserver = new MutationObserver(function(mutations) { |
michael@0 | 30 | is(msg.textContent, "PERMISSION_DENIED", "getUserMedia permission denied."); |
michael@0 | 31 | ok(getUserMediaDialogOpened, "Prompt shown."); |
michael@0 | 32 | finish(); |
michael@0 | 33 | }); |
michael@0 | 34 | mutObserver.observe(msg, { childList: true }); |
michael@0 | 35 | }); |
michael@0 | 36 | |
michael@0 | 37 | registerCleanupFunction(function() { |
michael@0 | 38 | Services.ww.unregisterNotification(winObserver); |
michael@0 | 39 | mutObserver.disconnect(); |
michael@0 | 40 | Services.prefs.clearUserPref("media.navigator.permission.fake"); |
michael@0 | 41 | }); |
michael@0 | 42 | } |