Bug 1184186 - Convert robocop testResourceSubstitutions to mochitest-chrome; r=nalexander
authorGeoff Brown <gbrown@mozilla.com>
Mon, 03 Aug 2015 12:00:55 -0600
changeset 287617 3fc1d9ffd07981c15cff6447383ed79710dd3752
parent 287616 4e05c3afe0e088176a720bdd594c283008f3f4d5
child 287618 2d440acf37fe4fd69d0735fe5cafcfef34c7a62b
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnalexander
bugs1184186
milestone42.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 1184186 - Convert robocop testResourceSubstitutions to mochitest-chrome; r=nalexander
mobile/android/tests/browser/chrome/chrome.ini
mobile/android/tests/browser/chrome/test_resource_substitutions.html
mobile/android/tests/browser/robocop/robocop.ini
mobile/android/tests/browser/robocop/testResourceSubstitutions.java
mobile/android/tests/browser/robocop/testResourceSubstitutions.js
--- a/mobile/android/tests/browser/chrome/chrome.ini
+++ b/mobile/android/tests/browser/chrome/chrome.ini
@@ -1,6 +1,7 @@
 [DEFAULT]
 skip-if = os != 'android'
 support-files =
 
 [test_about_logins.html]
 [test_app_constants.html]
+[test_resource_substitutions.html]
new file mode 100644
--- /dev/null
+++ b/mobile/android/tests/browser/chrome/test_resource_substitutions.html
@@ -0,0 +1,72 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=948465
+Migrated from Robocop: https://bugzilla.mozilla.org/show_bug.cgi?id=1184186
+-->
+<head>
+  <meta charset="utf-8">
+  <title>Test for Bug 948465</title>
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
+  <link rel="stylesheet" type="text/css" href="chrome://global/skin"/>
+  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
+  <script type="application/javascript;version=1.7">
+
+  const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
+
+  Cu.import("resource://gre/modules/Promise.jsm"); /*global Promise */
+  Cu.import("resource://gre/modules/Services.jsm"); /*global Services */
+  Cu.import("resource://gre/modules/NetUtil.jsm"); /*global NetUtil */
+
+  function readChannel(url) {
+    let deferred = Promise.defer();
+
+    let channel = NetUtil.newChannel({uri: url, loadUsingSystemPrincipal: true});
+
+    channel.contentType = "text/plain";
+
+    NetUtil.asyncFetch(channel, function(inputStream, status) {
+      if (!Components.isSuccessCode(status)) {
+        deferred.reject();
+        return;
+      }
+
+      let content = NetUtil.readInputStreamToString(inputStream, inputStream.available());
+      deferred.resolve(content);
+    });
+
+    return deferred.promise;
+  }
+
+  add_task(function* () {
+    let protocolHandler = Services.io
+       .getProtocolHandler("resource")
+       .QueryInterface(Ci.nsIResProtocolHandler);
+
+    ok(protocolHandler.hasSubstitution("android"));
+
+    // This can be any file that we know exists in the root of every APK.
+    let packageName = yield readChannel("resource://android/package-name.txt");
+    info(packageName);
+
+    // It's difficult to fish ANDROID_PACKAGE_NAME from JavaScript, so we test the
+    // following weaker condition.
+    let expectedPrefix = "org.mozilla.";
+    is(packageName.substring(0, expectedPrefix.length), expectedPrefix);
+  });
+
+  </script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=948465">Mozilla Bug 948465</a>
+<br>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1184186">Migrated from Robocop testResourceSubstitutions</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+</pre>
+</body>
+</html>
--- a/mobile/android/tests/browser/robocop/robocop.ini
+++ b/mobile/android/tests/browser/robocop/robocop.ini
@@ -129,17 +129,16 @@ skip-if = android_version == "18"
 [testNetworkManager.java]
 [testOfflinePage.java]
 [testOrderedBroadcast.java]
 [testOSLocale.java]
 # disabled on 2.3 and 4.3: Bug 1124494
 skip-if = android_version == "10" || android_version == "18"
 [testReaderView.java]
 [testReadingListCache.java]
-[testResourceSubstitutions.java]
 [testRestrictedProfiles.java]
 [testRestrictions.java]
 [testSessionFormData.java]
 [testSharedPreferences.java]
 [testSimpleDiscovery.java]
 [testTrackingProtection.java]
 # disabled on 4.3, bug 1158363
 skip-if = android_version == "18"
deleted file mode 100644
--- a/mobile/android/tests/browser/robocop/testResourceSubstitutions.java
+++ /dev/null
@@ -1,13 +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/. */
-
-package org.mozilla.gecko.tests;
-
-
-
-public class testResourceSubstitutions extends JavascriptTest {
-    public testResourceSubstitutions() {
-        super("testResourceSubstitutions.js");
-    }
-}
deleted file mode 100644
--- a/mobile/android/tests/browser/robocop/testResourceSubstitutions.js
+++ /dev/null
@@ -1,48 +0,0 @@
-// -*- indent-tabs-mode: nil; js-indent-level: 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/. */
-
-const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
-
-Cu.import("resource://gre/modules/Promise.jsm"); /*global Promise */
-Cu.import("resource://gre/modules/Services.jsm"); /*global Services */
-Cu.import("resource://gre/modules/NetUtil.jsm"); /*global NetUtil */
-
-function readChannel(url) {
-  let deferred = Promise.defer();
-
-  let channel = NetUtil.newChannel({uri: url, loadUsingSystemPrincipal: true});
-
-  channel.contentType = "text/plain";
-
-  NetUtil.asyncFetch(channel, function(inputStream, status) {
-    if (!Components.isSuccessCode(status)) {
-      deferred.reject();
-      return;
-    }
-
-    let content = NetUtil.readInputStreamToString(inputStream, inputStream.available());
-    deferred.resolve(content);
-  });
-
-  return deferred.promise;
-}
-
-add_task(function test_Android() {
-    let protocolHandler = Services.io
-       .getProtocolHandler("resource")
-       .QueryInterface(Ci.nsIResProtocolHandler);
-
-    do_check_true(protocolHandler.hasSubstitution("android"));
-
-    // This can be any file that we know exists in the root of every APK.
-    let packageName = yield readChannel("resource://android/package-name.txt");
-
-    // It's difficult to fish ANDROID_PACKAGE_NAME from JavaScript, so we test the
-    // following weaker condition.
-    let expectedPrefix = "org.mozilla.";
-    do_check_eq(packageName.substring(0, expectedPrefix.length), expectedPrefix);
-});
-
-run_next_test();