Bug 1006394 - Test installing apps from the webapp runtime. r=myk
authorMarco Castelluccio <mar.castelluccio@studenti.unina.it>
Thu, 09 Oct 2014 22:21:00 -0400
changeset 233201 0738005d0ff59a328a32a6d0ac181884e9d96e0e
parent 233200 d18f4f55dd4e5e845a0ae6d6a22b4dc2bdd7f84a
child 233202 4978e73d44444ad1c1fc009316d0182aefc858f4
push id4187
push userbhearsum@mozilla.com
push dateFri, 28 Nov 2014 15:29:12 +0000
treeherdermozilla-beta@f23cc6a30c11 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmyk
bugs1006394
milestone35.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1006394 - Test installing apps from the webapp runtime. r=myk
webapprt/test/chrome/browser_install-app.js
webapprt/test/chrome/install-app.html
webapprt/test/chrome/install-app.webapp
webapprt/test/chrome/install-app.webapp^headers^
webapprt/test/chrome/webapprt.ini
new file mode 100644
--- /dev/null
+++ b/webapprt/test/chrome/browser_install-app.js
@@ -0,0 +1,49 @@
+Cu.import("resource://gre/modules/Services.jsm");
+let { WebappOSUtils } = Cu.import("resource://gre/modules/WebappOSUtils.jsm", {});
+
+let url = "http://test/webapprtChrome/webapprt/test/chrome/sample.webapp";
+
+function test() {
+  waitForExplicitFinish();
+
+  loadWebapp("install-app.webapp", undefined, function onLoad() {
+
+    let dialogShown = false;
+
+    let winObserver = function(win, topic) {
+      if (topic == "domwindowopened") {
+        win.addEventListener("load", function onLoadWindow() {
+          win.removeEventListener("load", onLoadWindow, false);
+
+          if (win.document.documentURI == "chrome://global/content/commonDialog.xul") {
+            dialogShown = true;
+
+            executeSoon(() => {
+              win.document.documentElement.acceptDialog();
+            });
+          }
+        }, false);
+      }
+    }
+
+    Services.ww.registerNotification(winObserver);
+
+    registerCleanupFunction(function() {
+      Services.ww.unregisterNotification(winObserver);
+    });
+
+    let request = navigator.mozApps.install(url);
+    request.onsuccess = function() {
+      ok(dialogShown, "Install app dialog shown");
+      ok(request.result, "App installed");
+
+      navigator.mozApps.mgmt.uninstall(request.result).onsuccess = function() {
+        finish();
+      }
+    }
+    request.onerror = function() {
+      ok(false, "Not installed: " + request.error.name);
+      finish();
+    }
+  });
+}
new file mode 100644
--- /dev/null
+++ b/webapprt/test/chrome/install-app.html
@@ -0,0 +1,10 @@
+<!DOCTYPE HTML>
+<html>
+  <head>
+    <title>Install Test App</title>
+    <meta charset="utf-8">
+  </head>
+  <body>
+    <h1>Install Test App</h1>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/webapprt/test/chrome/install-app.webapp
@@ -0,0 +1,5 @@
+{
+  "name": "Install Test App",
+  "description": "an app for testing installing apps",
+  "launch_path": "/webapprtChrome/webapprt/test/chrome/install-app.html"
+}
new file mode 100644
--- /dev/null
+++ b/webapprt/test/chrome/install-app.webapp^headers^
@@ -0,0 +1,1 @@
+Content-Type: application/x-web-app-manifest+json
--- a/webapprt/test/chrome/webapprt.ini
+++ b/webapprt/test/chrome/webapprt.ini
@@ -41,23 +41,27 @@ support-files =
   window-open-blank.html
   alarm.html
   alarm.webapp
   alarm.webapp^headers^
   download.html
   download.webapp
   download.webapp^headers^
   download.test
+  install-app.html
+  install-app.webapp
+  install-app.webapp^headers^
 
-[browser_sample.js]
-[browser_window-title.js]
-[browser_webperm.js]
+[browser_alarm.js]
+[browser_debugger.js]
+[browser_download.js]
+[browser_geolocation-prompt-noperm.js]
+[browser_geolocation-prompt-perm.js]
+[browser_getUserMedia.js]
+[browser_install-app.js]
+[browser_mozpay.js]
 [browser_noperm.js]
-[browser_geolocation-prompt-perm.js]
-[browser_geolocation-prompt-noperm.js]
-[browser_debugger.js]
-[browser_mozpay.js]
-[browser_getUserMedia.js]
+[browser_sample.js]
+[browser_webperm.js]
+[browser_window-open-blank.js]
 [browser_window-open-self.js]
 [browser_window-open.js]
-[browser_window-open-blank.js]
-[browser_alarm.js]
-[browser_download.js]
+[browser_window-title.js]