Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 const Cc = Components.classes;
2 const Ci = Components.interfaces;
4 var authPromptRequestReceived;
6 const tPFCID = Components.ID("{749e62f4-60ae-4569-a8a2-de78b649660f}");
7 const tPFContract = "@mozilla.org/passwordmanager/authpromptfactory;1";
9 /*
10 * TestPromptFactory
11 *
12 * Implements nsIPromptFactory
13 */
14 var TestPromptFactory = {
15 QueryInterface: function tPF_qi(iid) {
16 if (iid.equals(Ci.nsISupports) ||
17 iid.equals(Ci.nsIFactory) ||
18 iid.equals(Ci.nsIPromptFactory))
19 return this;
20 throw Components.results.NS_ERROR_NO_INTERFACE;
21 },
23 createInstance: function tPF_ci(outer, iid) {
24 if (outer)
25 throw Components.results.NS_ERROR_NO_AGGREGATION;
26 return this.QueryInterface(iid);
27 },
29 lockFactory: function tPF_lockf(lock) {
30 throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
31 },
33 getPrompt : function tPF_getPrompt(aWindow, aIID) {
34 if (aIID.equals(Ci.nsIAuthPrompt) ||
35 aIID.equals(Ci.nsIAuthPrompt2)) {
36 authPromptRequestReceived = true;
37 return {};
38 }
40 throw Components.results.NS_ERROR_NO_INTERFACE;
41 }
42 }; // end of TestPromptFactory implementation
44 /*
45 * The tests
46 */
47 function run_test() {
48 Components.manager.nsIComponentRegistrar.registerFactory(tPFCID,
49 "TestPromptFactory", tPFContract, TestPromptFactory);
51 // Make sure that getting both nsIAuthPrompt and nsIAuthPrompt2 works
52 // (these should work independently of whether the application has
53 // nsIPromptService2)
54 var ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].getService();
56 authPromptRequestReceived = false;
58 do_check_neq(ww.nsIPromptFactory.getPrompt(null, Ci.nsIAuthPrompt), null);
60 do_check_true(authPromptRequestReceived);
62 authPromptRequestReceived = false;
64 do_check_neq(ww.nsIPromptFactory.getPrompt(null, Ci.nsIAuthPrompt2), null);
66 do_check_true(authPromptRequestReceived);
67 }