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 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
2 Cu.import("resource://webapprt/modules/WebappRT.jsm");
3 let { DOMApplicationRegistry } =
4 Cu.import("resource://gre/modules/Webapps.jsm", {});
6 function test() {
7 waitForExplicitFinish();
9 let appID = Ci.nsIScriptSecurityManager.NO_APP_ID;
11 let progressListener = {
12 QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener,
13 Ci.nsISupportsWeakReference]),
14 onLocationChange: function(progress, request, location, flags) {
15 ok(false, "Content redirected")
16 finish();
17 }
18 };
20 let winObserver = function(win, topic) {
21 if (topic == "domwindowopened") {
22 win.addEventListener("load", function onLoadWindow() {
23 win.removeEventListener("load", onLoadWindow, false);
25 if (win.location == "chrome://webapprt/content/webapp.xul") {
26 let winAppBrowser = win.document.getElementById("content");
27 winAppBrowser.addEventListener("load", function onLoadBrowser() {
28 winAppBrowser.removeEventListener("load", onLoadBrowser, true);
30 is(winAppBrowser.getAttribute("src"),
31 "http://test/webapprtChrome/webapprt/test/chrome/sample.html",
32 "New window browser has correct src");
34 is(winAppBrowser.contentDocument.defaultView.document.nodePrincipal.appId,
35 appID,
36 "New window principal app ID correct");
38 win.close();
40 finish();
41 }, true);
42 }
43 }, false);
44 }
45 }
47 Services.ww.registerNotification(winObserver);
49 loadWebapp("window-open.webapp", undefined, function() {
50 appID = gAppBrowser.contentDocument.defaultView.document.nodePrincipal.appId;
52 is(DOMApplicationRegistry.getAppLocalIdByManifestURL(WebappRT.config.app.manifestURL),
53 appID,
54 "Principal app ID correct");
56 gAppBrowser.addProgressListener(progressListener,
57 Ci.nsIWebProgress.NOTIFY_LOCATION);
58 });
60 registerCleanupFunction(function() {
61 Services.ww.unregisterNotification(winObserver);
62 gAppBrowser.removeProgressListener(progressListener);
63 });
64 }