Backout 1924fe55fb6e (bug 771294) for causing failures in test_cross_domain.xul

This commit is contained in:
Ed Morley 2012-08-03 11:14:08 +01:00
parent e4101ad4dc
commit 814a6224c4
8 changed files with 37 additions and 105 deletions

View File

@ -30,12 +30,10 @@ let webappsUI = {
switch(aTopic) {
case "webapps-ask-install":
let win = this._getWindowForId(data.oid);
if (win && win.location.href == data.from) {
this.doInstall(data, win);
}
let [chromeWin, browser] = this._getBrowserForId(data.oid);
if (chromeWin)
this.doInstall(data, browser, chromeWin);
break;
case "webapps-launch":
WebappOSUtils.launch(data);
break;
@ -81,14 +79,27 @@ let webappsUI = {
}
},
doInstall: function(aData, aWindow) {
let browser = aWindow.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShell)
.chromeEventHandler;
_getBrowserForId: function(aId) {
let someWindow = Services.wm.getMostRecentWindow(null);
let chromeWin = browser.ownerDocument.defaultView;
let bundle = chromeWin.gNavigatorBundle;
if (someWindow) {
let windowUtils = someWindow.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
let content = windowUtils.getOuterWindowWithId(aId);
if (content) {
let browser = content.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShell).chromeEventHandler;
let win = browser.ownerDocument.defaultView;
return [win, browser];
}
}
return [null, null];
},
doInstall: function(aData, aBrowser, aWindow) {
let bundle = aWindow.gNavigatorBundle;
let mainAction = {
label: bundle.getString("webapps.install"),
@ -102,14 +113,14 @@ let webappsUI = {
}
DOMApplicationRegistry.confirmInstall(aData, false, localDir);
installationSuccessNotification(app, chromeWin);
installationSuccessNotification(app, aWindow);
} else {
DOMApplicationRegistry.denyInstall(aData);
}
}
};
let requestingURI = chromeWin.makeURI(aData.from);
let requestingURI = aWindow.makeURI(aData.from);
let manifest = new DOMApplicationManifest(aData.app.manifest, aData.app.origin);
let host;
@ -120,18 +131,11 @@ let webappsUI = {
}
let message = bundle.getFormattedString("webapps.requestInstall",
[manifest.name, host]);
[manifest.name, host], 2);
chromeWin.PopupNotifications.show(browser, "webapps-install", message,
"webapps-notification-icon", mainAction);
},
aWindow.PopupNotifications.show(aBrowser, "webapps-install", message,
"webapps-notification-icon", mainAction);
_getWindowForId: function(aId) {
let someWindow = Services.wm.getMostRecentWindow(null);
return someWindow &&
someWindow.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils)
.getOuterWindowWithId(aId);
}
}

View File

@ -16,7 +16,6 @@ DIRS = \
MOCHITEST_CHROME_FILES = \
test_bug_765063.xul \
test_bug_771294.xul \
test_install_app.xul \
test_list_api.xul \
test_install_errors.xul \

View File

@ -12,7 +12,6 @@ include $(DEPTH)/config/autoconf.mk
MOCHITEST_CHROME_FILES = \
bug_765063.xul \
bug_771294.xul \
include.html \
wild_crazy.webapp \
wild_crazy.webapp^headers^ \

View File

@ -6,6 +6,6 @@
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script>
navigator.mozApps.install("http://www.example.com:80/chrome/dom/tests/mochitest/webapps/apps/super_crazy.webapp", null);
history.pushState({}, "", "modified-url");
document.location = "about:blank";
</script>
</window>

View File

@ -1,11 +0,0 @@
<?xml version="1.0"?>
<!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script>
navigator.mozApps.install("http://www.example.com:80/chrome/dom/tests/mochitest/webapps/apps/super_crazy.webapp", null);
window.location = "about:blank";
</script>
</window>

View File

@ -18,22 +18,19 @@
<script>
SimpleTest.waitForExplicitFinish();
var mmListener = {
receiveMessage: function(aMessage) {
ppmm.removeMessageListener("Webapps:Install", mmListener);
var msg = aMessage.json;
is(msg.from.indexOf("modified-url"), -1, "the install origin didn't change");
// Observe app installation and confirm that the install origin didn't change.
var observer = {
observe: function observe(subject, topic, data) {
Services.obs.removeObserver(observer, "webapps-sync-install");
ok(JSON.parse(data).installOrigin == "http://www.example.com",
"the install origin didn't change");
tearDown();
SimpleTest.finish();
}
};
var ppmm = Components.classes["@mozilla.org/parentprocessmessagemanager;1"]
.getService(Components.interfaces.nsIFrameMessageManager);
ppmm.addMessageListener("Webapps:Install", mmListener);
Components.utils.import("resource://gre/modules/Services.jsm");
Services.obs.addObserver(observer, "webapps-sync-install", false);
</script>
<!-- Load a page that initiates an app installation and then immediately

View File

@ -1,53 +0,0 @@
<?xml version="1.0"?>
<!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="Mozilla Bug 771294">
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript" src="apphelper.js"/>
<script type="application/javascript" src="jshelper.js"/>
<script>
SimpleTest.waitForExplicitFinish();
Components.utils.import('resource://gre/modules/Services.jsm');
var blocked = true;
Services.obs.addObserver(
function observeShowing() {
Services.obs.removeObserver(observeShowing, "PopupNotifications-showing");
blocked = false;
},
"PopupNotifications-showing",
false
);
Services.obs.addObserver(
function observeInstalling() {
Services.obs.removeObserver(observeInstalling, "webapps-ask-install");
// Spin the event loop before running the test to give the registry time
// to process the install request and (hopefully not) show the doorhanger.
setTimeout(function verify() {
ok(blocked, "Install panel was blocked after immediate redirect");
tearDown();
SimpleTest.finish();
}, 0);
},
"webapps-ask-install",
false
);
</script>
<!-- Load a page that initiates an app installation and then immediately
- redirects to a page at a different origin. We can't do this directly
- inside this test page, because that would cause the test to hang. -->
<iframe src="http://www.example.com:80/chrome/dom/tests/mochitest/webapps/apps/bug_771294.xul"/>
</window>

View File

@ -241,9 +241,6 @@ PopupNotifications.prototype = {
let notifications = this._getNotificationsForBrowser(browser);
notifications.push(notification);
// Notify observers that we're showing the popup (useful for testing)
this._notify("showing");
let fm = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager);
if (browser == this.tabbrowser.selectedBrowser && fm.activeWindow == this.window) {
// show panel now