Backed out changeset 61fc517d0336 (bug 1044736)
authorWes Kocher <wkocher@mozilla.com>
Mon, 17 Nov 2014 22:44:01 -0800
changeset 216074 fa6d6ca97c393f51428dc4828b4ea9ffb1e06cb0
parent 216073 3f6dd413b4187b9ddbed75f378dc3cf3aa629a1e
child 216075 4efb2b966b3372ace762cc87cd0ebddc6e428aa8
push id27839
push userkwierso@gmail.com
push dateTue, 18 Nov 2014 06:49:50 +0000
treeherdermozilla-central@2a292d225ec0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1044736
milestone36.0a1
backs out61fc517d0336ad0ce36db3beab213f7c3a7201b0
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
Backed out changeset 61fc517d0336 (bug 1044736)
dom/apps/tests/file_test_widget.js
dom/apps/tests/mochitest.ini
dom/apps/tests/test_widget.html
deleted file mode 100644
--- a/dom/apps/tests/file_test_widget.js
+++ /dev/null
@@ -1,217 +0,0 @@
-var gWidgetManifestURL = 'http://test/tests/dom/apps/tests/file_app.sjs?apptype=widget&getmanifest=true';
-var gInvalidWidgetManifestURL = 'http://test/tests/dom/apps/tests/file_app.sjs?apptype=invalidWidget&getmanifest=true';
-var gApp;
-
-function onError() {
-  ok(false, "Error callback invoked");
-  finish();
-}
-
-function installApp(path) {
-  var request = navigator.mozApps.install(path);
-  request.onerror = onError;
-  request.onsuccess = function() {
-    gApp = request.result;
-
-    runTest();
-  }
-}
-
-function uninstallApp() {
-  // Uninstall the app.
-  var request = navigator.mozApps.mgmt.uninstall(gApp);
-  request.onerror = onError;
-  request.onsuccess = function() {
-    // All done.
-    info("All done");
-
-    runTest();
-  }
-}
-
-function testApp(isValidWidget) {
-  info("Test widget feature. IsValidWidget: " + isValidWidget);
-
-  var ifr = document.createElement('iframe');
-  ifr.setAttribute('mozbrowser', 'true');
-  ifr.setAttribute('mozwidget', gApp.manifestURL);
-  ifr.setAttribute('src', gApp.origin+gApp.manifest.launch_path);
-
-  var domParent = document.getElementById('container');
-  domParent.appendChild(ifr);
-
-  var mm = SpecialPowers.getBrowserFrameMessageManager(ifr);
-  mm.addMessageListener('OK', function(msg) {
-    ok(isValidWidget, "Message from widget: " + SpecialPowers.wrap(msg).json);
-  });
-  mm.addMessageListener('KO', function(msg) {
-    ok(!isValidWidget, "Message from widget: " + SpecialPowers.wrap(msg).json);
-  });
-  mm.addMessageListener('DONE', function(msg) {
-    ok(true, "Message from widget complete: "+SpecialPowers.wrap(msg).json);
-    domParent.removeChild(ifr);
-    runTest();
-  });
-
-  ifr.addEventListener('mozbrowserloadend', function() {
-    ok(true, "receive mozbrowserloadend");
-
-    // Test limited browser API feature only for valid widget case
-    if (isValidWidget) {
-      testLimitedBrowserAPI(ifr);
-    }
-    SimpleTest.executeSoon(()=>loadFrameScript(mm));
-  }, false);
-
-  // Test limited browser API feature only for valid widget case
-  if (!isValidWidget) {
-    return;
-  }
-
-  [
-    'mozbrowsertitlechange',
-    'mozbrowseropenwindow',
-    'mozbrowserscroll',
-    'mozbrowserasyncscroll'
-  ].forEach( function(topic) {
-    ifr.addEventListener(topic, function() {
-      ok(false, topic + " should be hidden");
-    }, false);
-  });
-}
-
-function testLimitedBrowserAPI(ifr) {
-  var securitySensitiveCalls = [
-    'sendMouseEvent',
-    'sendTouchEvent',
-    'goBack',
-    'goForward',
-    'reload',
-    'stop',
-    'download',
-    'purgeHistory',
-    'getScreenshot',
-    'zoom',
-    'getCanGoBack',
-    'getCanGoForward'
-  ];
-  securitySensitiveCalls.forEach( function(call) {
-    is(typeof ifr[call], "undefined", call + " should be hidden for widget");
-  });
-}
-
-function loadFrameScript(mm) {
-  var script = 'data:,\
-  function ok(p, msg) { \
-  if (p) { \
-  sendAsyncMessage("OK", msg); \
-} else { \
-  sendAsyncMessage("KO", msg); \
-} \
-} \
-  \
-  function is(a, b, msg) { \
-  if (a == b) { \
-  sendAsyncMessage("OK", a + " == " + b + " - " + msg); \
-} else { \
-  sendAsyncMessage("KO", a + " != " + b + " - " + msg); \
-} \
-} \
-  \
-  function finish() { \
-  sendAsyncMessage("DONE",""); \
-} \
-  \
-  function onError() { \
-  ok(false, "Error callback invoked"); \
-  finish(); \
-} \
-  \
-  function checkWidget(widget) { \
-  /*For invalid widget case, ignore the following check*/\
-  if (widget) { \
-  var widgetName = "Really Rapid Release (APPTYPETOKEN)"; \
-  is(widget.origin, "http://test", "Widget origin should be correct"); \
-  is(widget.installOrigin, "http://mochi.test:8888", "Install origin should be correct"); \
-} \
-  finish(); \
-} \
-  \
-  var request = content.window.navigator.mozApps.getSelf(); \
-  request.onsuccess = function() { \
-  var widget = request.result; \
-  ok(widget,"Should be a widget"); \
-  checkWidget(widget); \
-}; \
-  request.onerror = onError; \
-  content.window.open("about:blank"); /*test mozbrowseropenwindow*/ \
-  content.window.scrollTo(4000, 4000); /*test mozbrowser(async)scroll*/ \
-  ';
-  mm.loadFrameScript(script, /* allowDelayedLoad = */ false);
-}
-
-var tests = [
-  // Permissions
-  function() {
-    SpecialPowers.pushPermissions(
-      [{ "type": "browser", "allow": 1, "context": document },
-       { "type": "embed-widgets", "allow": 1, "context": document },
-       { "type": "webapps-manage", "allow": 1, "context": document }], runTest);
-  },
-
-  // Preferences
-  function() {
-    SpecialPowers.pushPrefEnv({"set": [["dom.mozBrowserFramesEnabled", true],
-                                       ["dom.enable_widgets", true],
-                                       ["dom.datastore.sysMsgOnChangeShortTimeoutSec", 1],
-                                       ["dom.datastore.sysMsgOnChangeLongTimeoutSec", 3]]}, runTest);
-  },
-
-  function() {
-    if (SpecialPowers.isMainProcess()) {
-      SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
-    }
-
-    SpecialPowers.setAllAppsLaunchable(true);
-    runTest();
-  },
-
-  // No confirmation needed when an app is installed
-  function() {
-    SpecialPowers.autoConfirmAppInstall(() => {
-      SpecialPowers.autoConfirmAppUninstall(runTest);
-    });
-  },
-
-  // Installing the app
-  ()=>installApp(gWidgetManifestURL),
-
-  // Run tests in app
-  ()=>testApp(true),
-
-  // Uninstall the app
-  uninstallApp,
-
-  // Installing the app for invalid widget case
-  ()=>installApp(gInvalidWidgetManifestURL),
-
-  // Run tests in app for invalid widget case
-  ()=>testApp(false),
-
-  // Uninstall the app
-  uninstallApp
-];
-
-function runTest() {
-  if (!tests.length) {
-    finish();
-    return;
-  }
-
-  var test = tests.shift();
-  test();
-}
-
-function finish() {
-  SimpleTest.finish();
-}
--- a/dom/apps/tests/mochitest.ini
+++ b/dom/apps/tests/mochitest.ini
@@ -12,17 +12,16 @@ support-files =
   file_manifest.json^headers^
   file_trusted_app.template.webapp
   file_invalidWidget_app.template.webapp
   file_packaged_app.sjs
   file_packaged_app.template.html
   file_packaged_app.template.webapp
   file_widget_app.template.webapp
   file_widget_app.template.html
-  file_test_widget.js
   signed_app.sjs
   signed_app_template.webapp
   signed/*
   test_packaged_app_common.js
   marketplace/*
   pkg_install_iframe.html
 
 [test_app_enabled.html]
--- a/dom/apps/tests/test_widget.html
+++ b/dom/apps/tests/test_widget.html
@@ -1,17 +1,235 @@
 <!DOCTYPE HTML>
 <html>
 <head>
   <meta charset="utf-8">
   <title>Test for DataStore - basic operation on a readonly db</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="file_test_widget.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 </head>
 <body>
 <div id="container"></div>
   <script type="application/javascript;version=1.7">
+
+  var gWidgetManifestURL = 'http://test/tests/dom/apps/tests/file_app.sjs?apptype=widget&getmanifest=true';
+  var gInvalidWidgetManifestURL = 'http://test/tests/dom/apps/tests/file_app.sjs?apptype=invalidWidget&getmanifest=true';
+  var gApp;
+
+  function onError() {
+    ok(false, "Error callback invoked");
+    finish();
+  }
+
+  function installApp(path) {
+    var request = navigator.mozApps.install(path);
+    request.onerror = onError;
+    request.onsuccess = function() {
+      gApp = request.result;
+
+      runTest();
+    }
+  }
+
+  function uninstallApp() {
+    // Uninstall the app.
+    var request = navigator.mozApps.mgmt.uninstall(gApp);
+    request.onerror = onError;
+    request.onsuccess = function() {
+      // All done.
+      info("All done");
+
+      runTest();
+    }
+  }
+
+  function testApp(isValidWidget) {
+    info("Test widget feature. IsValidWidget: " + isValidWidget);
+
+    var ifr = document.createElement('iframe');
+    ifr.setAttribute('mozbrowser', 'true');
+    ifr.setAttribute('mozwidget', gApp.manifestURL);
+    ifr.setAttribute('src', gApp.origin+gApp.manifest.launch_path);
+
+    var domParent = document.getElementById('container');
+    domParent.appendChild(ifr);
+
+    var mm = SpecialPowers.getBrowserFrameMessageManager(ifr);
+    mm.addMessageListener('OK', function(msg) {
+      ok(isValidWidget, "Message from widget: " + SpecialPowers.wrap(msg).json);
+    });
+    mm.addMessageListener('KO', function(msg) {
+      ok(!isValidWidget, "Message from widget: " + SpecialPowers.wrap(msg).json);
+    });
+    mm.addMessageListener('DONE', function(msg) {
+      ok(true, "Message from widget complete: "+SpecialPowers.wrap(msg).json);
+      domParent.removeChild(ifr);
+      runTest();
+    });
+
+    ifr.addEventListener('mozbrowserloadend', function() {
+      ok(true, "receive mozbrowserloadend");
+
+      // Test limited browser API feature only for valid widget case
+      if (isValidWidget) {
+        testLimitedBrowserAPI(ifr);
+      }
+      SimpleTest.executeSoon(()=>loadFrameScript(mm));
+    }, false);
+
+    // Test limited browser API feature only for valid widget case
+    if (!isValidWidget) {
+      return;
+    }
+
+    [
+      'mozbrowsertitlechange',
+      'mozbrowseropenwindow',
+      'mozbrowserscroll',
+      'mozbrowserasyncscroll'
+    ].forEach( function(topic) {
+      ifr.addEventListener(topic, function() {
+        ok(false, topic + " should be hidden");
+      }, false);
+    });
+  }
+
+  function testLimitedBrowserAPI(ifr) {
+    var securitySensitiveCalls = [
+      'sendMouseEvent',
+      'sendTouchEvent',
+      'goBack',
+      'goForward',
+      'reload',
+      'stop',
+      'download',
+      'purgeHistory',
+      'getScreenshot',
+      'zoom',
+      'getCanGoBack',
+      'getCanGoForward'
+    ];
+    securitySensitiveCalls.forEach( function(call) {
+      is(typeof ifr[call], "undefined", call + " should be hidden for widget");
+    });
+  }
+
+  function loadFrameScript(mm) {
+    var script = 'data:,\
+      function ok(p, msg) { \
+        if (p) { \
+          sendAsyncMessage("OK", msg); \
+        } else { \
+          sendAsyncMessage("KO", msg); \
+        } \
+      } \
+      \
+      function is(a, b, msg) { \
+        if (a == b) { \
+          sendAsyncMessage("OK", a + " == " + b + " - " + msg); \
+        } else { \
+          sendAsyncMessage("KO", a + " != " + b + " - " + msg); \
+        } \
+      } \
+      \
+      function finish() { \
+          sendAsyncMessage("DONE",""); \
+      } \
+      \
+      function onError() { \
+        ok(false, "Error callback invoked"); \
+        finish(); \
+      } \
+      \
+      function checkWidget(widget) { \
+        /*For invalid widget case, ignore the following check*/\
+        if (widget) { \
+          var widgetName = "Really Rapid Release (APPTYPETOKEN)"; \
+          is(widget.origin, "http://test", "Widget origin should be correct"); \
+          is(widget.installOrigin, "http://mochi.test:8888", "Install origin should be correct"); \
+        } \
+        finish(); \
+      } \
+      \
+      var request = content.window.navigator.mozApps.getSelf(); \
+      request.onsuccess = function() { \
+        var widget = request.result; \
+        ok(widget,"Should be a widget"); \
+        checkWidget(widget); \
+      }; \
+      request.onerror = onError; \
+      content.window.open("about:blank"); /*test mozbrowseropenwindow*/ \
+      content.window.scrollTo(4000, 4000); /*test mozbrowser(async)scroll*/ \
+      ';
+    mm.loadFrameScript(script, /* allowDelayedLoad = */ false);
+  }
+
+  var tests = [
+    // Permissions
+    function() {
+      SpecialPowers.pushPermissions(
+        [{ "type": "browser", "allow": 1, "context": document },
+         { "type": "embed-widgets", "allow": 1, "context": document },
+         { "type": "webapps-manage", "allow": 1, "context": document }], runTest);
+    },
+
+    // Preferences
+    function() {
+      SpecialPowers.pushPrefEnv({"set": [["dom.mozBrowserFramesEnabled", true],
+                                         ["dom.enable_widgets", true],
+                                         ["dom.datastore.sysMsgOnChangeShortTimeoutSec", 1],
+                                         ["dom.datastore.sysMsgOnChangeLongTimeoutSec", 3]]}, runTest);
+    },
+
+    function() {
+      if (SpecialPowers.isMainProcess()) {
+        SpecialPowers.Cu.import("resource://gre/modules/DataStoreChangeNotifier.jsm");
+      }
+
+      SpecialPowers.setAllAppsLaunchable(true);
+      runTest();
+    },
+
+    // No confirmation needed when an app is installed
+    function() {
+      SpecialPowers.autoConfirmAppInstall(() => {
+        SpecialPowers.autoConfirmAppUninstall(runTest);
+      });
+    },
+
+    // Installing the app
+    ()=>installApp(gWidgetManifestURL),
+
+    // Run tests in app
+    ()=>testApp(true),
+
+    // Uninstall the app
+    uninstallApp,
+
+    // Installing the app for invalid widget case
+    ()=>installApp(gInvalidWidgetManifestURL),
+
+    // Run tests in app for invalid widget case
+    ()=>testApp(false),
+
+    // Uninstall the app
+    uninstallApp
+  ];
+
+  function runTest() {
+    if (!tests.length) {
+      finish();
+      return;
+    }
+
+    var test = tests.shift();
+    test();
+  }
+
+  function finish() {
+    SimpleTest.finish();
+  }
+
   SimpleTest.waitForExplicitFinish();
   runTest();
   </script>
 </body>
 </html>