Fri, 16 Jan 2015 18:13:44 +0100
Integrate suggestion from review to improve consistency with existing code.
michael@0 | 1 | function test() { |
michael@0 | 2 | waitForExplicitFinish(); |
michael@0 | 3 | |
michael@0 | 4 | // Setup a phony handler to ensure the app pane will be populated. |
michael@0 | 5 | var handler = Cc["@mozilla.org/uriloader/web-handler-app;1"]. |
michael@0 | 6 | createInstance(Ci.nsIWebHandlerApp); |
michael@0 | 7 | handler.name = "App pane alive test"; |
michael@0 | 8 | handler.uriTemplate = "http://test.mozilla.org/%s"; |
michael@0 | 9 | |
michael@0 | 10 | var extps = Cc["@mozilla.org/uriloader/external-protocol-service;1"]. |
michael@0 | 11 | getService(Ci.nsIExternalProtocolService); |
michael@0 | 12 | var info = extps.getProtocolHandlerInfo("apppanetest"); |
michael@0 | 13 | info.possibleApplicationHandlers.appendElement(handler, false); |
michael@0 | 14 | |
michael@0 | 15 | var hserv = Cc["@mozilla.org/uriloader/handler-service;1"]. |
michael@0 | 16 | getService(Ci.nsIHandlerService); |
michael@0 | 17 | hserv.store(info); |
michael@0 | 18 | |
michael@0 | 19 | function observer(win, topic, data) { |
michael@0 | 20 | if (topic != "app-handler-pane-loaded") |
michael@0 | 21 | return; |
michael@0 | 22 | |
michael@0 | 23 | Services.obs.removeObserver(observer, "app-handler-pane-loaded"); |
michael@0 | 24 | runTest(win); |
michael@0 | 25 | } |
michael@0 | 26 | Services.obs.addObserver(observer, "app-handler-pane-loaded", false); |
michael@0 | 27 | |
michael@0 | 28 | openDialog("chrome://browser/content/preferences/preferences.xul", "Preferences", |
michael@0 | 29 | "chrome,titlebar,toolbar,centerscreen,dialog=no", "paneApplications"); |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | function runTest(win) { |
michael@0 | 33 | var sel = win.document.documentElement.getAttribute("lastSelected"); |
michael@0 | 34 | ok(sel == "paneApplications", "Specified pane was opened"); |
michael@0 | 35 | |
michael@0 | 36 | var rbox = win.document.getElementById("handlersView"); |
michael@0 | 37 | ok(rbox, "handlersView is present"); |
michael@0 | 38 | |
michael@0 | 39 | var items = rbox && rbox.getElementsByTagName("richlistitem"); |
michael@0 | 40 | ok(items && items.length > 0, "App handler list populated"); |
michael@0 | 41 | |
michael@0 | 42 | var handlerAdded = false; |
michael@0 | 43 | for (let i = 0; i < items.length; i++) { |
michael@0 | 44 | if (items[i].type == "apppanetest") |
michael@0 | 45 | handlerAdded = true; |
michael@0 | 46 | } |
michael@0 | 47 | ok(handlerAdded, "apppanetest protocol handler was successfully added"); |
michael@0 | 48 | |
michael@0 | 49 | win.close(); |
michael@0 | 50 | finish(); |
michael@0 | 51 | } |