Bug 859631 - Move test_uninstall_errors to dom/apps and avoid UI confirmation. r=fabrice, a=test-only
authorMarco Castelluccio <mar.castelluccio@studenti.unina.it>
Thu, 19 Sep 2013 15:38:45 -0400
changeset 154088 40d5f2078ca9fe75ba026c6ff74c3fd06e9fa75e
parent 154087 1f83dbfd31f2a569838a1b7a2b36c559dc15d8c3
child 154089 ed7ce69c66031e393b667d38111da1d6a0513c3b
push id2875
push userryanvm@gmail.com
push dateMon, 23 Sep 2013 19:50:01 +0000
treeherdermozilla-beta@eda4dbed18fe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfabrice, test-only
bugs859631
milestone25.0
Bug 859631 - Move test_uninstall_errors to dom/apps and avoid UI confirmation. r=fabrice, a=test-only
dom/apps/tests/Makefile.in
dom/apps/tests/test_uninstall_errors.html
dom/tests/mochitest/webapps/Makefile.in
dom/tests/mochitest/webapps/test_uninstall_errors.xul
--- a/dom/apps/tests/Makefile.in
+++ b/dom/apps/tests/Makefile.in
@@ -21,16 +21,17 @@ MOCHITEST_FILES = \
   $(NULL)
 
 ifdef MOZ_B2G
 MOCHITEST_FILES += \
   file_packaged_app.sjs \
   file_packaged_app.template.webapp \
   file_packaged_app.template.html \
   test_packaged_app_install.html \
+  test_uninstall_errors.html \
   $(NULL)
 endif
 
 MOCHITEST_CHROME_FILES = \
   test_apps_service.xul \
   $(NULL)
 
 include $(topsrcdir)/config/rules.mk
new file mode 100644
--- /dev/null
+++ b/dom/apps/tests/test_uninstall_errors.html
@@ -0,0 +1,112 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=830258
+-->
+<head>
+  <meta charset="utf-8">
+  <title>Test for Bug 830258</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+  <script type="application/javascript;version=1.7">
+
+  /** Test for Bug 830258 **/
+
+  SimpleTest.waitForExplicitFinish();
+
+  var url1 = 'http://test1.example.com/tests/dom/apps/tests/file_app.sjs?apptype=hosted&getmanifest=true';
+  var url2 = 'http://test2.example.com/tests/dom/apps/tests/file_app.sjs?apptype=hosted&getmanifest=true';
+
+  var gGenerator = runTest();
+  var launchableValue = undefined;
+
+  function go() {
+    SpecialPowers.pushPermissions(
+      [{ "type": "webapps-manage", "allow": 1, "context": document }],
+      function() { gGenerator.next() });
+  }
+
+  function continueTest() {
+    try { gGenerator.next(); }
+    catch (e) { dump("Got exception: " + e + "\n"); }
+  }
+
+  function mozAppsError() {
+    ok(false, "mozApps error: " + this.error.name);
+    finish();
+  }
+
+  function runTest() {
+    // Set up.
+    launchableValue = SpecialPowers.setAllAppsLaunchable(true);
+    SpecialPowers.autoConfirmAppInstall(continueTest);
+    yield undefined;
+
+    let request = navigator.mozApps.install(url1);
+    request.onerror = mozAppsError;
+    request.onsuccess = continueTest;
+    yield undefined;
+    let app1 = request.result;
+    ok(app1, "App1 is non-null");
+
+    request = navigator.mozApps.install(url2);
+    request.onerror = mozAppsError;
+    request.onsuccess = continueTest;
+    yield undefined;
+    let app2 = request.result;
+    ok(app2, "App2 is non-null");
+
+    request = navigator.mozApps.mgmt.uninstall(app1);
+    request.onsuccess = function() {
+      ok(true, "Succeed to uninstall the app1 as expected");
+      continueTest();
+    };
+    request.onerror = function() {
+      ok(false, "Fail to uninstall the app1");
+      continueTest();
+    };
+    yield undefined;
+
+    request = navigator.mozApps.mgmt.uninstall(app1);
+    request.onsuccess = function() {
+      ok(false, "Shouldn't be able to uninstall the app1 again");
+      continueTest();
+    };
+    request.onerror = function() {
+      is(this.error.name, "NOT_INSTALLED", "Error name should be 'NOT_INSTALLED'");
+      continueTest();
+    };
+    yield undefined;
+
+    var request = navigator.mozApps.mgmt.uninstall(app2);
+    request.onsuccess = function() {
+      ok(true, "Succeed to uninstall the app2 as expected");
+      continueTest();
+    };
+    request.onerror = function() {
+      ok(false, "Fail to uninstall the app2");
+      continueTest();
+    };
+    yield undefined;
+
+    // All done.
+    ok(true, "All done");
+    finish();
+  }
+
+  function finish() {
+    SpecialPowers.setAllAppsLaunchable(launchableValue);
+    SimpleTest.finish();
+  }
+  </script>
+</head>
+<body onload="go()">
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=830258">Mozilla Bug 830258</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+</pre>
+</body>
+</html>
--- a/dom/tests/mochitest/webapps/Makefile.in
+++ b/dom/tests/mochitest/webapps/Makefile.in
@@ -19,17 +19,16 @@ MOCHITEST_CHROME_FILES = \
     test_cross_origin.xul \
     test_install_app.xul \
     test_list_api.xul \
     test_install_errors.xul \
     test_install_utf8.xul \
     test_install_receipts.xul \
     test_getNotInstalled.xul \
     test_launch_paths.xul \
-    test_uninstall_errors.xul \
     $(NULL)
 
 MOCHITEST_FILES = \
     test_bug_779982.html \
     file_bug_779982.js \
     file_bug_779982.html \
     $(NULL)
 
deleted file mode 100644
--- a/dom/tests/mochitest/webapps/test_uninstall_errors.xul
+++ /dev/null
@@ -1,82 +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 830258">
-  <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=830258"
-     target="_blank">Mozilla Bug 830258</a>
-  </body>
-<script>
-
-var url1 = "http://test1.example.com/chrome/dom/tests/mochitest/webapps/apps/basic.webapp";
-var url2 = "http://test2.example.com/chrome/dom/tests/mochitest/webapps/apps/basic.webapp";
-var app1, app2;
-
-var steps = [
-  installTwoApps,
-  uninstallApp1,
-  uninstallApp1Again,
-  uninstallApp2
-];
-
-runAll(steps);
-
-function installTwoApps(next) {
-  confirmNextInstall();
-  navigator.mozApps.install(url1, null).onsuccess = function onInstallApp1(evt) {
-    app1 = evt.target.result;
-    confirmNextInstall();
-    navigator.mozApps.install(url2, null).onsuccess = function onInstallApp2(evt) {
-      app2 = evt.target.result;
-      next();
-    };
-  };
-}
-
-function uninstallApp1(next) {
-  var request = navigator.mozApps.mgmt.uninstall(app1);
-  request.onsuccess = function onUninstallApp1Success() {
-    ok(true, "Succeed to uninstall the app1 as expected");
-    next();
-  };
-  request.onerror = function onUninstallApp1Error() {
-    ok(false, "Fail to uninstall the app1");
-    next();
-  };
-}
-
-function uninstallApp1Again(next) {
-  var request = navigator.mozApps.mgmt.uninstall(app1);
-  request.onsuccess = function onUninstallApp1AgainSuccess() {
-    ok(false, "Shouldn't be able to uninstall the app1 again");
-    next();
-  };
-  request.onerror = function onUninstallApp1AgainError() {
-    is(this.error.name, "NOT_INSTALLED", "Error name should be 'NOT_INSTALLED'");
-    next();
-  };
-}
-
-function uninstallApp2(next) {
-  var request = navigator.mozApps.mgmt.uninstall(app2);
-  request.onsuccess = function onUninstallApp2Success() {
-    ok(true, "Succeed to uninstall the app2 as expected");
-    next();
-  };
-  request.onerror = function onUninstallApp2Error() {
-    ok(false, "Fail to uninstall the app2");
-    next();
-  };
-}
-
-</script>
-</window>