mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 899322 - Convert the mozApps API to use webidl r=marco,bholley
This commit is contained in:
parent
0c1e0e0a57
commit
3c97fffc91
@ -30,7 +30,6 @@
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIDocShellTreeOwner.h"
|
||||
#include "nsIDocShellLoadInfo.h"
|
||||
#include "nsIDOMApplicationRegistry.h"
|
||||
#include "nsIBaseWindow.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIXPConnect.h"
|
||||
|
@ -249,7 +249,11 @@ this.DOMApplicationRegistry = {
|
||||
if (!DOMApplicationRegistry.webapps[aId]) {
|
||||
return;
|
||||
}
|
||||
return DOMApplicationRegistry.webapps[aId][prop];
|
||||
|
||||
if (prop in DOMApplicationRegistry.webapps[aId]) {
|
||||
return DOMApplicationRegistry.webapps[aId][prop];
|
||||
}
|
||||
return null;
|
||||
},
|
||||
set: function(target, prop, val) {
|
||||
if (!DOMApplicationRegistry.webapps[aId]) {
|
||||
|
@ -18,20 +18,16 @@ XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
|
||||
"@mozilla.org/childprocessmessagemanager;1",
|
||||
"nsIMessageSender");
|
||||
|
||||
function debug(aMsg) {
|
||||
dump("-*- Webapps.js " + aMsg + "\n");
|
||||
}
|
||||
|
||||
function convertAppsArray(aApps, aWindow) {
|
||||
let apps = new aWindow.Array();
|
||||
for (let i = 0; i < aApps.length; i++) {
|
||||
let app = aApps[i];
|
||||
// Our application objects are JS-implemented XPCOM objects with DOM_OBJECT
|
||||
// set in classinfo. These objects are reflector-per-scope, so as soon as we
|
||||
// pass them to content, we'll end up with a new object in content. But from
|
||||
// this code, they _appear_ to be chrome objects, and so the Array Xray code
|
||||
// vetos the attempt to define a chrome-privileged object on a content Array.
|
||||
// Very carefully waive Xrays so that this can keep working until we convert
|
||||
// mozApps to WebIDL in bug 899322.
|
||||
Cu.waiveXrays(apps)[i] = createApplicationObject(aWindow, app);
|
||||
}
|
||||
|
||||
aApps.forEach((aApp) => {
|
||||
let obj = createContentApplicationObject(aWindow, aApp);
|
||||
apps.push(obj);
|
||||
});
|
||||
return apps;
|
||||
}
|
||||
|
||||
@ -52,7 +48,7 @@ WebappsRegistry.prototype = {
|
||||
switch (aMessage.name) {
|
||||
case "Webapps:Install:Return:OK":
|
||||
this.removeMessageListeners("Webapps:Install:Return:KO");
|
||||
Services.DOMRequest.fireSuccess(req, createApplicationObject(this._window, app));
|
||||
Services.DOMRequest.fireSuccess(req, createContentApplicationObject(this._window, app));
|
||||
cpmm.sendAsyncMessage("Webapps:Install:Return:Ack",
|
||||
{ manifestURL : app.manifestURL });
|
||||
break;
|
||||
@ -64,7 +60,7 @@ WebappsRegistry.prototype = {
|
||||
this.removeMessageListeners(aMessage.name);
|
||||
if (msg.apps.length) {
|
||||
app = msg.apps[0];
|
||||
Services.DOMRequest.fireSuccess(req, createApplicationObject(this._window, app));
|
||||
Services.DOMRequest.fireSuccess(req, createContentApplicationObject(this._window, app));
|
||||
} else {
|
||||
Services.DOMRequest.fireSuccess(req, null);
|
||||
}
|
||||
@ -215,8 +211,14 @@ WebappsRegistry.prototype = {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!this._mgmt)
|
||||
this._mgmt = new WebappsApplicationMgmt(this._window);
|
||||
if (!this._mgmt) {
|
||||
let mgmt = Cc["@mozilla.org/webapps/manager;1"]
|
||||
.createInstance(Ci.nsISupports);
|
||||
mgmt.wrappedJSObject.init(this._window);
|
||||
this._mgmt = mgmt.__DOM_IMPL__
|
||||
? mgmt.__DOM_IMPL__
|
||||
: this._window.DOMApplicationsManager._create(this._window, mgmt.wrappedJSObject);
|
||||
}
|
||||
return this._mgmt;
|
||||
},
|
||||
|
||||
@ -262,30 +264,27 @@ WebappsRegistry.prototype = {
|
||||
classID: Components.ID("{fff440b3-fae2-45c1-bf03-3b5a2e432270}"),
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsISupportsWeakReference,
|
||||
Ci.nsISupports,
|
||||
Ci.nsIObserver,
|
||||
Ci.mozIDOMApplicationRegistry,
|
||||
Ci.mozIDOMApplicationRegistry2,
|
||||
Ci.nsIDOMGlobalPropertyInitializer]),
|
||||
|
||||
classInfo: XPCOMUtils.generateCI({classID: Components.ID("{fff440b3-fae2-45c1-bf03-3b5a2e432270}"),
|
||||
contractID: "@mozilla.org/webapps;1",
|
||||
interfaces: [Ci.mozIDOMApplicationRegistry,
|
||||
Ci.mozIDOMApplicationRegistry2],
|
||||
flags: Ci.nsIClassInfo.DOM_OBJECT,
|
||||
classDescription: "Webapps Registry"})
|
||||
Ci.nsIDOMGlobalPropertyInitializer])
|
||||
}
|
||||
|
||||
/**
|
||||
* mozIDOMApplication object
|
||||
* DOMApplication object
|
||||
*/
|
||||
|
||||
function createApplicationObject(aWindow, aApp) {
|
||||
let app = Cc["@mozilla.org/webapps/application;1"]
|
||||
.createInstance(Ci.mozIDOMApplication);
|
||||
.createInstance(Ci.nsISupports);
|
||||
app.wrappedJSObject.init(aWindow, aApp);
|
||||
return app;
|
||||
}
|
||||
|
||||
function createContentApplicationObject(aWindow, aApp) {
|
||||
return createApplicationObject(aWindow, aApp).wrappedJSObject
|
||||
._prepareForContent();
|
||||
}
|
||||
|
||||
function WebappsApplication() {
|
||||
this.wrappedJSObject = this;
|
||||
}
|
||||
@ -301,12 +300,6 @@ WebappsApplication.prototype = {
|
||||
|
||||
this._window = aWindow;
|
||||
|
||||
this._onprogress = null;
|
||||
this._ondownloadsuccess = null;
|
||||
this._ondownloaderror = null;
|
||||
this._ondownloadavailable = null;
|
||||
this._ondownloadapplied = null;
|
||||
|
||||
this.initDOMRequestHelper(aWindow);
|
||||
},
|
||||
|
||||
@ -358,14 +351,6 @@ WebappsApplication.prototype = {
|
||||
return this._proxy.readyToApplyDownload;
|
||||
},
|
||||
|
||||
get receipts() {
|
||||
return this._proxy.receipts;
|
||||
},
|
||||
|
||||
set receipts(aReceipts) {
|
||||
this._proxy.receipts = aReceipts;
|
||||
},
|
||||
|
||||
get removable() {
|
||||
return this._proxy.removable;
|
||||
},
|
||||
@ -387,43 +372,47 @@ WebappsApplication.prototype = {
|
||||
},
|
||||
|
||||
set onprogress(aCallback) {
|
||||
this._onprogress = aCallback;
|
||||
this.__DOM_IMPL__.setEventHandler("onprogress", aCallback);
|
||||
},
|
||||
|
||||
get onprogress() {
|
||||
return this._onprogress;
|
||||
return this.__DOM_IMPL__.getEventHandler("onprogress");
|
||||
},
|
||||
|
||||
set ondownloadsuccess(aCallback) {
|
||||
this._ondownloadsuccess = aCallback;
|
||||
this.__DOM_IMPL__.setEventHandler("ondownloadsuccess", aCallback);
|
||||
},
|
||||
|
||||
get ondownloadsuccess() {
|
||||
return this._ondownloadsuccess;
|
||||
return this.__DOM_IMPL__.getEventHandler("ondownloadsuccess");
|
||||
},
|
||||
|
||||
set ondownloaderror(aCallback) {
|
||||
this._ondownloaderror = aCallback;
|
||||
this.__DOM_IMPL__.setEventHandler("ondownloaderror", aCallback);
|
||||
},
|
||||
|
||||
get ondownloaderror() {
|
||||
return this._ondownloaderror;
|
||||
return this.__DOM_IMPL__.getEventHandler("ondownloaderror");
|
||||
},
|
||||
|
||||
set ondownloadavailable(aCallback) {
|
||||
this._ondownloadavailable = aCallback;
|
||||
this.__DOM_IMPL__.setEventHandler("ondownloadavailable", aCallback);
|
||||
},
|
||||
|
||||
get ondownloadavailable() {
|
||||
return this._ondownloadavailable;
|
||||
return this.__DOM_IMPL__.getEventHandler("ondownloadavailable");
|
||||
},
|
||||
|
||||
set ondownloadapplied(aCallback) {
|
||||
this._ondownloadapplied = aCallback;
|
||||
this.__DOM_IMPL__.setEventHandler("ondownloadapplied", aCallback);
|
||||
},
|
||||
|
||||
get ondownloadapplied() {
|
||||
return this._ondownloadapplied;
|
||||
return this.__DOM_IMPL__.getEventHandler("ondownloadapplied");
|
||||
},
|
||||
|
||||
get receipts() {
|
||||
return this._proxy.receipts;
|
||||
},
|
||||
|
||||
get downloadError() {
|
||||
@ -558,23 +547,23 @@ WebappsApplication.prototype = {
|
||||
return request;
|
||||
},
|
||||
|
||||
_prepareForContent: function() {
|
||||
if (this.__DOM_IMPL__) {
|
||||
return this.__DOM_IMPL__;
|
||||
}
|
||||
return this._window.DOMApplication._create(this._window, this.wrappedJSObject);
|
||||
},
|
||||
|
||||
uninit: function() {
|
||||
this._onprogress = null;
|
||||
WrappedManifestCache.evict(this.manifestURL, this.innerWindowID);
|
||||
},
|
||||
|
||||
_fireEvent: function(aName) {
|
||||
let handler = this["_on" + aName];
|
||||
if (handler) {
|
||||
let event = new this._window.MozApplicationEvent(aName, {
|
||||
application: this
|
||||
});
|
||||
try {
|
||||
handler.handleEvent(event);
|
||||
} catch (ex) {
|
||||
dump("Event handler expection " + ex + "\n");
|
||||
}
|
||||
}
|
||||
let obj = this._prepareForContent();
|
||||
let event = new this._window.MozApplicationEvent(aName, {
|
||||
application: obj
|
||||
});
|
||||
obj.dispatchEvent(event);
|
||||
},
|
||||
|
||||
_fireRequestResult: function(aMessage, aIsError) {
|
||||
@ -649,7 +638,7 @@ WebappsApplication.prototype = {
|
||||
case "Webapps:AddReceipt:Return:OK":
|
||||
this.removeMessageListeners(["Webapps:AddReceipt:Return:OK",
|
||||
"Webapps:AddReceipt:Return:KO"]);
|
||||
this.receipts = msg.receipts;
|
||||
this._proxy.receipts = msg.receipts;
|
||||
Services.DOMRequest.fireSuccess(req, null);
|
||||
break;
|
||||
case "Webapps:AddReceipt:Return:KO":
|
||||
@ -660,7 +649,7 @@ WebappsApplication.prototype = {
|
||||
case "Webapps:RemoveReceipt:Return:OK":
|
||||
this.removeMessageListeners(["Webapps:RemoveReceipt:Return:OK",
|
||||
"Webapps:RemoveReceipt:Return:KO"]);
|
||||
this.receipts = msg.receipts;
|
||||
this._proxy.receipts = msg.receipts;
|
||||
Services.DOMRequest.fireSuccess(req, null);
|
||||
break;
|
||||
case "Webapps:RemoveReceipt:Return:KO":
|
||||
@ -671,7 +660,7 @@ WebappsApplication.prototype = {
|
||||
case "Webapps:ReplaceReceipt:Return:OK":
|
||||
this.removeMessageListeners(["Webapps:ReplaceReceipt:Return:OK",
|
||||
"Webapps:ReplaceReceipt:Return:KO"]);
|
||||
this.receipts = msg.receipts;
|
||||
this._proxy.receipts = msg.receipts;
|
||||
Services.DOMRequest.fireSuccess(req, null);
|
||||
break;
|
||||
case "Webapps:ReplaceReceipt:Return:KO":
|
||||
@ -684,52 +673,37 @@ WebappsApplication.prototype = {
|
||||
|
||||
classID: Components.ID("{723ed303-7757-4fb0-b261-4f78b1f6bd22}"),
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.mozIDOMApplication,
|
||||
Ci.nsISupportsWeakReference,
|
||||
Ci.nsIObserver]),
|
||||
|
||||
classInfo: XPCOMUtils.generateCI({classID: Components.ID("{723ed303-7757-4fb0-b261-4f78b1f6bd22}"),
|
||||
contractID: "@mozilla.org/webapps/application;1",
|
||||
interfaces: [Ci.mozIDOMApplication],
|
||||
flags: Ci.nsIClassInfo.DOM_OBJECT,
|
||||
classDescription: "Webapps Application"})
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports,
|
||||
Ci.nsIObserver,
|
||||
Ci.nsISupportsWeakReference])
|
||||
}
|
||||
|
||||
/**
|
||||
* mozIDOMApplicationMgmt object
|
||||
* DOMApplicationsManager object
|
||||
*/
|
||||
function WebappsApplicationMgmt(aWindow) {
|
||||
this.initDOMRequestHelper(aWindow, ["Webapps:Uninstall:Return:OK",
|
||||
"Webapps:Uninstall:Broadcast:Return:OK",
|
||||
"Webapps:Uninstall:Return:KO",
|
||||
"Webapps:Install:Return:OK",
|
||||
"Webapps:GetNotInstalled:Return:OK"]);
|
||||
|
||||
cpmm.sendAsyncMessage("Webapps:RegisterForMessages",
|
||||
{
|
||||
messages: ["Webapps:Install:Return:OK",
|
||||
"Webapps:Uninstall:Return:OK",
|
||||
"Webapps:Uninstall:Broadcast:Return:OK"]
|
||||
}
|
||||
);
|
||||
|
||||
this._oninstall = null;
|
||||
this._onuninstall = null;
|
||||
function WebappsApplicationMgmt() {
|
||||
this.wrappedJSObject = this;
|
||||
}
|
||||
|
||||
WebappsApplicationMgmt.prototype = {
|
||||
__proto__: DOMRequestIpcHelper.prototype,
|
||||
__exposedProps__: {
|
||||
applyDownload: "r",
|
||||
getAll: "r",
|
||||
getNotInstalled: "r",
|
||||
oninstall: "rw",
|
||||
onuninstall: "rw"
|
||||
},
|
||||
|
||||
init: function(aWindow) {
|
||||
this.initDOMRequestHelper(aWindow, ["Webapps:Uninstall:Return:OK",
|
||||
"Webapps:Uninstall:Broadcast:Return:OK",
|
||||
"Webapps:Uninstall:Return:KO",
|
||||
"Webapps:Install:Return:OK",
|
||||
"Webapps:GetNotInstalled:Return:OK"]);
|
||||
cpmm.sendAsyncMessage("Webapps:RegisterForMessages",
|
||||
{
|
||||
messages: ["Webapps:Install:Return:OK",
|
||||
"Webapps:Uninstall:Return:OK",
|
||||
"Webapps:Uninstall:Broadcast:Return:OK"]
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
uninit: function() {
|
||||
this._oninstall = null;
|
||||
this._onuninstall = null;
|
||||
cpmm.sendAsyncMessage("Webapps:UnregisterForMessages",
|
||||
["Webapps:Install:Return:OK",
|
||||
"Webapps:Uninstall:Return:OK",
|
||||
@ -773,19 +747,19 @@ WebappsApplicationMgmt.prototype = {
|
||||
},
|
||||
|
||||
get oninstall() {
|
||||
return this._oninstall;
|
||||
return this.__DOM_IMPL__.getEventHandler("oninstall");
|
||||
},
|
||||
|
||||
get onuninstall() {
|
||||
return this._onuninstall;
|
||||
return this.__DOM_IMPL__.getEventHandler("onuninstall");
|
||||
},
|
||||
|
||||
set oninstall(aCallback) {
|
||||
this._oninstall = aCallback;
|
||||
this.__DOM_IMPL__.setEventHandler("oninstall", aCallback);
|
||||
},
|
||||
|
||||
set onuninstall(aCallback) {
|
||||
this._onuninstall = aCallback;
|
||||
this.__DOM_IMPL__.setEventHandler("onuninstall", aCallback);
|
||||
},
|
||||
|
||||
receiveMessage: function(aMessage) {
|
||||
@ -803,18 +777,23 @@ WebappsApplicationMgmt.prototype = {
|
||||
Services.DOMRequest.fireSuccess(req, convertAppsArray(msg.apps, this._window));
|
||||
break;
|
||||
case "Webapps:Install:Return:OK":
|
||||
if (this._oninstall) {
|
||||
let app = msg.app;
|
||||
let event = new this._window.MozApplicationEvent("applicationinstall",
|
||||
{ application : createApplicationObject(this._window, app) });
|
||||
this._oninstall.handleEvent(event);
|
||||
{
|
||||
let app = createContentApplicationObject(this._window, msg.app);
|
||||
let event =
|
||||
new this._window.MozApplicationEvent("install", { application: app });
|
||||
this.__DOM_IMPL__.dispatchEvent(event);
|
||||
}
|
||||
break;
|
||||
case "Webapps:Uninstall:Broadcast:Return:OK":
|
||||
if (this._onuninstall) {
|
||||
let event = new this._window.MozApplicationEvent("applicationuninstall",
|
||||
{ application : createApplicationObject(this._window, msg) });
|
||||
this._onuninstall.handleEvent(event);
|
||||
{
|
||||
let detail = {
|
||||
manifestURL: msg.manifestURL,
|
||||
origin: msg.origin
|
||||
};
|
||||
let app = createContentApplicationObject(this._window, detail);
|
||||
let event =
|
||||
new this._window.MozApplicationEvent("uninstall", { application : app });
|
||||
this.__DOM_IMPL__.dispatchEvent(event);
|
||||
}
|
||||
break;
|
||||
case "Webapps:Uninstall:Return:OK":
|
||||
@ -831,16 +810,11 @@ WebappsApplicationMgmt.prototype = {
|
||||
|
||||
classID: Components.ID("{8c1bca96-266f-493a-8d57-ec7a95098c15}"),
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.mozIDOMApplicationMgmt,
|
||||
Ci.nsISupportsWeakReference,
|
||||
Ci.nsIObserver]),
|
||||
|
||||
classInfo: XPCOMUtils.generateCI({classID: Components.ID("{8c1bca96-266f-493a-8d57-ec7a95098c15}"),
|
||||
contractID: "@mozilla.org/webapps/application-mgmt;1",
|
||||
interfaces: [Ci.mozIDOMApplicationMgmt],
|
||||
flags: Ci.nsIClassInfo.DOM_OBJECT,
|
||||
classDescription: "Webapps Application Mgmt"})
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports,
|
||||
Ci.nsIObserver,
|
||||
Ci.nsISupportsWeakReference])
|
||||
}
|
||||
|
||||
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([WebappsRegistry,
|
||||
WebappsApplicationMgmt,
|
||||
WebappsApplication]);
|
||||
|
@ -1,10 +1,9 @@
|
||||
# Webapps.js
|
||||
component {fff440b3-fae2-45c1-bf03-3b5a2e432270} Webapps.js
|
||||
contract @mozilla.org/webapps;1 {fff440b3-fae2-45c1-bf03-3b5a2e432270}
|
||||
category JavaScript-navigator-property mozApps @mozilla.org/webapps;1
|
||||
|
||||
component {8c1bca96-266f-493a-8d57-ec7a95098c15} Webapps.js
|
||||
contract @mozilla.org/webapps/manager;1 {8c1bca96-266f-493a-8d57-ec7a95098c15}
|
||||
|
||||
component {723ed303-7757-4fb0-b261-4f78b1f6bd22} Webapps.js
|
||||
contract @mozilla.org/webapps/application;1 {723ed303-7757-4fb0-b261-4f78b1f6bd22}
|
||||
|
||||
component {dcc1d5b7-43d8-4740-9244-b3d8db0f503d} Webapps.js
|
||||
contract @mozilla.org/dom-error;1 {dcc1d5b7-43d8-4740-9244-b3d8db0f503d}
|
||||
|
@ -208,4 +208,4 @@ addLoadEvent(go);
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
@ -44,8 +44,8 @@ function finish() {
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
function cbError(aError) {
|
||||
ok(false, "Error callback invoked " + aError);
|
||||
function cbError(aEvent) {
|
||||
ok(false, "Error callback invoked " + aEvent.target.error.name);
|
||||
finish();
|
||||
}
|
||||
|
||||
@ -64,6 +64,7 @@ function runTest() {
|
||||
|
||||
var app = request.result;
|
||||
ok(app, "App is non-null");
|
||||
info("receipts are " + app.receipts);
|
||||
ok(app.receipts.length == 0, "No receipts");
|
||||
|
||||
let receipt1 = 'eyJhbGciOiAiSFMyNTYiLCAidHlwIjogIkpXVCJ9.eyJwcm9kdWN0IjogeyJ1cmwiOiAiaHR0cHM6Ly93d3cubW96aWxsYS5vcmciLCAic3RvcmVkYXRhIjogIjUxNjkzMTQzNTYifSwgInJlaXNzdWUiOiAiaHR0cDovL21vY2hpLnRlc3Q6ODg4OC9yZWlzc3VlLzUxNjkzMTQzNTYiLCAidXNlciI6IHsidHlwZSI6ICJkaXJlY3RlZC1pZGVudGlmaWVyIiwgInZhbHVlIjogIjRmYjM1MTUxLTJiOWItNGJhMi04MjgzLWM0OWQzODE2NDBiZCJ9LCAidmVyaWZ5IjogImh0dHA6Ly9tb2NoaS50ZXN0Ojg4ODgvdmVyaWZ5LzUxNjkzMTQzNTYiLCAiaXNzIjogImh0dHA6Ly9tb2NoaS50ZXN0Ojg4ODgiLCAiaWF0IjogMTMxMzYwMTg4LCAidHlwIjogInB1cmNoYXNlLXJlY2VpcHQiLCAibmJmIjogMTMxMzYwMTg1LCAiZGV0YWlsIjogImh0dHA6Ly9tb2NoaS50ZXN0Ojg4ODgvcmVjZWlwdC81MTY5MzE0MzU2In0.eZpTEnCLUR3iP3rm9WyJOqx1k66mQaAxqcrvX11r5E0';
|
||||
@ -96,12 +97,12 @@ function runTest() {
|
||||
yield undefined;
|
||||
|
||||
// Test addReceipt
|
||||
request = app.addReceipt(null);
|
||||
request = app.addReceipt();
|
||||
request.onsuccess = function() {
|
||||
ok(false, "Call with missing parameter should've failed");
|
||||
}
|
||||
request.onerror = function() {
|
||||
ok(this.error.name == "INVALID_PARAMETERS",
|
||||
is(this.error.name, "INVALID_PARAMETERS",
|
||||
"Request failed because of a missing parameter");
|
||||
continueTest();
|
||||
}
|
||||
@ -110,8 +111,8 @@ function runTest() {
|
||||
request = app.addReceipt(receipt1);
|
||||
request.onerror = cbError;
|
||||
request.onsuccess = function() {
|
||||
ok(app.receipts.length == 1, "One receipt");
|
||||
ok(app.receipts[0] == receipt1, "Receipt correctly added");
|
||||
is(app.receipts.length, 1, "One receipt");
|
||||
is(app.receipts[0], receipt1, "Receipt correctly added");
|
||||
continueTest();
|
||||
};
|
||||
yield undefined;
|
||||
@ -138,7 +139,7 @@ function runTest() {
|
||||
yield undefined;
|
||||
|
||||
// Test replace receipts
|
||||
request = app.replaceReceipt(null, null);
|
||||
request = app.replaceReceipt();
|
||||
request.onsuccess = function() {
|
||||
ok(false, "Call with missing parameters should've failed");
|
||||
}
|
||||
@ -149,18 +150,7 @@ function runTest() {
|
||||
}
|
||||
yield undefined;
|
||||
|
||||
request = app.replaceReceipt(null, receipt1);
|
||||
request.onsuccess = function() {
|
||||
ok(false, "Call with missing parameter should've failed");
|
||||
}
|
||||
request.onerror = function() {
|
||||
ok(this.error.name == "INVALID_PARAMETERS",
|
||||
"Request failed because of a missing parameter");
|
||||
continueTest();
|
||||
}
|
||||
yield undefined;
|
||||
|
||||
request = app.replaceReceipt(receipt1, null);
|
||||
request = app.replaceReceipt(receipt1);
|
||||
request.onsuccess = function() {
|
||||
ok(false, "Call with missing parameter should've failed");
|
||||
}
|
||||
@ -196,7 +186,7 @@ function runTest() {
|
||||
yield undefined;
|
||||
|
||||
// Test remove receipt
|
||||
request = app.removeReceipt(null);
|
||||
request = app.removeReceipt();
|
||||
request.onsuccess = function() {
|
||||
ok(false, "Call with missing parameter should've failed");
|
||||
}
|
||||
|
@ -1978,7 +1978,6 @@ def addExternalIface(iface, nativeType=None, headerFile=None,
|
||||
addExternalIface('ApplicationCache', nativeType='nsIDOMOfflineResourceList')
|
||||
addExternalIface('Counter')
|
||||
addExternalIface('CSSRule')
|
||||
addExternalIface('mozIDOMApplication', nativeType='mozIDOMApplication', headerFile='nsIDOMApplicationRegistry.h')
|
||||
addExternalIface('RTCDataChannel', nativeType='nsIDOMDataChannel')
|
||||
addExternalIface('File')
|
||||
addExternalIface('HitRegionOptions', nativeType='nsISupports')
|
||||
|
@ -8,7 +8,6 @@ XPIDL_SOURCES += [
|
||||
'mozIApplication.idl',
|
||||
'mozIApplicationClearPrivateDataParams.idl',
|
||||
'nsIAppsService.idl',
|
||||
'nsIDOMApplicationRegistry.idl',
|
||||
'nsIInterAppCommService.idl',
|
||||
'nsIInterAppCommUIGlue.idl'
|
||||
]
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
#include "domstubs.idl"
|
||||
|
||||
interface mozIDOMApplication;
|
||||
interface mozIApplication;
|
||||
interface nsIURI;
|
||||
|
||||
|
@ -1,201 +0,0 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "domstubs.idl"
|
||||
#include "nsIDOMEventTarget.idl"
|
||||
|
||||
interface nsIDOMDOMRequest;
|
||||
|
||||
[scriptable, uuid(f8cb08ed-588e-465f-b2b3-a4b0afde711a)]
|
||||
interface mozIDOMApplication : nsISupports
|
||||
{
|
||||
readonly attribute jsval manifest;
|
||||
readonly attribute jsval updateManifest;
|
||||
readonly attribute DOMString manifestURL;
|
||||
readonly attribute jsval receipts; /* an array of strings */
|
||||
readonly attribute DOMString origin;
|
||||
readonly attribute DOMString installOrigin;
|
||||
readonly attribute unsigned long long installTime;
|
||||
readonly attribute boolean removable;
|
||||
|
||||
/**
|
||||
* The current progress when downloading an offline cache.
|
||||
*/
|
||||
readonly attribute double progress;
|
||||
|
||||
/**
|
||||
* The application installation state :
|
||||
* "pending" : The application is being installed (eg, we're downloading the
|
||||
* offline cache or the package).
|
||||
* "installed" : The application is installed and ready to be launched.
|
||||
* "updating" : We are updating the offline-cache or the package.
|
||||
*/
|
||||
readonly attribute DOMString installState;
|
||||
|
||||
/**
|
||||
* fires a nsIDOMApplicationEvent when a change in appcache download or
|
||||
* package download happens.
|
||||
*/
|
||||
attribute nsIDOMEventListener onprogress;
|
||||
|
||||
/**
|
||||
* The date of the last update check.
|
||||
*/
|
||||
readonly attribute unsigned long long lastUpdateCheck;
|
||||
|
||||
/**
|
||||
* The date of the last updated manifest.
|
||||
*/
|
||||
readonly attribute unsigned long long updateTime;
|
||||
|
||||
/**
|
||||
* Starts the process of looking for an update.
|
||||
*/
|
||||
nsIDOMDOMRequest checkForUpdate();
|
||||
|
||||
readonly attribute boolean downloadAvailable;
|
||||
readonly attribute boolean downloading;
|
||||
readonly attribute boolean readyToApplyDownload;
|
||||
readonly attribute long downloadSize;
|
||||
|
||||
// This is a DOMError
|
||||
readonly attribute nsISupports downloadError;
|
||||
|
||||
attribute nsIDOMEventListener ondownloadsuccess;
|
||||
attribute nsIDOMEventListener ondownloaderror;
|
||||
attribute nsIDOMEventListener ondownloadavailable;
|
||||
|
||||
/**
|
||||
* Will fire once the mgmt.applyDownload() call succeeds.
|
||||
*/
|
||||
attribute nsIDOMEventListener ondownloadapplied;
|
||||
|
||||
/**
|
||||
* Starts to download an update. If |downloading| is true, this
|
||||
* is a no-op.
|
||||
*/
|
||||
void download();
|
||||
|
||||
/**
|
||||
* Cancels an ongoing update download.
|
||||
*/
|
||||
void cancelDownload();
|
||||
|
||||
/* startPoint will be used when several launch_path exists for an app */
|
||||
nsIDOMDOMRequest launch([optional] in DOMString startPoint);
|
||||
|
||||
/**
|
||||
* Clear data that has been collected through mozbrowser elements.
|
||||
* onsuccess will be called once data is actually cleared.
|
||||
*/
|
||||
nsIDOMDOMRequest clearBrowserData();
|
||||
|
||||
/**
|
||||
* Inter-App Communication APIs.
|
||||
*
|
||||
* https://wiki.mozilla.org/WebAPI/Inter_App_Communication_Alt_proposal
|
||||
*/
|
||||
nsISupports connect(in DOMString keyword,
|
||||
[optional] in jsval rules); // nsISupports is a Promise.
|
||||
|
||||
nsISupports getConnections(); // nsISupports is a Promise.
|
||||
|
||||
/* Receipts handling functions */
|
||||
nsIDOMDOMRequest addReceipt(in DOMString receipt);
|
||||
nsIDOMDOMRequest removeReceipt(in DOMString receipt);
|
||||
nsIDOMDOMRequest replaceReceipt(in DOMString oldReceipt, in DOMString newReceipt);
|
||||
};
|
||||
|
||||
[scriptable, uuid(cf742022-5ba3-11e2-868f-03310341b006)]
|
||||
interface mozIDOMApplicationMgmt : nsISupports
|
||||
{
|
||||
/**
|
||||
* the request will return the all the applications installed. Only accessible
|
||||
* to privileged callers.
|
||||
*/
|
||||
nsIDOMDOMRequest getAll();
|
||||
|
||||
/**
|
||||
* the request will return the applications acquired from all origins but
|
||||
* which are not launchable (e.g. by not being natively installed), or null.
|
||||
*/
|
||||
nsIDOMDOMRequest getNotInstalled();
|
||||
|
||||
/**
|
||||
* event listener to get notified of application installs. Only settable by
|
||||
* privileged callers.
|
||||
* the event will be a mozIDOMApplicationEvent
|
||||
*/
|
||||
attribute nsIDOMEventListener oninstall;
|
||||
|
||||
/**
|
||||
* event listener to get notified of application uninstalls. Only settable by
|
||||
* privileged callers.
|
||||
* the event will be a mozIDOMApplicationEvent
|
||||
*/
|
||||
attribute nsIDOMEventListener onuninstall;
|
||||
|
||||
/**
|
||||
* Applies a downloaded update.
|
||||
* This function is a no-op if it's passed an app object which doesn't have
|
||||
* |readyToApplyDownload| set to true.
|
||||
*/
|
||||
void applyDownload(in mozIDOMApplication app);
|
||||
|
||||
/**
|
||||
* Uninstall a web app.
|
||||
*
|
||||
* @param app : the app object of the web app to be uninstalled.
|
||||
* @returns : A DOMRequest object, returning the app's origin in |result|
|
||||
* if uninstall succeeds; returning "NOT_INSTALLED" error otherwise.
|
||||
*/
|
||||
nsIDOMDOMRequest uninstall(in mozIDOMApplication app);
|
||||
};
|
||||
|
||||
[scriptable, uuid(52710c5f-b2a2-4b27-b5b9-f679a1bcc79b)]
|
||||
interface mozIDOMApplicationRegistry : nsISupports
|
||||
{
|
||||
/**
|
||||
* Install a web app.
|
||||
*
|
||||
* @param manifestUrl : the URL of the webapps manifest.
|
||||
* @param parameters : A structure with optional information.
|
||||
* {
|
||||
* receipts: ... Will be used to specify the payment receipts for this installation.
|
||||
* categories: ... Will be used to specify the categories of the webapp.
|
||||
* }
|
||||
* @returns : A DOMRequest object, returning the app object in |result| if install succeeds.
|
||||
*/
|
||||
nsIDOMDOMRequest install(in DOMString manifestUrl, [optional] in jsval parameters);
|
||||
|
||||
/**
|
||||
* the request will return the application currently installed, or null.
|
||||
*/
|
||||
nsIDOMDOMRequest getSelf();
|
||||
|
||||
/**
|
||||
* the request will return the application if the app from that origin is installed
|
||||
*/
|
||||
nsIDOMDOMRequest checkInstalled(in DOMString manifestUrl);
|
||||
|
||||
/**
|
||||
* the request will return the applications installed from this origin, or null.
|
||||
*/
|
||||
nsIDOMDOMRequest getInstalled();
|
||||
|
||||
/**
|
||||
* Install a packaged web app.
|
||||
*
|
||||
* @param packageUrl : the URL of the webapps manifest.
|
||||
* @param parameters : A structure with optional information.
|
||||
* {
|
||||
* receipts: ... Will be used to specify the payment receipts for this installation.
|
||||
* categories: ... Will be used to specify the categories of the webapp.
|
||||
* }
|
||||
* @returns : A DOMRequest object, returning the app object in |result| if install succeeds.
|
||||
*/
|
||||
nsIDOMDOMRequest installPackage(in DOMString packageUrl, [optional] in jsval parameters);
|
||||
|
||||
readonly attribute mozIDOMApplicationMgmt mgmt;
|
||||
};
|
@ -16,11 +16,17 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=815105
|
||||
<pre id="test">
|
||||
<script type="application/javascript;version=1.8" src="file_framework.js"></script>
|
||||
<script type="application/javascript;version=1.8">
|
||||
function verifier(success, failure) {
|
||||
if (window.navigator.mozApps.mgmt) {
|
||||
success("Got mozApps.mgmt object!");
|
||||
} else {
|
||||
failure("Failed to get mozApps.mgmt object!");
|
||||
}
|
||||
}
|
||||
var gData = [
|
||||
{
|
||||
perm: ["webapps-manage"],
|
||||
obj: "mozApps.mgmt",
|
||||
idl: "mozIDOMApplicationMgmt",
|
||||
verifier: verifier.toSource(),
|
||||
}
|
||||
]
|
||||
</script>
|
||||
|
@ -639,8 +639,6 @@ var interfaceNamesInGlobalScope =
|
||||
"MouseScrollEvent",
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{name: "MozActivity", b2g: true},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
"MozApplicationEvent",
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{name: "MozCellBroadcast", b2g: true, pref: "dom.cellbroadcast.enabled"},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
|
@ -42,7 +42,7 @@ function noArgs(next) {
|
||||
try {
|
||||
navigator.mozApps.install();
|
||||
} catch (e) {
|
||||
is(e.message, "Not enough arguments \[mozIDOMApplicationRegistry.install\]",
|
||||
is(e.message, "Not enough arguments to DOMApplicationsRegistry.install.",
|
||||
"install without arguments throws exception");
|
||||
next();
|
||||
}
|
||||
|
@ -19,7 +19,6 @@
|
||||
<script>
|
||||
|
||||
var props = {
|
||||
QueryInterface: "function",
|
||||
checkInstalled: "function",
|
||||
getInstalled: "function",
|
||||
getSelf: "function",
|
||||
@ -36,13 +35,18 @@ for (var p in props) {
|
||||
}
|
||||
|
||||
var mgmtProps = {
|
||||
QueryInterface: "function",
|
||||
addEventListener: "function",
|
||||
applyDownload: "function",
|
||||
dispatchEvent: "function",
|
||||
getEventHandler: "function",
|
||||
getAll: "function",
|
||||
getNotInstalled: "function",
|
||||
uninstall: "function",
|
||||
oninstall: "object",
|
||||
onuninstall: "object",
|
||||
ownerGlobal: "object",
|
||||
removeEventListener: "function",
|
||||
setEventHandler: "function",
|
||||
};
|
||||
|
||||
isDeeply([p for (p in navigator.mozApps.mgmt)].sort(),
|
||||
|
96
dom/webidl/Apps.webidl
Normal file
96
dom/webidl/Apps.webidl
Normal file
@ -0,0 +1,96 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
dictionary InstallParameters {
|
||||
sequence<DOMString> receipts = [];
|
||||
sequence<DOMString> categories = [];
|
||||
};
|
||||
|
||||
[NoInterfaceObject, NavigatorProperty="mozApps",
|
||||
JSImplementation="@mozilla.org/webapps;1"]
|
||||
interface DOMApplicationsRegistry {
|
||||
[CheckPermissions="webapps-manage"]
|
||||
readonly attribute DOMApplicationsManager mgmt;
|
||||
DOMRequest install(DOMString url, optional InstallParameters params);
|
||||
DOMRequest installPackage(DOMString url, optional InstallParameters params);
|
||||
DOMRequest getSelf();
|
||||
DOMRequest getInstalled();
|
||||
DOMRequest checkInstalled(DOMString manifestUrl);
|
||||
};
|
||||
|
||||
[JSImplementation="@mozilla.org/webapps/application;1", ChromeOnly]
|
||||
interface DOMApplication : EventTarget {
|
||||
// manifest and updateManifest will be turned into dictionaries once
|
||||
// in bug 1053033 once bug 963382 is fixed.
|
||||
readonly attribute any manifest;
|
||||
readonly attribute any updateManifest;
|
||||
readonly attribute DOMString manifestURL;
|
||||
readonly attribute DOMString origin;
|
||||
readonly attribute DOMString installOrigin;
|
||||
readonly attribute DOMTimeStamp installTime;
|
||||
readonly attribute boolean removable;
|
||||
|
||||
// That's actually a [Cached, Pure] sequence<DOMString>.
|
||||
// Will update once bug 963382 is fixed.
|
||||
readonly attribute any receipts;
|
||||
|
||||
readonly attribute double progress;
|
||||
|
||||
readonly attribute DOMString installState;
|
||||
|
||||
readonly attribute DOMTimeStamp lastUpdateCheck;
|
||||
readonly attribute DOMTimeStamp updateTime;
|
||||
|
||||
readonly attribute boolean downloadAvailable;
|
||||
readonly attribute boolean downloading;
|
||||
readonly attribute boolean readyToApplyDownload;
|
||||
readonly attribute long downloadSize;
|
||||
|
||||
readonly attribute DOMError? downloadError;
|
||||
|
||||
attribute EventHandler onprogress;
|
||||
attribute EventHandler ondownloadsuccess;
|
||||
attribute EventHandler ondownloaderror;
|
||||
attribute EventHandler ondownloadavailable;
|
||||
attribute EventHandler ondownloadapplied;
|
||||
|
||||
void download();
|
||||
void cancelDownload();
|
||||
|
||||
DOMRequest launch(optional DOMString? url);
|
||||
|
||||
DOMRequest clearBrowserData();
|
||||
DOMRequest checkForUpdate();
|
||||
|
||||
/**
|
||||
* Inter-App Communication APIs.
|
||||
*
|
||||
* https://wiki.mozilla.org/WebAPI/Inter_App_Communication_Alt_proposal
|
||||
*
|
||||
*/
|
||||
Promise<MozInterAppConnection> connect(DOMString keyword, optional any rules);
|
||||
|
||||
Promise<sequence<MozInterAppMessagePort>> getConnections();
|
||||
|
||||
// Receipts handling functions.
|
||||
DOMRequest addReceipt(optional DOMString receipt);
|
||||
DOMRequest removeReceipt(optional DOMString receipt);
|
||||
DOMRequest replaceReceipt(optional DOMString oldReceipt,
|
||||
optional DOMString newReceipt);
|
||||
};
|
||||
|
||||
[JSImplementation="@mozilla.org/webapps/manager;1",
|
||||
ChromeOnly,
|
||||
CheckPermissions="webapps-manage"]
|
||||
interface DOMApplicationsManager : EventTarget {
|
||||
DOMRequest getAll();
|
||||
DOMRequest getNotInstalled();
|
||||
void applyDownload(DOMApplication app);
|
||||
DOMRequest uninstall(DOMApplication app);
|
||||
|
||||
attribute EventHandler oninstall;
|
||||
attribute EventHandler onuninstall;
|
||||
};
|
@ -3,15 +3,14 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
interface mozIDOMApplication;
|
||||
|
||||
[Constructor(DOMString type, optional MozApplicationEventInit eventInitDict)]
|
||||
[Constructor(DOMString type, optional MozApplicationEventInit eventInitDict), ChromeOnly]
|
||||
interface MozApplicationEvent : Event
|
||||
{
|
||||
readonly attribute mozIDOMApplication? application;
|
||||
readonly attribute DOMApplication? application;
|
||||
};
|
||||
|
||||
dictionary MozApplicationEventInit : EventInit
|
||||
{
|
||||
mozIDOMApplication? application = null;
|
||||
DOMApplication? application = null;
|
||||
};
|
||||
|
@ -27,6 +27,7 @@ WEBIDL_FILES = [
|
||||
'AnimationTimeline.webidl',
|
||||
'AppInfo.webidl',
|
||||
'AppNotificationServiceOptions.webidl',
|
||||
'Apps.webidl',
|
||||
'APZTestData.webidl',
|
||||
'ArchiveReader.webidl',
|
||||
'ArchiveRequest.webidl',
|
||||
|
Loading…
Reference in New Issue
Block a user