mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 771294 - Install App doorhanger remains visible when installing page immediately loads another page. r=myk
--HG-- rename : dom/tests/mochitest/webapps/bug_765063.xul => dom/tests/mochitest/webapps/install_and_redirect_helper.xul
This commit is contained in:
parent
cacd35ced5
commit
dfc9d0934f
@ -34,9 +34,10 @@ this.webappsUI = {
|
|||||||
|
|
||||||
switch(aTopic) {
|
switch(aTopic) {
|
||||||
case "webapps-ask-install":
|
case "webapps-ask-install":
|
||||||
let [chromeWin, browser] = this._getBrowserForId(data.oid);
|
let win = this._getWindowForId(data.oid);
|
||||||
if (chromeWin)
|
if (win && win.location.href == data.from) {
|
||||||
this.doInstall(data, browser, chromeWin);
|
this.doInstall(data, win);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "webapps-launch":
|
case "webapps-launch":
|
||||||
WebappOSUtils.launch(data);
|
WebappOSUtils.launch(data);
|
||||||
@ -47,6 +48,13 @@ this.webappsUI = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_getWindowForId: function(aId) {
|
||||||
|
let someWindow = Services.wm.getMostRecentWindow(null);
|
||||||
|
return someWindow && someWindow.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||||
|
.getInterface(Ci.nsIDOMWindowUtils)
|
||||||
|
.getOuterWindowWithId(aId);
|
||||||
|
},
|
||||||
|
|
||||||
openURL: function(aUrl, aOrigin) {
|
openURL: function(aUrl, aOrigin) {
|
||||||
let browserEnumerator = Services.wm.getEnumerator("navigator:browser");
|
let browserEnumerator = Services.wm.getEnumerator("navigator:browser");
|
||||||
let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
|
let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
|
||||||
@ -86,21 +94,13 @@ this.webappsUI = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_getBrowserForId: function(aId) {
|
doInstall: function(aData, aWindow) {
|
||||||
let content = Services.wm.getOuterWindowWithId(aId);
|
let browser = aWindow.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||||
if (content) {
|
.getInterface(Ci.nsIWebNavigation)
|
||||||
let browser = content.QueryInterface(Ci.nsIInterfaceRequestor)
|
.QueryInterface(Ci.nsIDocShell)
|
||||||
.getInterface(Ci.nsIWebNavigation)
|
.chromeEventHandler;
|
||||||
.QueryInterface(Ci.nsIDocShell).chromeEventHandler;
|
let chromeWin = browser.ownerDocument.defaultView;
|
||||||
let win = browser.ownerDocument.defaultView;
|
let bundle = chromeWin.gNavigatorBundle;
|
||||||
return [win, browser];
|
|
||||||
}
|
|
||||||
|
|
||||||
return [null, null];
|
|
||||||
},
|
|
||||||
|
|
||||||
doInstall: function(aData, aBrowser, aWindow) {
|
|
||||||
let bundle = aWindow.gNavigatorBundle;
|
|
||||||
|
|
||||||
let mainAction = {
|
let mainAction = {
|
||||||
label: bundle.getString("webapps.install"),
|
label: bundle.getString("webapps.install"),
|
||||||
@ -117,7 +117,7 @@ this.webappsUI = {
|
|||||||
DOMApplicationRegistry.confirmInstall(aData, false, localDir, null,
|
DOMApplicationRegistry.confirmInstall(aData, false, localDir, null,
|
||||||
function (aManifest) {
|
function (aManifest) {
|
||||||
if (WebappsInstaller.install(aData, aManifest)) {
|
if (WebappsInstaller.install(aData, aManifest)) {
|
||||||
installationSuccessNotification(aData, app, aWindow);
|
installationSuccessNotification(aData, app, chromeWin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -127,7 +127,7 @@ this.webappsUI = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let requestingURI = aWindow.makeURI(aData.from);
|
let requestingURI = chromeWin.makeURI(aData.from);
|
||||||
let jsonManifest = aData.isPackage ? aData.app.updateManifest : aData.app.manifest;
|
let jsonManifest = aData.isPackage ? aData.app.updateManifest : aData.app.manifest;
|
||||||
let manifest = new ManifestHelper(jsonManifest, aData.app.origin);
|
let manifest = new ManifestHelper(jsonManifest, aData.app.origin);
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ this.webappsUI = {
|
|||||||
let message = bundle.getFormattedString("webapps.requestInstall",
|
let message = bundle.getFormattedString("webapps.requestInstall",
|
||||||
[manifest.name, host], 2);
|
[manifest.name, host], 2);
|
||||||
|
|
||||||
aWindow.PopupNotifications.show(aBrowser, "webapps-install", message,
|
chromeWin.PopupNotifications.show(browser, "webapps-install", message,
|
||||||
"webapps-notification-icon", mainAction);
|
"webapps-notification-icon", mainAction);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,11 +11,12 @@ relativesrcdir = @relativesrcdir@
|
|||||||
include $(DEPTH)/config/autoconf.mk
|
include $(DEPTH)/config/autoconf.mk
|
||||||
|
|
||||||
MOCHITEST_CHROME_FILES = \
|
MOCHITEST_CHROME_FILES = \
|
||||||
bug_765063.xul \
|
install_and_redirect_helper.xul \
|
||||||
cross_origin.html \
|
cross_origin.html \
|
||||||
head.js \
|
head.js \
|
||||||
test_bug_765063.xul \
|
test_bug_765063.xul \
|
||||||
test_bug_795164.xul \
|
test_bug_795164.xul \
|
||||||
|
test_bug_771294.xul \
|
||||||
test_cross_origin.xul \
|
test_cross_origin.xul \
|
||||||
test_install_app.xul \
|
test_install_app.xul \
|
||||||
test_list_api.xul \
|
test_list_api.xul \
|
||||||
|
@ -3,8 +3,7 @@
|
|||||||
<!-- Any copyright is dedicated to the Public Domain.
|
<!-- Any copyright is dedicated to the Public Domain.
|
||||||
- http://creativecommons.org/publicdomain/zero/1.0/ -->
|
- http://creativecommons.org/publicdomain/zero/1.0/ -->
|
||||||
|
|
||||||
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||||
title="Mozilla Bug 765063 Helper">
|
|
||||||
<script>
|
<script>
|
||||||
var url = "http://test/chrome/dom/tests/mochitest/webapps/apps/basic.webapp";
|
var url = "http://test/chrome/dom/tests/mochitest/webapps/apps/basic.webapp";
|
||||||
navigator.mozApps.install(url, null);
|
navigator.mozApps.install(url, null);
|
@ -22,26 +22,23 @@ SimpleTest.waitForExplicitFinish();
|
|||||||
|
|
||||||
makeAllAppsLaunchable();
|
makeAllAppsLaunchable();
|
||||||
|
|
||||||
var url = "http://test/chrome/dom/tests/mochitest/webapps/apps/basic.webapp";
|
var mmListener = {
|
||||||
|
receiveMessage: function(aMessage) {
|
||||||
|
ppmm.removeMessageListener("Webapps:Install", mmListener);
|
||||||
|
|
||||||
// Observe app installation and confirm that the install origin didn't change.
|
var msg = aMessage.json;
|
||||||
var observer = {
|
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
|
||||||
observe: function observe(subject, topic, data) {
|
.getService(Components.interfaces.nsIIOService);
|
||||||
Services.obs.removeObserver(observer, "webapps-sync-install");
|
var uri = ioService.newURI(msg.from, null, null);
|
||||||
is(JSON.parse(data).installOrigin, "http://test",
|
is(uri.prePath, "http://test", "the install origin didn't change");
|
||||||
"the install origin didn't change");
|
|
||||||
|
|
||||||
navigator.mozApps.mgmt.getAll().onsuccess = function onGetAll() {
|
SimpleTest.finish();
|
||||||
var app = [a for (a of this.result) if (a.manifestURL == url)][0];
|
|
||||||
navigator.mozApps.mgmt.uninstall(app).onsuccess = function onUninstall() {
|
|
||||||
SimpleTest.finish();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
var ppmm = Components.classes["@mozilla.org/parentprocessmessagemanager;1"]
|
||||||
Services.obs.addObserver(observer, "webapps-sync-install", false);
|
.getService(Components.interfaces.nsIMessageBroadcaster);
|
||||||
|
ppmm.addMessageListener("Webapps:Install", mmListener);
|
||||||
|
|
||||||
// We call this here, even though the app is installed by the helper page,
|
// We call this here, even though the app is installed by the helper page,
|
||||||
// because the helper page redirect would cause its install listener to unload
|
// because the helper page redirect would cause its install listener to unload
|
||||||
@ -53,6 +50,6 @@ confirmNextInstall();
|
|||||||
<!-- Load a page that initiates an app installation and then immediately
|
<!-- 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
|
- 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. -->
|
- inside this test page, because that would cause the test to hang. -->
|
||||||
<iframe src="http://test/chrome/dom/tests/mochitest/webapps/bug_765063.xul"/>
|
<iframe src="http://test/chrome/dom/tests/mochitest/webapps/install_and_redirect_helper.xul"/>
|
||||||
|
|
||||||
</window>
|
</window>
|
||||||
|
62
dom/tests/mochitest/webapps/test_bug_771294.xul
Normal file
62
dom/tests/mochitest/webapps/test_bug_771294.xul
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
<?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="head.js"/>
|
||||||
|
<!-- test results are displayed in the html:body -->
|
||||||
|
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=771294"
|
||||||
|
target="_blank">Mozilla Bug 771294</a>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
const Ci = Components.interfaces;
|
||||||
|
const Cu = Components.utils;
|
||||||
|
|
||||||
|
SimpleTest.waitForExplicitFinish();
|
||||||
|
|
||||||
|
makeAllAppsLaunchable();
|
||||||
|
|
||||||
|
Cu.import("resource://gre/modules/Services.jsm");
|
||||||
|
Cu.import("resource://gre/modules/PopupNotifications.jsm");
|
||||||
|
|
||||||
|
let blocked = true;
|
||||||
|
|
||||||
|
window.top.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||||
|
.getInterface(Ci.nsIWebNavigation)
|
||||||
|
.QueryInterface(Ci.nsIDocShell)
|
||||||
|
.chromeEventHandler.ownerDocument.defaultView
|
||||||
|
.PopupNotifications.panel
|
||||||
|
.addEventListener("popupshowing", function() {
|
||||||
|
blocked = false;
|
||||||
|
}, 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");
|
||||||
|
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://test/chrome/dom/tests/mochitest/webapps/install_and_redirect_helper.xul"/>
|
||||||
|
|
||||||
|
</window>
|
Loading…
Reference in New Issue
Block a user