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