Bug 539713 - Simple Alive test for the Applications Prefpane (Port browser_bug410900.js). r=Neil
This commit is contained in:
Родитель
403511519f
Коммит
46d0041561
|
@ -47,7 +47,7 @@ include $(DEPTH)/config/autoconf.mk
|
|||
MODULE = test_suite_common
|
||||
|
||||
ifdef ENABLE_TESTS
|
||||
PARALLEL_DIRS = browser chrome
|
||||
PARALLEL_DIRS = browser chrome preferences
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Mozilla Foundation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 2007
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Ryan Flint <rflint@dslr.net> (Original Author)
|
||||
# Philip Chee <philip.chee@gmail.com>
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
relativesrcdir = suite/common/tests/preferences
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
_BROWSER_FILES = \
|
||||
browser_bug410900.js \
|
||||
$(NULL)
|
||||
|
||||
libs:: $(_BROWSER_FILES)
|
||||
$(INSTALL) $(foreach f,$^,"$f") $(MOZDEPTH)/_tests/testing/mochitest/browser/$(relativesrcdir)
|
|
@ -0,0 +1,55 @@
|
|||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
// Setup a phony handler to ensure the app pane will be populated.
|
||||
var handler = Components.classes["@mozilla.org/uriloader/web-handler-app;1"]
|
||||
.createInstance(Components.interfaces.nsIWebHandlerApp);
|
||||
handler.name = "App pane alive test";
|
||||
handler.uriTemplate = "http://test.mozilla.org/%s";
|
||||
|
||||
var extps = Components.classes["@mozilla.org/uriloader/external-protocol-service;1"]
|
||||
.getService(Components.interfaces.nsIExternalProtocolService);
|
||||
var info = extps.getProtocolHandlerInfo("apppanetest");
|
||||
info.possibleApplicationHandlers.appendElement(handler, false);
|
||||
|
||||
var hserv = Components.classes["@mozilla.org/uriloader/handler-service;1"]
|
||||
.getService(Components.interfaces.nsIHandlerService);
|
||||
hserv.store(info);
|
||||
|
||||
var obs = Components.classes["@mozilla.org/observer-service;1"]
|
||||
.getService(Components.interfaces.nsIObserverService);
|
||||
|
||||
function observer(win, topic, data) {
|
||||
if (topic != "app-handler-pane-loaded")
|
||||
return;
|
||||
|
||||
obs.removeObserver(observer, "app-handler-pane-loaded");
|
||||
runTest(win);
|
||||
}
|
||||
obs.addObserver(observer, "app-handler-pane-loaded", false);
|
||||
|
||||
openDialog("chrome://communicator/content/pref/preferences.xul",
|
||||
"PrefWindow", "chrome,titlebar,dialog=no,resizable",
|
||||
"applications_pane");
|
||||
}
|
||||
|
||||
function runTest(win) {
|
||||
var sel = win.document.documentElement.getAttribute("lastSelected");
|
||||
ok(sel == "applications_pane", "Specified pane was opened");
|
||||
|
||||
var rbox = win.document.getElementById("handlersView");
|
||||
ok(rbox, "handlersView is present");
|
||||
|
||||
var items = rbox && rbox.getElementsByTagName("listitem");
|
||||
ok(items && items.length > 0, "App handler list populated");
|
||||
|
||||
var handlerAdded = false;
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
if (items[i].getAttribute("type") == "apppanetest")
|
||||
handlerAdded = true;
|
||||
}
|
||||
ok(handlerAdded, "apppanetest protocol handler was succesfully added");
|
||||
|
||||
win.close();
|
||||
finish();
|
||||
}
|
Загрузка…
Ссылка в новой задаче