Bug 1288885: Migrate storage mochitests to xpcshell. r?aswan draft
authorKris Maglione <maglione.k@gmail.com>
Fri, 22 Jul 2016 17:32:31 -0700
changeset 392107 3fa6ba1ef4a82fde5af16e4e5f8cd216ee68e49d
parent 392106 15e153637c818e0f1826c0845509f9c2c081ddda
child 392108 10dc22514ed8e3ae6923fdfc3ca6bb271774d633
push id23940
push usermaglione.k@gmail.com
push dateSat, 23 Jul 2016 02:07:34 +0000
reviewersaswan
bugs1288885
milestone50.0a1
Bug 1288885: Migrate storage mochitests to xpcshell. r?aswan MozReview-Commit-ID: 1DYgv3LNDOW
toolkit/components/extensions/test/mochitest/mochitest.ini
toolkit/components/extensions/test/mochitest/test_ext_storage.html
toolkit/components/extensions/test/xpcshell/test_ext_storage.js
toolkit/components/extensions/test/xpcshell/xpcshell.ini
--- a/toolkit/components/extensions/test/mochitest/mochitest.ini
+++ b/toolkit/components/extensions/test/mochitest/mochitest.ini
@@ -63,17 +63,16 @@ skip-if = (os == 'android' || buildapp =
 [test_ext_runtime_id.html]
 [test_ext_sandbox_var.html]
 [test_ext_sendmessage_reply.html]
 skip-if = (os == 'android' || buildapp == 'b2g') # sender.tab is undefined on b2g. Bug 1258975 on android.
 [test_ext_sendmessage_reply2.html]
 skip-if = (os == 'android' || buildapp == 'b2g') # sender.tab is undefined on b2g. Bug 1258975 on android.
 [test_ext_sendmessage_doublereply.html]
 skip-if = (os == 'android' || buildapp == 'b2g') # sender.tab is undefined on b2g. Bug 1258975 on android.
-[test_ext_storage.html]
 [test_ext_storage_content.html]
 [test_ext_storage_tab.html]
 skip-if = os == 'android' # Android does not currently support tabs.
 [test_ext_cookies.html]
 [test_ext_background_window_properties.html]
 [test_ext_background_sub_windows.html]
 [test_ext_background_api_injection.html]
 [test_ext_background_generated_url.html]
rename from toolkit/components/extensions/test/mochitest/test_ext_storage.html
rename to toolkit/components/extensions/test/xpcshell/test_ext_storage.js
--- a/toolkit/components/extensions/test/mochitest/test_ext_storage.html
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_storage.js
@@ -1,22 +1,15 @@
-<!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>
+/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim: set sts=2 sw=2 et tw=80: */
+"use strict";
 
-<script type="text/javascript">
-"use strict";
+/* globals browser */
+
+ExtensionTestUtils.init(this);
 
 function backgroundScript() {
   let storage = browser.storage.local;
   function check(prop, value) {
     return storage.get(null).then(data => {
       browser.test.assertEq(value, data[prop], "null getter worked for " + prop);
       return storage.get(prop);
     }).then(data => {
@@ -166,31 +159,28 @@ function backgroundScript() {
     browser.test.notifyPass("storage");
   }).catch(e => {
     browser.test.fail(`Error: ${e} :: ${e.stack}`);
     browser.test.notifyFail("storage");
   });
 }
 
 let extensionData = {
-  background: "(" + backgroundScript.toString() + ")()",
+  background: backgroundScript,
   manifest: {
     permissions: ["storage"],
   },
 };
 
 add_task(function* test_backgroundScript() {
   let extension = ExtensionTestUtils.loadExtension(extensionData);
 
   yield extension.startup();
 
   yield extension.awaitMessage("invalidate");
-  SpecialPowers.invalidateExtensionStorageCache();
+
+  Services.obs.notifyObservers(null, "extension-invalidate-storage-cache", "");
+
   extension.sendMessage("invalidated");
 
   yield extension.awaitFinish("storage");
   yield extension.unload();
 });
-
-</script>
-
-</body>
-</html>
--- a/toolkit/components/extensions/test/xpcshell/xpcshell.ini
+++ b/toolkit/components/extensions/test/xpcshell/xpcshell.ini
@@ -17,13 +17,14 @@ skip-if = (os == 'android' || buildapp =
 [test_ext_localStorage.js]
 [test_ext_manifest_content_security_policy.js]
 [test_ext_manifest_incognito.js]
 [test_ext_onmessage_removelistener.js]
 [test_ext_runtime_getPlatformInfo.js]
 [test_ext_runtime_sendMessage.js]
 [test_ext_schemas.js]
 [test_ext_simple.js]
+[test_ext_storage.js]
 [test_getAPILevelForWindow.js]
 [test_locale_converter.js]
 [test_locale_data.js]
 [test_native_messaging.js]
 skip-if = os == "android"