bug 765063 - save installURL for later use; r=fabrice

--HG--
extra : rebase_source : 7360e295a4549d29d2667a0c8e38708959df7f40
This commit is contained in:
Myk Melez 2012-07-05 11:12:55 -07:00
parent c54af9a8f3
commit 618d1fd23a
5 changed files with 56 additions and 2 deletions

View File

@ -119,6 +119,8 @@ WebappsRegistry.prototype = {
// mozIDOMApplicationRegistry implementation
install: function(aURL, aParams) {
let installURL = this._window.location.href;
let installOrigin = this._getOrigin(installURL);
let request = this.createRequest();
let requestID = this.getRequestId(request);
let xhr = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Ci.nsIXMLHttpRequest);
@ -127,7 +129,6 @@ WebappsRegistry.prototype = {
xhr.addEventListener("load", (function() {
if (xhr.status == 200) {
try {
let installOrigin = this._getOrigin(this._window.location.href);
let manifest = JSON.parse(xhr.responseText, installOrigin);
if (!this.checkManifest(manifest, installOrigin)) {
Services.DOMRequest.fireError(request, "INVALID_MANIFEST");
@ -138,7 +139,7 @@ WebappsRegistry.prototype = {
manifestURL: aURL,
manifest: manifest,
receipts: receipts },
from: this._window.location.href,
from: installURL,
oid: this._id,
requestID: requestID });
}

View File

@ -17,6 +17,7 @@ DIRS = \
include $(topsrcdir)/config/rules.mk
_TEST_FILES = \
test_bug_765063.xul \
test_install_app.xul \
test_list_api.xul \
test_install_errors.xul \

View File

@ -13,6 +13,7 @@ include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
_TEST_FILES = \
bug_765063.xul \
include.html \
wild_crazy.webapp \
wild_crazy.webapp^headers^ \

View File

@ -0,0 +1,11 @@
<?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);
document.location = "about:blank";
</script>
</window>

View File

@ -0,0 +1,40 @@
<?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 765063">
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript" src="apphelper.js"/>
<!-- We only need jshelper.js for debug(), which apphelper.js calls. But
- since we include it, we also let it call apphelper.js's popup_listener(),
- which listens for the install doorhanger and presses its main button. -->
<script type="application/javascript" src="jshelper.js"/>
<script>
SimpleTest.waitForExplicitFinish();
// Observe app installation and confirm that the install origin didn't change.
var observer = {
observe: function observe(subject, topic, data) {
ok(JSON.parse(data).installOrigin == "http://www.example.com",
"the install origin didn't change");
tearDown();
SimpleTest.finish();
}
};
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
- 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_765063.xul"/>
</window>