Bug 1166351 - Super-contrived not-so-minimal STR. draft
authorBob Silverberg <bsilverberg@mozilla.com>
Fri, 08 Apr 2016 10:19:19 -0400
changeset 355407 51621f64c6b1cdfd87cb1a6c171a44a3ca1234a0
parent 354827 1152d99d8c53ac9dae371a6e6d9fab03d3f98697
child 357884 e90f319443a384e7cc3f4b631f0a83533fa56919
child 357918 1306bde550715038c295b8fd827ef2d9da405942
child 363653 bd3f1314428e6e226a6875b5bf45d1d6bb1db5d1
push id16278
push usermconley@mozilla.com
push dateFri, 22 Apr 2016 14:52:58 +0000
bugs1166351
milestone48.0a1
Bug 1166351 - Super-contrived not-so-minimal STR. Run ./mach mochitest --flavor=plain toolkit/components/extensions/test/mochitest/ --jsdebugger Run the tests When the tests cease, focus the main browser showing the Mochitest results Open the Browser Console Try to access gBrowser.selectedBrowser.currentURI MozReview-Commit-ID: HQ9cmZMhn1o
toolkit/components/extensions/test/mochitest/mochitest.ini
toolkit/components/extensions/test/mochitest/test_ext_extension.html
toolkit/components/extensions/test/mochitest/test_ext_i18n_css.html
toolkit/components/extensions/test/mochitest/test_ext_inIncognitoContext_window.html
toolkit/components/extensions/test/mochitest/test_ext_runtime_connect.html
toolkit/content/widgets/remote-browser.xml
--- a/toolkit/components/extensions/test/mochitest/mochitest.ini
+++ b/toolkit/components/extensions/test/mochitest/mochitest.ini
@@ -25,66 +25,80 @@ support-files =
   file_script_xhr.js
   file_sample.html
   redirection.sjs
   file_privilege_escalation.html
   file_ext_test_api_injection.js
   file_permission_xhr.html
   file_download.txt
 
-[test_ext_extension.html]
-[test_ext_simple.html]
-[test_ext_schema.html]
-skip-if = e10s # Uses a console montitor. Actual code does not depend on e10s.
-[test_ext_geturl.html]
-[test_ext_contentscript.html]
-skip-if = buildapp == 'b2g' # runat != document_idle is not supported.
-[test_ext_contentscript_create_iframe.html]
-[test_ext_contentscript_api_injection.html]
-[test_ext_downloads.html]
-[test_ext_exclude_include_globs.html]
+#[test_ext_extension.html]
+
+[test_ext_inIncognitoContext_window.html]
+skip-if = os == 'android' # Android does not currently support windows.
+
+#[test_ext_simple.html]
+#[test_ext_schema.html]
+#skip-if = e10s # Uses a console montitor. Actual code does not depend on e10s.
+#[test_ext_geturl.html]
+#[test_ext_contentscript.html]
+#skip-if = buildapp == 'b2g' # runat != document_idle is not supported.
+#[test_ext_contentscript_create_iframe.html]
+#[test_ext_contentscript_api_injection.html]
+
+#[test_ext_downloads.html]
+#[test_ext_exclude_include_globs.html]
+
 [test_ext_i18n_css.html]
-[test_ext_generate.html]
-[test_ext_idle.html]
-[test_ext_localStorage.html]
-[test_ext_onmessage_removelistener.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_generate.html]
+
+#[test_ext_idle.html]
+#[test_ext_localStorage.html]
+#[test_ext_onmessage_removelistener.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_connect2.html]
-skip-if = (os == 'android' || buildapp == 'b2g') # port.sender.tab is undefined on b2g. Bug 1258975 on android.
-[test_ext_runtime_disconnect.html]
-[test_ext_runtime_getPlatformInfo.html]
-[test_ext_runtime_sendMessage.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_tab.html]
-skip-if = os == 'android' # Android does not currently support tabs.
-[test_ext_background_runtime_connect_params.html]
-[test_ext_cookies.html]
-[test_ext_cookies_expiry.html]
-skip-if = e10s || buildapp == 'b2g' # Uses cookie service via SpecialPowers.Services, which does not support e10s.
-[test_ext_cookies_permissions.html]
-skip-if = e10s || buildapp == 'b2g' # Uses cookie service via SpecialPowers.Services, which does not support e10s.
-[test_ext_bookmarks.html]
-skip-if = (os == 'android' || buildapp == 'b2g') # unimplemented api. Bug 1258975 on android.
-[test_ext_alarms.html]
-[test_ext_background_window_properties.html]
-[test_ext_background_sub_windows.html]
-[test_ext_background_api_injection.html]
-[test_ext_jsversion.html]
-skip-if = e10s || buildapp == 'b2g' # Uses a console monitor which doesn't work from a content process. The code being tested doesn't run in a tab content process in any case.
-[test_ext_i18n.html]
-skip-if = (os == 'android') # Bug 1258975 on android.
-[test_ext_web_accessible_resources.html]
-skip-if = (os == 'android') # Bug 1258975 on android.
-[test_ext_webrequest.html]
-skip-if = (os == 'android' || buildapp == 'b2g') # webrequest api uninplemented (bug 1199504). Bug 1258975 on android.
-[test_ext_webnavigation.html]
-skip-if = (os == 'android' || buildapp == 'b2g') # needs TabManager which is not yet implemented. Bug 1258975 on android.
+
+
+
+
+
+#[test_ext_runtime_connect2.html]
+#skip-if = (os == 'android' || buildapp == 'b2g') # port.sender.tab is undefined on b2g. Bug 1258975 on android.
+#[test_ext_runtime_disconnect.html]
+#[test_ext_runtime_getPlatformInfo.html]
+#[test_ext_runtime_sendMessage.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_tab.html]
+#skip-if = os == 'android' # Android does not currently support tabs.
+#[test_ext_background_runtime_connect_params.html]
+#[test_ext_cookies.html]
+#[test_ext_cookies_expiry.html]
+#skip-if = e10s || buildapp == 'b2g' # Uses cookie service via SpecialPowers.Services, which does not support e10s.
+#[test_ext_cookies_permissions.html]
+#skip-if = e10s || buildapp == 'b2g' # Uses cookie service via SpecialPowers.Services, which does not support e10s.
+#[test_ext_bookmarks.html]
+#skip-if = (os == 'android' || buildapp == 'b2g') # unimplemented api. Bug 1258975 on android.
+#[test_ext_alarms.html]
+#[test_ext_background_window_properties.html]
+#[test_ext_background_sub_windows.html]
+#[test_ext_background_api_injection.html]
+#[test_ext_jsversion.html]
+#skip-if = e10s || buildapp == 'b2g' # Uses a console monitor which doesn't work from a content process. The code being tested doesn't run in a tab content process in any case.
+#[test_ext_i18n.html]
+#skip-if = (os == 'android') # Bug 1258975 on android.
+#[test_ext_web_accessible_resources.html]
+#skip-if = (os == 'android') # Bug 1258975 on android.
+#[test_ext_webrequest.html]
+#skip-if = (os == 'android' || buildapp == 'b2g') # webrequest api uninplemented (bug 1199504). Bug 1258975 on android.
+#[test_ext_webnavigation.html]
+#skip-if = (os == 'android' || buildapp == 'b2g') # needs TabManager which is not yet implemented. Bug 1258975 on android.
--- a/toolkit/components/extensions/test/mochitest/test_ext_extension.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_extension.html
@@ -9,33 +9,47 @@
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 </head>
 <body>
 
 <script type="text/javascript">
 "use strict";
 
 add_task(function* test_is_allowed_incognito_access() {
-  function backgroundScript() {
+  function background() {
     browser.extension.isAllowedIncognitoAccess().then(isAllowedIncognitoAccess => {
       browser.test.assertEq(true, isAllowedIncognitoAccess, "isAllowedIncognitoAccess is true");
       browser.test.notifyPass("isAllowedIncognitoAccess");
     });
   }
 
   let extension = ExtensionTestUtils.loadExtension({
-    background: `(${backgroundScript})()`,
+    background: `(${background})()`,
     manifest: {},
   });
 
   yield extension.startup();
-  info("extension loaded");
   yield extension.awaitFinish("isAllowedIncognitoAccess");
   yield extension.unload();
-  info("extension unloaded");
+});
+
+add_task(function* test_in_incognito_context_false() {
+  function background() {
+    browser.test.assertEq(false, browser.extension.inIncognitoContext, "inIncognitoContext returned false");
+    browser.test.notifyPass("inIncognitoContext");
+  }
+
+  let extension = ExtensionTestUtils.loadExtension({
+    background: `(${background})()`,
+    manifest: {},
+  });
+
+  yield extension.startup();
+  yield extension.awaitFinish("inIncognitoContext");
+  yield extension.unload();
 });
 
 add_task(function* test_is_allowed_file_scheme_access() {
   function backgroundScript() {
     browser.extension.isAllowedFileSchemeAccess().then(isAllowedFileSchemeAccess => {
       browser.test.assertEq(true, isAllowedFileSchemeAccess, "isAllowedFileSchemeAccess is true");
       browser.test.notifyPass("isAllowedFileSchemeAccess");
     });
--- a/toolkit/components/extensions/test/mochitest/test_ext_i18n_css.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_i18n_css.html
@@ -9,108 +9,18 @@
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 </head>
 <body>
 
 <script type="text/javascript">
 "use strict";
 
 add_task(function* test_i18n_css() {
-  let extension = ExtensionTestUtils.loadExtension({
-    background: "new " + function() {
-      function fetch(url) {
-        return new Promise((resolve, reject) => {
-          let xhr = new XMLHttpRequest();
-          xhr.open("GET", url);
-          xhr.onload = () => { resolve(xhr.responseText); };
-          xhr.onerror = reject;
-          xhr.send();
-        });
-      }
-
-      Promise.all([fetch("foo.css"), fetch("bar.CsS?x#y"), fetch("foo.txt")]).then(results => {
-        browser.test.assertEq("body { max-width: 42px; }", results[0], "CSS file localized");
-        browser.test.assertEq("body { max-width: 42px; }", results[1], "CSS file localized");
-
-        browser.test.assertEq("body { __MSG_foo__; }", results[2], "Text file not localized");
-
-        browser.test.notifyPass("i18n-css");
-      });
-
-      browser.test.sendMessage("ready", browser.runtime.getURL("foo.css"));
-    },
-
-    manifest: {
-      "web_accessible_resources": ["foo.css", "foo.txt", "locale.css"],
-
-      "content_scripts": [{
-        "matches": ["http://mochi.test/*/file_sample.html"],
-        "css": ["foo.css"],
-      }],
-
-      "default_locale": "en",
-    },
-
-    files: {
-      "_locales/en/messages.json": JSON.stringify({
-        "foo": {
-          "message": "max-width: 42px",
-          "description": "foo",
-        },
-      }),
+  ok(true, "Foo");
+  const LOCALE = "general.useragent.locale";
+  SpecialPowers.setCharPref(LOCALE, "he");
+  SpecialPowers.clearUserPref(LOCALE);
+});
 
-      "foo.css": "body { __MSG_foo__; }",
-      "bar.CsS": "body { __MSG_foo__; }",
-      "foo.txt": "body { __MSG_foo__; }",
-      "locale.css": '* { content: "__MSG_@@ui_locale__ __MSG_@@bidi_dir__ __MSG_@@bidi_reversed_dir__ __MSG_@@bidi_start_edge__ __MSG_@@bidi_end_edge__" }',
-    },
-  });
-
-  yield extension.startup();
-  let cssURL = yield extension.awaitMessage("ready");
-
-  function fetch(url) {
-    return new Promise((resolve, reject) => {
-      let xhr = new XMLHttpRequest();
-      xhr.open("GET", url);
-      xhr.onload = () => { resolve(xhr.responseText); };
-      xhr.onerror = reject;
-      xhr.send();
-    });
-  }
-
-  let css = yield fetch(cssURL);
-
-  is(css, "body { max-width: 42px; }", "CSS file localized in mochitest scope");
-
-  let win = window.open("file_sample.html");
-  yield waitForLoad(win);
-
-  let style = win.getComputedStyle(win.document.body);
-  is(style.maxWidth, "42px", "stylesheet correctly applied");
-  win.close();
-
-  cssURL = cssURL.replace(/foo.css$/, "locale.css");
-
-  css = yield fetch(cssURL);
-  is(css, '* { content: "en_US ltr rtl left right" }', "CSS file localized in mochitest scope");
-
-  const LOCALE = "general.useragent.locale";
-  const DIR = "intl.uidirection.en";
-
-  // We don't wind up actually switching the chrome registry locale, since we
-  // don't have a chrome package for Hebrew. So just override it.
-  SpecialPowers.setCharPref(LOCALE, "he");
-  SpecialPowers.setCharPref(DIR, "rtl");
-
-  css = yield fetch(cssURL);
-  is(css, '* { content: "he rtl ltr right left" }', "CSS file localized in mochitest scope");
-
-  SpecialPowers.clearUserPref(LOCALE);
-  SpecialPowers.clearUserPref(DIR);
-
-  yield extension.awaitFinish("i18n-css");
-  yield extension.unload();
-});
 </script>
 
 </body>
 </html>
new file mode 100644
--- /dev/null
+++ b/toolkit/components/extensions/test/mochitest/test_ext_inIncognitoContext_window.html
@@ -0,0 +1,35 @@
+<!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">
+"use strict";
+
+add_task(function* test_in_incognito_context_true() {
+  function background() {
+    browser.test.notifyPass("inIncognitoContext");
+    browser.windows.create({url: browser.runtime.getURL("/tab.html"), incognito: true});
+  }
+
+  let extension = ExtensionTestUtils.loadExtension({
+    background: `(${background})()`,
+    manifest: {},
+  });
+
+  yield extension.startup();
+  yield extension.awaitFinish("inIncognitoContext");
+  yield extension.unload();
+});
+
+</script>
+
+</body>
+</html>
--- a/toolkit/components/extensions/test/mochitest/test_ext_runtime_connect.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_runtime_connect.html
@@ -8,76 +8,17 @@
   <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">
 "use strict";
 
-function backgroundScript() {
-  browser.runtime.onConnect.addListener(port => {
-    browser.test.assertEq(port.name, "ernie", "port name correct");
-    browser.test.assertTrue(port.sender.url.endsWith("file_sample.html"), "URL correct");
-    browser.test.assertTrue(port.sender.tab.url.endsWith("file_sample.html"), "tab URL correct");
-
-    let expected = "message 1";
-    port.onMessage.addListener(msg => {
-      browser.test.assertEq(msg, expected, "message is expected");
-      if (expected == "message 1") {
-        port.postMessage("message 2");
-        expected = "message 3";
-      } else if (expected == "message 3") {
-        expected = "disconnect";
-        browser.test.notifyPass("runtime.connect");
-      }
-    });
-    port.onDisconnect.addListener(() => {
-      browser.test.assertEq(expected, "disconnect", "got disconnection at right time");
-    });
-  });
-}
-
-function contentScript() {
-  let port = browser.runtime.connect({name: "ernie"});
-  port.postMessage("message 1");
-  port.onMessage.addListener(msg => {
-    if (msg == "message 2") {
-      port.postMessage("message 3");
-      port.disconnect();
-    }
-  });
-}
-
-let extensionData = {
-  background: "(" + backgroundScript.toString() + ")()",
-  manifest: {
-    "permissions": ["tabs"],
-    "content_scripts": [{
-      "matches": ["http://mochi.test/*/file_sample.html"],
-      "js": ["content_script.js"],
-      "run_at": "document_start",
-    }],
-  },
-
-  files: {
-    "content_script.js": "(" + contentScript.toString() + ")()",
-  },
-};
-
 add_task(function* test_contentscript() {
-  let extension = ExtensionTestUtils.loadExtension(extensionData);
-  yield extension.startup();
-  info("extension loaded");
-
-  let win = window.open("file_sample.html");
-
-  yield Promise.all([waitForLoad(win), extension.awaitFinish("runtime.connect")]);
-
+  ok(true, "Hello");
+  let win = window.open("about:blank");
   win.close();
-
-  yield extension.unload();
-  info("extension unloaded");
 });
 </script>
 
 </body>
 </html>
--- a/toolkit/content/widgets/remote-browser.xml
+++ b/toolkit/content/widgets/remote-browser.xml
@@ -56,19 +56,23 @@
       </method>
 
       <field name="_controller">null</field>
 
       <field name="_selectParentHelper">null</field>
 
       <field name="_remoteWebNavigation">null</field>
 
-      <property name="webNavigation"
-                onget="return this._remoteWebNavigation;"
-                readonly="true"/>
+      <property name="webNavigation" readonly="true">
+        <getter>
+          <![CDATA[
+            return this._remoteWebNavigation;
+          ]]>
+        </getter>
+      </property>
 
       <field name="_remoteWebProgress">null</field>
 
       <property name="webProgress" readonly="true">
       	<getter>
       	  <![CDATA[
             if (!this._remoteWebProgress) {
               // Don't attempt to create the remote web progress if the