1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/webapprt/test/chrome/browser_getUserMedia.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,42 @@ 1.4 +Cu.import("resource://gre/modules/Services.jsm"); 1.5 + 1.6 +function test() { 1.7 + waitForExplicitFinish(); 1.8 + 1.9 + Services.prefs.setBoolPref("media.navigator.permission.fake", true); 1.10 + 1.11 + let getUserMediaDialogOpened = false; 1.12 + 1.13 + let winObserver = function(win, topic) { 1.14 + if (topic == "domwindowopened") { 1.15 + win.addEventListener("load", function onLoadWindow() { 1.16 + win.removeEventListener("load", onLoadWindow, false); 1.17 + 1.18 + if (win.document.documentURI == "chrome://webapprt/content/getUserMediaDialog.xul") { 1.19 + getUserMediaDialogOpened = true; 1.20 + win.close(); 1.21 + } 1.22 + }, false); 1.23 + } 1.24 + } 1.25 + 1.26 + Services.ww.registerNotification(winObserver); 1.27 + 1.28 + let mutObserver = null; 1.29 + 1.30 + loadWebapp("getUserMedia.webapp", undefined, function onLoad() { 1.31 + let msg = gAppBrowser.contentDocument.getElementById("msg"); 1.32 + mutObserver = new MutationObserver(function(mutations) { 1.33 + is(msg.textContent, "PERMISSION_DENIED", "getUserMedia permission denied."); 1.34 + ok(getUserMediaDialogOpened, "Prompt shown."); 1.35 + finish(); 1.36 + }); 1.37 + mutObserver.observe(msg, { childList: true }); 1.38 + }); 1.39 + 1.40 + registerCleanupFunction(function() { 1.41 + Services.ww.unregisterNotification(winObserver); 1.42 + mutObserver.disconnect(); 1.43 + Services.prefs.clearUserPref("media.navigator.permission.fake"); 1.44 + }); 1.45 +}