Bug 1288885: Migrate localStorage mochitests to xpcshell. r=aswan
authorKris Maglione <maglione.k@gmail.com>
Wed, 27 Jul 2016 21:47:53 -0700
changeset 332231 f8d2367b1c62e9069bece909234c62320ec4f692
parent 332230 af745bd5c20928ef776a7c94c76cb9c87ac77c71
child 332232 642065cf0f131ce85447290ad737c0857dae9e65
push id9858
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 14:37:10 +0000
treeherdermozilla-aurora@203106ef6cb6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaswan
bugs1288885
milestone50.0a1
Bug 1288885: Migrate localStorage mochitests to xpcshell. r=aswan MozReview-Commit-ID: 1sjpnsKYEv5
toolkit/components/extensions/test/mochitest/mochitest.ini
toolkit/components/extensions/test/mochitest/test_ext_localStorage.html
toolkit/components/extensions/test/xpcshell/test_ext_localStorage.js
toolkit/components/extensions/test/xpcshell/xpcshell.ini
--- a/toolkit/components/extensions/test/mochitest/mochitest.ini
+++ b/toolkit/components/extensions/test/mochitest/mochitest.ini
@@ -47,17 +47,16 @@ skip-if = buildapp == 'b2g' # runat != d
 [test_ext_contentscript_create_iframe.html]
 [test_ext_contentscript_devtools_metadata.html]
 [test_ext_contentscript_exporthelpers.html]
 [test_ext_contentscript_css.html]
 [test_ext_downloads.html]
 [test_ext_exclude_include_globs.html]
 [test_ext_i18n_css.html]
 [test_ext_generate.html]
-[test_ext_localStorage.html]
 [test_ext_notifications.html]
 [test_ext_permission_xhr.html]
 skip-if = buildapp == 'b2g' # JavaScript error: jar:remoteopenfile:///data/local/tmp/generated-extension.xpi!/content.js, line 46: NS_ERROR_ILLEGAL_VALUE:
 [test_ext_runtime_connect.html]
 skip-if = (os == 'android' || buildapp == 'b2g') # port.sender.tab is undefined on b2g. Bug 1258975 on android.
 [test_ext_runtime_connect_twoway.html]
 skip-if = (os == 'android' || buildapp == 'b2g') # port.sender.tab is undefined on b2g. Bug 1258975 on android.
 [test_ext_runtime_connect2.html]
rename from toolkit/components/extensions/test/mochitest/test_ext_localStorage.html
rename to toolkit/components/extensions/test/xpcshell/test_ext_localStorage.js
--- a/toolkit/components/extensions/test/mochitest/test_ext_localStorage.html
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_localStorage.js
@@ -1,21 +1,10 @@
-<!DOCTYPE HTML>
-<html>
-<head>
-  <title>WebExtension test</title>
-  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
-  <script type="text/javascript" src="/tests/SimpleTest/ExtensionTestUtils.js"></script>
-  <script type="text/javascript" src="head.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-</head>
-<body>
-
-<script type="text/javascript">
+/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim: set sts=2 sw=2 et tw=80: */
 "use strict";
 
 function backgroundScript() {
   let hasRun = localStorage.getItem("has-run");
   let result;
   if (!hasRun) {
     localStorage.setItem("has-run", "yup");
     localStorage.setItem("test-item", "item1");
@@ -33,28 +22,28 @@ function backgroundScript() {
       result = "cleared";
     }
   }
   browser.test.sendMessage("result", result);
   browser.test.notifyPass("localStorage");
 }
 
 let extensionData = {
-  background: "(" + backgroundScript.toString() + ")()",
+  background: backgroundScript,
 };
 
-add_task(function* test_contentscript() {
+add_task(function* test_localStorage() {
   let id = "test-webextension@mozilla.com";
   const RESULTS = ["item1", "item2", "deleted", "cleared", "item1"];
 
   for (let expected of RESULTS) {
     let extension = ExtensionTestUtils.loadExtension(extensionData, id);
-    let [, actual] = yield Promise.all([extension.startup(), extension.awaitMessage("result")]);
+
+    yield extension.startup();
+
+    let actual = yield extension.awaitMessage("result");
+
     yield extension.awaitFinish("localStorage");
     yield extension.unload();
 
-    is(actual, expected, "got expected localStorage data");
+    equal(actual, expected, "got expected localStorage data");
   }
 });
-</script>
-
-</body>
-</html>
--- a/toolkit/components/extensions/test/xpcshell/xpcshell.ini
+++ b/toolkit/components/extensions/test/xpcshell/xpcshell.ini
@@ -7,16 +7,17 @@ skip-if = toolkit == 'gonk' || appname =
 [test_csp_custom_policies.js]
 [test_csp_validator.js]
 [test_ext_alarms.js]
 [test_ext_background_runtime_connect_params.js]
 [test_ext_contexts.js]
 [test_ext_extension.js]
 [test_ext_idle.js]
 [test_ext_json_parser.js]
+[test_ext_localStorage.js]
 [test_ext_manifest_content_security_policy.js]
 [test_ext_manifest_incognito.js]
 [test_ext_onmessage_removelistener.js]
 [test_ext_runtime_connect_no_receiver.js]
 [test_ext_runtime_getPlatformInfo.js]
 [test_ext_runtime_sendMessage.js]
 [test_ext_runtime_sendMessage_no_receiver.js]
 [test_ext_schemas.js]