Bug 1444680: Part 4: Convert test_ext_webRequest_webSocket to xpcshell. r=mixedpuppy
authorKris Maglione <maglione.k@gmail.com>
Sat, 10 Mar 2018 18:49:38 -0800
changeset 407814 9d5817d7cb8ef26f5dfb68c26d2e96aea597c6e2
parent 407813 36eb1b1ba44f62f05cb225e6ef5902c41f98073b
child 407815 4545ede6e508a03e88bbf400ebcca1a65b0ce6c4
push id33621
push userapavel@mozilla.com
push dateTue, 13 Mar 2018 17:12:05 +0000
treeherdermozilla-central@deb7714a7bcd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmixedpuppy
bugs1444680
milestone60.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 1444680: Part 4: Convert test_ext_webRequest_webSocket to xpcshell. r=mixedpuppy MozReview-Commit-ID: Ck0vyHoqPV9
toolkit/components/extensions/test/mochitest/mochitest-common.ini
toolkit/components/extensions/test/mochitest/test_ext_webrequest_websocket.html
toolkit/components/extensions/test/xpcshell/test_ext_webRequest_webSocket.js
toolkit/components/extensions/test/xpcshell/xpcshell-common.ini
--- a/toolkit/components/extensions/test/mochitest/mochitest-common.ini
+++ b/toolkit/components/extensions/test/mochitest/mochitest-common.ini
@@ -160,12 +160,11 @@ skip-if = os == 'android' && debug # bug
 [test_ext_webrequest_filter.html]
 [test_ext_webrequest_frameId.html]
 [test_ext_webrequest_hsts.html]
 [test_ext_webrequest_responseBody.html]
 skip-if = os == 'android' || os == 'linux' # linux, bug 1398120
 [test_ext_webrequest_upgrade.html]
 [test_ext_webrequest_upload.html]
 skip-if = os == 'android' # Currently fails in emulator tests
-[test_ext_webrequest_websocket.html]
 [test_ext_webrequest_redirect_data_uri.html]
 [test_ext_window_postMessage.html]
 [test_ext_xhr_capabilities.html]
rename from toolkit/components/extensions/test/mochitest/test_ext_webrequest_websocket.html
rename to toolkit/components/extensions/test/xpcshell/test_ext_webRequest_webSocket.js
--- a/toolkit/components/extensions/test/mochitest/test_ext_webrequest_websocket.html
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_webRequest_webSocket.js
@@ -1,56 +1,53 @@
-<!DOCTYPE HTML>
-<html>
-<!--
--->
-<head>
-  <title>Basic websocket 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" />
+"use strict";
+
+const HOSTS = new Set([
+  "example.com",
+]);
 
-<script class="testbody" type="text/javascript">
-"use strict";
+const server = createHttpServer({hosts: HOSTS});
+
+server.registerPathHandler("/dummy", (request, response) => {
+  response.setStatusLine(request.httpVersion, 200, "OK");
+  response.write("ok");
+});
 
 add_task(async function test_webSocket() {
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       "permissions": [
         "webRequest",
         "webRequestBlocking",
         "<all_urls>",
       ],
     },
     background() {
       browser.webRequest.onBeforeRequest.addListener(details => {
         browser.test.assertEq("ws:", new URL(details.url).protocol, "ws protocol worked");
         browser.test.notifyPass("websocket");
-      }, {urls: ["ws://mochi.test/*"]}, ["blocking"]);
+      }, {urls: ["ws://example.com/*"]}, ["blocking"]);
 
       browser.test.onMessage.addListener(msg => {
-        let ws = new WebSocket("ws://mochi.test:8888/tests/dom/base/test/file_websocket_hello");
+        let ws = new WebSocket("ws://example.com/dummy");
         ws.onopen = (e) => {
           ws.send("data");
         };
         ws.onclose = (e) => {};
         ws.onerror = (e) => {};
         ws.onmessage = (e) => {
           ws.close();
         };
       });
       browser.test.sendMessage("ready");
     },
   });
   await extension.startup();
   await extension.awaitMessage("ready");
   extension.sendMessage("go");
   await extension.awaitFinish("websocket");
+
+  // Wait until the next tick so that listener responses are processed
+  // before we unload.
+  await new Promise(executeSoon);
+
   await extension.unload();
 });
-
-</script>
-</head>
-<body>
-</body>
-</html>
--- a/toolkit/components/extensions/test/xpcshell/xpcshell-common.ini
+++ b/toolkit/components/extensions/test/xpcshell/xpcshell-common.ini
@@ -79,16 +79,17 @@ skip-if = os == "android"
 [test_ext_storage_telemetry.js]
 skip-if = os == "android" # checking for telemetry needs to be updated: 1384923
 [test_ext_trustworthy_origin.js]
 [test_ext_topSites.js]
 skip-if = os == "android"
 [test_ext_webRequest_filterResponseData.js]
 [test_ext_webRequest_permission.js]
 [test_ext_webRequest_suspend.js]
+[test_ext_webRequest_webSocket.js]
 [test_native_manifests.js]
 subprocess = true
 skip-if = os == "android"
 [test_ext_permissions.js]
 skip-if = os == "android" # Bug 1350559
 [test_proxy_listener.js]
 [test_proxy_scripts.js]
 [test_proxy_scripts_results.js]