Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / embedding / tests / unit / test_wwauthpromptfactory.js
blobaba2cf684f6efd0234275cd6065966c3381a083e
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
12 * Implements nsIPromptFactory
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;
23 createInstance: function tPF_ci(outer, iid) {
24 if (outer)
25 throw Components.results.NS_ERROR_NO_AGGREGATION;
26 return this.QueryInterface(iid);
29 lockFactory: function tPF_lockf(lock) {
30 throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
33 getPrompt : function tPF_getPrompt(aWindow, aIID) {
34 if (aIID.equals(Ci.nsIAuthPrompt) ||
35 aIID.equals(Ci.nsIAuthPrompt2)) {
36 authPromptRequestReceived = true;
37 return {};
40 throw Components.results.NS_ERROR_NO_INTERFACE;
42 }; // end of TestPromptFactory implementation
45 * The tests
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);