browser/components/preferences/in-content/tests/browser_bug410900.js

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

michael@0 1 /* Any copyright is dedicated to the Public Domain.
michael@0 2 * http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 3
michael@0 4 Components.utils.import("resource://gre/modules/PlacesUtils.jsm");
michael@0 5 Components.utils.import("resource://gre/modules/NetUtil.jsm");
michael@0 6
michael@0 7 function test() {
michael@0 8 waitForExplicitFinish();
michael@0 9
michael@0 10 // Setup a phony handler to ensure the app pane will be populated.
michael@0 11 var handler = Cc["@mozilla.org/uriloader/web-handler-app;1"].
michael@0 12 createInstance(Ci.nsIWebHandlerApp);
michael@0 13 handler.name = "App pane alive test";
michael@0 14 handler.uriTemplate = "http://test.mozilla.org/%s";
michael@0 15
michael@0 16 var extps = Cc["@mozilla.org/uriloader/external-protocol-service;1"].
michael@0 17 getService(Ci.nsIExternalProtocolService);
michael@0 18 var info = extps.getProtocolHandlerInfo("apppanetest");
michael@0 19 info.possibleApplicationHandlers.appendElement(handler, false);
michael@0 20
michael@0 21 var hserv = Cc["@mozilla.org/uriloader/handler-service;1"].
michael@0 22 getService(Ci.nsIHandlerService);
michael@0 23 hserv.store(info);
michael@0 24
michael@0 25 function observer(win, topic, data) {
michael@0 26 if (topic != "app-handler-pane-loaded")
michael@0 27 return;
michael@0 28
michael@0 29 Services.obs.removeObserver(observer, "app-handler-pane-loaded");
michael@0 30 runTest(win);
michael@0 31 }
michael@0 32 Services.obs.addObserver(observer, "app-handler-pane-loaded", false);
michael@0 33
michael@0 34 gBrowser.selectedTab = gBrowser.addTab("about:preferences");
michael@0 35 }
michael@0 36
michael@0 37 function runTest(win) {
michael@0 38 win.gotoPref("applications");
michael@0 39 var sel = win.history.state;
michael@0 40 ok(sel == "applications", "Specified pane was opened");
michael@0 41
michael@0 42 var rbox = win.document.getElementById("handlersView");
michael@0 43 ok(rbox, "handlersView is present");
michael@0 44
michael@0 45 var items = rbox && rbox.getElementsByTagName("richlistitem");
michael@0 46 ok(items && items.length > 0, "App handler list populated");
michael@0 47
michael@0 48 var handlerAdded = false;
michael@0 49 for (let i = 0; i < items.length; i++) {
michael@0 50 if (items[i].getAttribute('type') == "apppanetest")
michael@0 51 handlerAdded = true;
michael@0 52 }
michael@0 53 ok(handlerAdded, "apppanetest protocol handler was successfully added");
michael@0 54
michael@0 55 gBrowser.removeCurrentTab();
michael@0 56 win.close();
michael@0 57 finish();
michael@0 58 }

mercurial