new file mode 100644
--- /dev/null
+++ b/devtools/shared/webconsole/test/.eslintrc.js
@@ -0,0 +1,6 @@
+"use strict";
+
+module.exports = {
+ // Extend from the shared list of defined globals for mochitests.
+ "extends": "../../../../testing/mochitest/chrome.eslintrc.js"
+};
--- a/devtools/shared/webconsole/test/console-test-worker.js
+++ b/devtools/shared/webconsole/test/console-test-worker.js
@@ -1,16 +1,17 @@
"use strict";
console.log("Log from worker init");
function f() {
- var a = 1;
- var b = 2;
- var c = 3;
+ const a = 1;
+ const b = 2;
+ const c = 3;
+ return {a, b, c};
}
self.onmessage = function (event) {
if (event.data == "ping") {
f();
postMessage("pong");
}
};
--- a/devtools/shared/webconsole/test/helper_serviceworker.js
+++ b/devtools/shared/webconsole/test/helper_serviceworker.js
@@ -1,8 +1,10 @@
+"use strict";
+
console.log("script evaluation");
addEventListener("install", function (evt) {
console.log("install event");
});
addEventListener("activate", function (evt) {
console.log("activate event");
--- a/devtools/shared/webconsole/test/network_requests_iframe.html
+++ b/devtools/shared/webconsole/test/network_requests_iframe.html
@@ -1,58 +1,63 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Console HTTP test page</title>
<!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
<script type="text/javascript"><!--
- var setAllowAllCookies = false;
+ "use strict";
+ let setAllowAllCookies = false;
- function makeXhr(aMethod, aUrl, aRequestBody, aCallback) {
+ function makeXhr(method, url, requestBody, callback) {
// On the first call, allow all cookies and set cookies, then resume the actual test
- if (!setAllowAllCookies)
- SpecialPowers.pushPrefEnv({"set": [["network.cookie.cookieBehavior", 0]]}, function () {
+ if (!setAllowAllCookies) {
+ SpecialPowers.pushPrefEnv({"set": [["network.cookie.cookieBehavior", 0]]},
+ function () {
setAllowAllCookies = true;
setCookies();
- makeXhrCallback(aMethod, aUrl, aRequestBody, aCallback);
+ makeXhrCallback(method, url, requestBody, callback);
});
- else
- makeXhrCallback(aMethod, aUrl, aRequestBody, aCallback);
+ } else {
+ makeXhrCallback(method, url, requestBody, callback);
+ }
}
- function makeXhrCallback(aMethod, aUrl, aRequestBody, aCallback) {
- var xmlhttp = new XMLHttpRequest();
- xmlhttp.open(aMethod, aUrl, true);
- if (aCallback) {
- xmlhttp.onreadystatechange = function() {
+ function makeXhrCallback(method, url, requestBody, callback) {
+ const xmlhttp = new XMLHttpRequest();
+ xmlhttp.open(method, url, true);
+ if (callback) {
+ xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4) {
- aCallback();
+ callback();
}
};
}
- xmlhttp.send(aRequestBody);
+ xmlhttp.send(requestBody);
}
- function testXhrGet(aCallback) {
- makeXhr('get', 'data.json', null, aCallback);
+ /* exported testXhrGet */
+ function testXhrGet(callback) {
+ makeXhr("get", "data.json", null, callback);
}
- function testXhrPost(aCallback) {
- var body = "Hello world! " + (new Array(50)).join("foobaz barr");
- makeXhr('post', 'data.json', body, aCallback);
+ /* exported testXhrPost */
+ function testXhrPost(callback) {
+ const body = "Hello world! " + (new Array(50)).join("foobaz barr");
+ makeXhr("post", "data.json", body, callback);
}
function setCookies() {
document.cookie = "foobar=fooval";
document.cookie = "omgfoo=bug768096";
document.cookie = "badcookie=bug826798=st3fan";
}
- // --></script>
+ </script>
</head>
<body>
<h1>Web Console HTTP Logging Testpage</h1>
<h2>This page is used to test the HTTP logging.</h2>
<form action="?" method="post">
<input name="name" type="text" value="foo bar"><br>
<input name="age" type="text" value="144"><br>
--- a/devtools/shared/webconsole/test/test_cached_messages.html
+++ b/devtools/shared/webconsole/test/test_cached_messages.html
@@ -10,18 +10,17 @@
</head>
<body>
<p>Test for cached messages</p>
<script class="testbody" type="application/javascript;version=1.8">
let expectedConsoleCalls = [];
let expectedPageErrors = [];
-function doPageErrors()
-{
+function doPageErrors() {
Services.console.reset();
expectedPageErrors = [
{
_type: "PageError",
errorMessage: /fooColor/,
sourceName: /.+/,
category: "CSS Parser",
@@ -52,18 +51,17 @@ function doPageErrors()
SimpleTest.expectUncaughtException();
container = document.createElement("script");
document.body.appendChild(container);
container.textContent = "document.doTheImpossible();";
document.body.removeChild(container);
}
-function doConsoleCalls()
-{
+function doConsoleCalls() {
ConsoleAPIStorage.clearEvents();
top.console.log("foobarBaz-log", undefined);
top.console.info("foobarBaz-info", null);
top.console.warn("foobarBaz-warn", document.body);
expectedConsoleCalls = [
{
@@ -97,74 +95,68 @@ function doConsoleCalls()
<script class="testbody" type="text/javascript;version=1.8">
SimpleTest.waitForExplicitFinish();
let consoleAPIListener, consoleServiceListener;
let consoleAPICalls = 0;
let pageErrors = 0;
let handlers = {
- onConsoleAPICall: function onConsoleAPICall(aMessage)
- {
+ onConsoleAPICall: function onConsoleAPICall(message) {
for (let msg of expectedConsoleCalls) {
- if (msg.functionName == aMessage.functionName &&
- msg.filename.test(aMessage.filename)) {
+ if (msg.functionName == message.functionName &&
+ msg.filename.test(message.filename)) {
consoleAPICalls++;
break;
}
}
if (consoleAPICalls == expectedConsoleCalls.length) {
checkConsoleAPICache();
}
},
- onConsoleServiceMessage: function onConsoleServiceMessage(aMessage)
- {
- if (!(aMessage instanceof Ci.nsIScriptError)) {
+ onConsoleServiceMessage: function onConsoleServiceMessage(message) {
+ if (!(message instanceof Ci.nsIScriptError)) {
return;
}
for (let msg of expectedPageErrors) {
- if (msg.category == aMessage.category &&
- msg.errorMessage.test(aMessage.errorMessage)) {
+ if (msg.category == message.category &&
+ msg.errorMessage.test(message.errorMessage)) {
pageErrors++;
break;
}
}
if (pageErrors == expectedPageErrors.length) {
testPageErrors();
}
},
};
-function startTest()
-{
+function startTest() {
removeEventListener("load", startTest);
consoleAPIListener = new ConsoleAPIListener(top, handlers);
consoleAPIListener.init();
doConsoleCalls();
}
-function checkConsoleAPICache()
-{
+function checkConsoleAPICache() {
consoleAPIListener.destroy();
consoleAPIListener = null;
attachConsole(["ConsoleAPI"], onAttach1);
}
-function onAttach1(aState, aResponse)
-{
- aState.client.getCachedMessages(["ConsoleAPI"],
- onCachedConsoleAPI.bind(null, aState));
+function onAttach1(state, response) {
+ state.client.getCachedMessages(["ConsoleAPI"],
+ onCachedConsoleAPI.bind(null, state));
}
-function onCachedConsoleAPI(aState, aResponse)
-{
- let msgs = aResponse.messages;
+function onCachedConsoleAPI(state, response) {
+ let msgs = response.messages;
info("cached console messages: " + msgs.length);
ok(msgs.length >= expectedConsoleCalls.length,
"number of cached console messages");
for (let msg of msgs) {
for (let expected of expectedConsoleCalls) {
if (expected.functionName == msg.functionName &&
@@ -173,39 +165,36 @@ function onCachedConsoleAPI(aState, aRes
checkConsoleAPICall(msg, expected);
break;
}
}
}
is(expectedConsoleCalls.length, 0, "all expected messages have been found");
- closeDebugger(aState, function() {
+ closeDebugger(state, function() {
consoleServiceListener = new ConsoleServiceListener(null, handlers);
consoleServiceListener.init();
doPageErrors();
});
}
-function testPageErrors()
-{
+function testPageErrors() {
consoleServiceListener.destroy();
consoleServiceListener = null;
attachConsole(["PageError"], onAttach2);
}
-function onAttach2(aState, aResponse)
-{
- aState.client.getCachedMessages(["PageError"],
- onCachedPageErrors.bind(null, aState));
+function onAttach2(state, response) {
+ state.client.getCachedMessages(["PageError"],
+ onCachedPageErrors.bind(null, state));
}
-function onCachedPageErrors(aState, aResponse)
-{
- let msgs = aResponse.messages;
+function onCachedPageErrors(state, response) {
+ let msgs = response.messages;
info("cached page errors: " + msgs.length);
ok(msgs.length >= expectedPageErrors.length,
"number of cached page errors");
for (let msg of msgs) {
for (let expected of expectedPageErrors) {
if (expected.category == msg.category &&
@@ -214,17 +203,17 @@ function onCachedPageErrors(aState, aRes
checkObject(msg, expected);
break;
}
}
}
is(expectedPageErrors.length, 0, "all expected messages have been found");
- closeDebugger(aState, function() {
+ closeDebugger(state, function() {
SimpleTest.finish();
});
}
addEventListener("load", startTest);
</script>
</body>
</html>
--- a/devtools/shared/webconsole/test/test_network_security-hpkp.html
+++ b/devtools/shared/webconsole/test/test_network_security-hpkp.html
@@ -34,18 +34,17 @@ const TEST_CASES = [
},
{
desc: "dynamic Public Key Pinning with previous request",
url: "https://include-subdomains.pinning-dynamic.example.com/",
usesPinning: true,
}
];
-function startTest()
-{
+function startTest() {
// Need to enable this pref or pinning headers are rejected due test
// certificate.
Services.prefs.setBoolPref(HPKP_PREF, true);
SimpleTest.registerCleanupFunction(() => {
Services.prefs.setBoolPref(HPKP_PREF, false);
// Reset pinning state.
let gSSService = Cc["@mozilla.org/ssservice;1"]
@@ -59,50 +58,48 @@ function startTest()
}
});
info("Test detection of Public Key Pinning.");
removeEventListener("load", startTest);
attachConsoleToTab(["NetworkActivity"], onAttach);
}
-function onAttach(aState, aResponse)
-{
- onNetworkEventUpdate = onNetworkEventUpdate.bind(null, aState);
- aState.dbgClient.addListener("networkEventUpdate", onNetworkEventUpdate);
+function onAttach(state, response) {
+ onNetworkEventUpdate = onNetworkEventUpdate.bind(null, state);
+ state.dbgClient.addListener("networkEventUpdate", onNetworkEventUpdate);
- runNextCase(aState);
+ runNextCase(state);
}
-function runNextCase(aState) {
+function runNextCase(state) {
gCurrentTestCase++;
if (gCurrentTestCase === TEST_CASES.length) {
info("Tests ran. Cleaning up.");
- closeDebugger(aState, SimpleTest.finish);
+ closeDebugger(state, SimpleTest.finish);
return;
}
let { desc, url } = TEST_CASES[gCurrentTestCase];
info("Testing site with " + desc);
let iframe = document.querySelector("iframe").contentWindow;
iframe.wrappedJSObject.makeXhrCallback("GET", url);
}
-function onNetworkEventUpdate(aState, aType, aPacket)
-{
- function onSecurityInfo(packet) {
+function onNetworkEventUpdate(state, type, packet) {
+ function onSecurityInfo(received) {
let data = TEST_CASES[gCurrentTestCase];
- is(packet.securityInfo.hpkp, data.usesPinning,
+ is(received.securityInfo.hpkp, data.usesPinning,
"Public Key Pinning detected correctly.");
- runNextCase(aState);
+ runNextCase(state);
}
- if (aPacket.updateType === "securityInfo") {
- aState.client.getSecurityInfo(aPacket.from, onSecurityInfo);
+ if (packet.updateType === "securityInfo") {
+ state.client.getSecurityInfo(packet.from, onSecurityInfo);
}
}
addEventListener("load", startTest);
</script>
</body>
</html>
--- a/devtools/shared/webconsole/test/test_object_actor.html
+++ b/devtools/shared/webconsole/test/test_object_actor.html
@@ -11,27 +11,25 @@
<body>
<p>Test for the object actor</p>
<script class="testbody" type="text/javascript;version=1.8">
SimpleTest.waitForExplicitFinish();
let expectedProps = [];
-function startTest()
-{
+function startTest() {
removeEventListener("load", startTest);
attachConsoleToTab(["ConsoleAPI"], onAttach);
}
-function onAttach(aState, aResponse)
-{
- onConsoleCall = onConsoleCall.bind(null, aState);
- aState.dbgClient.addListener("consoleAPICall", onConsoleCall);
+function onAttach(state, response) {
+ onConsoleCall = onConsoleCall.bind(null, state);
+ state.dbgClient.addListener("consoleAPICall", onConsoleCall);
let longString = (new Array(DebuggerServer.LONG_STRING_LENGTH + 3)).join("\u0629");
// Here we put the objects in the correct window, to avoid having them all
// wrapped by proxies for cross-compartment access.
let foobarObject = top.Object.create(null);
foobarObject.tamarbuta = longString;
@@ -127,52 +125,50 @@ function onAttach(aState, aResponse)
},
},
"testfoo": {
value: false,
},
};
}
-function onConsoleCall(aState, aType, aPacket)
-{
- is(aPacket.from, aState.actor, "console API call actor");
+function onConsoleCall(state, aType, aPacket) {
+ is(aPacket.from, state.actor, "console API call actor");
info("checking the console API call packet");
checkConsoleAPICall(aPacket.message, {
level: "log",
filename: /test_object_actor/,
functionName: "onAttach",
arguments: ["hello", {
type: "object",
actor: /[a-z]/,
}],
});
- aState.dbgClient.removeListener("consoleAPICall", onConsoleCall);
+ state.dbgClient.removeListener("consoleAPICall", onConsoleCall);
info("inspecting object properties");
let args = aPacket.message.arguments;
- onProperties = onProperties.bind(null, aState);
+ onProperties = onProperties.bind(null, state);
- let client = new ObjectClient(aState.dbgClient, args[1]);
+ let client = new ObjectClient(state.dbgClient, args[1]);
client.getPrototypeAndProperties(onProperties);
}
-function onProperties(aState, aResponse)
-{
- let props = aResponse.ownProperties;
+function onProperties(state, response) {
+ let props = response.ownProperties;
is(Object.keys(props).length, Object.keys(expectedProps).length,
"number of enumerable properties");
checkObject(props, expectedProps);
expectedProps = [];
- closeDebugger(aState, function() {
+ closeDebugger(state, function() {
SimpleTest.finish();
});
}
addEventListener("load", startTest);
</script>
</body>
</html>
--- a/devtools/shared/webconsole/test/test_page_errors.html
+++ b/devtools/shared/webconsole/test/test_page_errors.html
@@ -11,18 +11,17 @@
<body>
<p>Test for page errors</p>
<script class="testbody" type="text/javascript;version=1.8">
SimpleTest.waitForExplicitFinish();
let expectedPageErrors = [];
-function doPageErrors()
-{
+function doPageErrors() {
expectedPageErrors = {
"document.body.style.color = 'fooColor';": {
errorMessage: /fooColor/,
errorMessageName: undefined,
sourceName: /test_page_errors/,
category: "CSS Parser",
timeStamp: /^\d+$/,
error: false,
@@ -123,54 +122,51 @@ function doPageErrors()
container = document.createElement("script");
document.body.appendChild(container);
container.textContent = stmt;
document.body.removeChild(container);
info("ending stmt: " + stmt);
}
}
-function startTest()
-{
+function startTest() {
removeEventListener("load", startTest);
attachConsole(["PageError"], onAttach);
}
-function onAttach(aState, aResponse)
-{
- onPageError = onPageError.bind(null, aState);
- aState.dbgClient.addListener("pageError", onPageError);
+function onAttach(state, response) {
+ onPageError = onPageError.bind(null, state);
+ state.dbgClient.addListener("pageError", onPageError);
doPageErrors();
}
let pageErrors = [];
-function onPageError(aState, aType, aPacket)
-{
- if (!aPacket.pageError.sourceName.includes("test_page_errors")) {
- info("Ignoring error from unknown source: " + aPacket.pageError.sourceName);
+function onPageError(state, type, packet) {
+ if (!packet.pageError.sourceName.includes("test_page_errors")) {
+ info("Ignoring error from unknown source: " + packet.pageError.sourceName);
return;
}
- is(aPacket.from, aState.actor, "page error actor");
+ is(packet.from, state.actor, "page error actor");
- pageErrors.push(aPacket.pageError);
+ pageErrors.push(packet.pageError);
if (pageErrors.length != Object.keys(expectedPageErrors).length) {
return;
}
- aState.dbgClient.removeListener("pageError", onPageError);
+ state.dbgClient.removeListener("pageError", onPageError);
- Object.values(expectedPageErrors).forEach(function(aMessage, aIndex) {
- info("checking received page error #" + aIndex);
- checkObject(pageErrors[aIndex], Object.values(expectedPageErrors)[aIndex]);
+ Object.values(expectedPageErrors).forEach(function(message, index) {
+ info("checking received page error #" + index);
+ checkObject(pageErrors[index], Object.values(expectedPageErrors)[index]);
});
- closeDebugger(aState, function() {
+ closeDebugger(state, function() {
SimpleTest.finish();
});
}
addEventListener("load", startTest);
</script>
</body>
</html>
--- a/devtools/shared/webconsole/test/test_reflow.html
+++ b/devtools/shared/webconsole/test/test_reflow.html
@@ -11,34 +11,31 @@
<body>
<p>Test for reflow events</p>
<script class="testbody" type="text/javascript;version=1.8">
SimpleTest.waitForExplicitFinish();
let client;
-function generateReflow()
-{
+function generateReflow() {
top.document.documentElement.style.display = "none";
top.document.documentElement.getBoundingClientRect();
top.document.documentElement.style.display = "block";
}
-function startTest()
-{
+function startTest() {
removeEventListener("load", startTest);
attachConsoleToTab(["ReflowActivity"], onAttach);
}
-function onAttach(aState, aResponse)
-{
- client = aState.dbgClient;
+function onAttach(state, response) {
+ client = state.dbgClient;
- onReflowActivity = onReflowActivity.bind(null, aState);
+ onReflowActivity = onReflowActivity.bind(null, state);
client.addListener("reflowActivity", onReflowActivity);
generateReflow();
}
// We are expecting 3 reflow events.
let expectedEvents = [
{
interruptible: false,
@@ -55,39 +52,38 @@ let expectedEvents = [
sourceURL: null,
functionName: null
},
];
let receivedEvents = [];
-function onReflowActivity(aState, aType, aPacket)
-{
- info("packet: " + aPacket.message);
- receivedEvents.push(aPacket);
+function onReflowActivity(state, type, packet) {
+ info("packet: " + packet.message);
+ receivedEvents.push(packet);
if (receivedEvents.length == expectedEvents.length) {
checkEvents();
- finish(aState);
+ finish(state);
}
}
function checkEvents() {
for (let i = 0; i < expectedEvents.length; i++) {
let a = expectedEvents[i];
let b = receivedEvents[i];
for (let key in a) {
is(a[key], b[key], "field " + key + " is valid");
}
}
}
-function finish(aState) {
+function finish(state) {
client.removeListener("reflowActivity", onReflowActivity);
- closeDebugger(aState, function() {
+ closeDebugger(state, function() {
SimpleTest.finish();
});
}
addEventListener("load", startTest);
</script>
</body>
--- a/devtools/shared/webconsole/test/unit/test_js_property_provider.js
+++ b/devtools/shared/webconsole/test/unit/test_js_property_provider.js
@@ -24,30 +24,29 @@ function run_test() {
]
]`;
const testObject = 'var testObject = {"propA": [{"propB": "B"}]}';
const testHyphenated = 'var testHyphenated = {"prop-A": "res-A"}';
const testLet = "let foobar = {a: ''}; const blargh = {a: 1};";
let sandbox = Components.utils.Sandbox("http://example.com");
- let dbg = new Debugger;
+ let dbg = new Debugger();
let dbgObject = dbg.addDebuggee(sandbox);
let dbgEnv = dbgObject.asEnvironment();
Components.utils.evalInSandbox(testArray, sandbox);
Components.utils.evalInSandbox(testObject, sandbox);
Components.utils.evalInSandbox(testHyphenated, sandbox);
Components.utils.evalInSandbox(testLet, sandbox);
do_print("Running tests with dbgObject");
runChecks(dbgObject, null);
do_print("Running tests with dbgEnv");
runChecks(null, dbgEnv);
-
}
function runChecks(dbgObject, dbgEnv) {
do_print("Test that suggestions are given for 'this'");
let results = JSPropertyProvider(dbgObject, dbgEnv, "t");
test_has_result(results, "this");
if (dbgObject != null) {
@@ -124,17 +123,18 @@ function runChecks(dbgObject, dbgEnv) {
do_print("Test that suggestions are not given for numeric literals.");
results = JSPropertyProvider(dbgObject, dbgEnv, "1.");
do_check_null(results);
do_print("Test that suggestions are not given for index that's out of bounds.");
results = JSPropertyProvider(dbgObject, dbgEnv, "testArray[10].");
do_check_null(results);
- do_print("Test that no suggestions are given if an index is not numerical somewhere in the chain.");
+ do_print("Test that no suggestions are given if an index is not numerical "
+ + "somewhere in the chain.");
results = JSPropertyProvider(dbgObject, dbgEnv, "testArray[0]['propC'][0].");
do_check_null(results);
results = JSPropertyProvider(dbgObject, dbgEnv, "testObject['propA'][0].");
do_check_null(results);
results = JSPropertyProvider(dbgObject, dbgEnv, "testArray[0]['propC'].");
do_check_null(results);
@@ -144,27 +144,27 @@ function runChecks(dbgObject, dbgEnv) {
do_print("Test that suggestions are not given if there is an hyphen in the chain.");
results = JSPropertyProvider(dbgObject, dbgEnv, "testHyphenated['prop-A'].");
do_check_null(results);
}
/**
* A helper that ensures an empty array of results were found.
- * @param Object aResults
+ * @param Object results
* The results returned by JSPropertyProvider.
*/
-function test_has_no_results(aResults) {
- do_check_neq(aResults, null);
- do_check_eq(aResults.matches.length, 0);
+function test_has_no_results(results) {
+ do_check_neq(results, null);
+ do_check_eq(results.matches.length, 0);
}
/**
* A helper that ensures (required) results were found.
- * @param Object aResults
+ * @param Object results
* The results returned by JSPropertyProvider.
- * @param String aRequiredSuggestion
+ * @param String requiredSuggestion
* A suggestion that must be found from the results.
*/
-function test_has_result(aResults, aRequiredSuggestion) {
- do_check_neq(aResults, null);
- do_check_true(aResults.matches.length > 0);
- do_check_true(aResults.matches.indexOf(aRequiredSuggestion) !== -1);
+function test_has_result(results, requiredSuggestion) {
+ do_check_neq(results, null);
+ do_check_true(results.matches.length > 0);
+ do_check_true(results.matches.indexOf(requiredSuggestion) !== -1);
}
--- a/devtools/shared/webconsole/test/unit/test_network_helper.js
+++ b/devtools/shared/webconsole/test/unit/test_network_helper.js
@@ -23,25 +23,30 @@ function test_isTextMimeType() {
do_check_eq(NetworkHelper.isTextMimeType("application/javascript"), true);
do_check_eq(NetworkHelper.isTextMimeType("application/json"), true);
do_check_eq(NetworkHelper.isTextMimeType("text/css"), true);
do_check_eq(NetworkHelper.isTextMimeType("text/html"), true);
do_check_eq(NetworkHelper.isTextMimeType("image/svg+xml"), true);
do_check_eq(NetworkHelper.isTextMimeType("application/xml"), true);
// Test custom JSON subtype
- do_check_eq(NetworkHelper.isTextMimeType("application/vnd.tent.posts-feed.v0+json"), true);
- do_check_eq(NetworkHelper.isTextMimeType("application/vnd.tent.posts-feed.v0-json"), true);
+ do_check_eq(NetworkHelper
+ .isTextMimeType("application/vnd.tent.posts-feed.v0+json"), true);
+ do_check_eq(NetworkHelper
+ .isTextMimeType("application/vnd.tent.posts-feed.v0-json"), true);
// Test custom XML subtype
- do_check_eq(NetworkHelper.isTextMimeType("application/vnd.tent.posts-feed.v0+xml"), true);
- do_check_eq(NetworkHelper.isTextMimeType("application/vnd.tent.posts-feed.v0-xml"), false);
+ do_check_eq(NetworkHelper
+ .isTextMimeType("application/vnd.tent.posts-feed.v0+xml"), true);
+ do_check_eq(NetworkHelper
+ .isTextMimeType("application/vnd.tent.posts-feed.v0-xml"), false);
// Test case-insensitive
do_check_eq(NetworkHelper.isTextMimeType("application/vnd.BIG-CORP+json"), true);
// Test non-text type
do_check_eq(NetworkHelper.isTextMimeType("image/png"), false);
// Test invalid types
do_check_eq(NetworkHelper.isTextMimeType("application/foo-+json"), false);
do_check_eq(NetworkHelper.isTextMimeType("application/-foo+json"), false);
do_check_eq(NetworkHelper.isTextMimeType("application/foo--bar+json"), false);
// Test we do not cause internal errors with unoptimized regex. Bug 961097
- do_check_eq(NetworkHelper.isTextMimeType("application/vnd.google.safebrowsing-chunk"), false);
+ do_check_eq(NetworkHelper
+ .isTextMimeType("application/vnd.google.safebrowsing-chunk"), false);
}
--- a/devtools/shared/webconsole/test/unit/test_security-info-certificate.js
+++ b/devtools/shared/webconsole/test/unit/test_security-info-certificate.js
@@ -12,17 +12,16 @@ Object.defineProperty(this, "NetworkHelp
get: function () {
return require("devtools/shared/webconsole/network-helper");
},
configurable: true,
writeable: false,
enumerable: true
});
-var Ci = Components.interfaces;
const DUMMY_CERT = {
commonName: "cn",
organization: "o",
organizationalUnit: "ou",
issuerCommonName: "issuerCN",
issuerOrganization: "issuerO",
issuerOrganizationUnit: "issuerOU",
sha256Fingerprint: "qwertyuiopoiuytrewq",
--- a/devtools/shared/webconsole/test/unit/test_security-info-parser.js
+++ b/devtools/shared/webconsole/test/unit/test_security-info-parser.js
@@ -36,17 +36,18 @@ const MockCertificate = {
const MockSecurityInfo = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsITransportSecurityInfo,
Ci.nsISSLStatusProvider]),
securityState: wpl.STATE_IS_SECURE,
errorCode: 0,
SSLStatus: {
cipherSuite: "TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256",
- protocolVersion: 3, // TLS_VERSION_1_2
+ // TLS_VERSION_1_2
+ protocolVersion: 3,
serverCert: MockCertificate,
}
};
function run_test() {
let result = NetworkHelper.parseSecurityInfo(MockSecurityInfo, {});
equal(result.state, "secure", "State is correct.");
--- a/devtools/shared/webconsole/test/unit/test_security-info-protocol-version.js
+++ b/devtools/shared/webconsole/test/unit/test_security-info-protocol-version.js
@@ -12,17 +12,16 @@ Object.defineProperty(this, "NetworkHelp
get: function () {
return require("devtools/shared/webconsole/network-helper");
},
configurable: true,
writeable: false,
enumerable: true
});
-var Ci = Components.interfaces;
const TEST_CASES = [
{
description: "TLS_VERSION_1",
input: 1,
expected: "TLSv1"
}, {
description: "TLS_VERSION_1.1",
input: 2,
--- a/devtools/shared/webconsole/test/unit/test_security-info-state.js
+++ b/devtools/shared/webconsole/test/unit/test_security-info-state.js
@@ -21,17 +21,18 @@ Object.defineProperty(this, "NetworkHelp
var Ci = Components.interfaces;
const wpl = Ci.nsIWebProgressListener;
const MockSecurityInfo = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsITransportSecurityInfo,
Ci.nsISSLStatusProvider]),
securityState: wpl.STATE_IS_BROKEN,
errorCode: 0,
SSLStatus: {
- protocolVersion: 3, // nsISSLStatus.TLS_VERSION_1_2
+ // nsISSLStatus.TLS_VERSION_1_2
+ protocolVersion: 3,
cipherSuite: "TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256",
}
};
function run_test() {
test_nullSecurityInfo();
test_insecureSecurityInfoWithNSSError();
test_insecureSecurityInfoWithoutNSSError();
--- a/devtools/shared/webconsole/test/unit/test_security-info-static-hpkp.js
+++ b/devtools/shared/webconsole/test/unit/test_security-info-static-hpkp.js
@@ -23,17 +23,18 @@ const wpl = Ci.nsIWebProgressListener;
const MockSecurityInfo = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsITransportSecurityInfo,
Ci.nsISSLStatusProvider]),
securityState: wpl.STATE_IS_SECURE,
errorCode: 0,
SSLStatus: {
cipherSuite: "TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256",
- protocolVersion: 3, // TLS_VERSION_1_2
+ // TLS_VERSION_1_2
+ protocolVersion: 3,
serverCert: {
validity: {}
},
}
};
const MockHttpInfo = {
hostname: "include-subdomains.pinning.example.com",
--- a/devtools/shared/webconsole/test/unit/test_throttle.js
+++ b/devtools/shared/webconsole/test/unit/test_throttle.js
@@ -11,75 +11,75 @@ const promise = require("promise");
const { NetworkThrottleManager } =
require("devtools/shared/webconsole/throttle");
const nsIScriptableInputStream = Ci.nsIScriptableInputStream;
function TestStreamListener() {
this.state = "initial";
}
TestStreamListener.prototype = {
- onStartRequest: function() {
+ onStartRequest: function () {
this.setState("start");
},
- onStopRequest: function() {
+ onStopRequest: function () {
this.setState("stop");
},
- onDataAvailable: function(request, context, inputStream, offset, count) {
+ onDataAvailable: function (request, context, inputStream, offset, count) {
const sin = Components.classes["@mozilla.org/scriptableinputstream;1"]
.createInstance(nsIScriptableInputStream);
sin.init(inputStream);
this.data = sin.read(count);
this.setState("data");
},
- setState: function(state) {
+ setState: function (state) {
this.state = state;
if (this._deferred) {
this._deferred.resolve(state);
this._deferred = null;
}
},
- onStateChanged: function() {
+ onStateChanged: function () {
if (!this._deferred) {
this._deferred = promise.defer();
}
return this._deferred.promise;
}
};
function TestChannel() {
this.state = "initial";
this.testListener = new TestStreamListener();
this._throttleQueue = null;
}
TestChannel.prototype = {
- QueryInterface: function() {
+ QueryInterface: function () {
return this;
},
get throttleQueue() {
return this._throttleQueue;
},
set throttleQueue(q) {
this._throttleQueue = q;
this.state = "throttled";
},
- setNewListener: function(listener) {
+ setNewListener: function (listener) {
this.listener = listener;
this.state = "listener";
return this.testListener;
},
};
-add_task(function*() {
+add_task(function* () {
let throttler = new NetworkThrottleManager({
latencyMean: 1,
latencyMax: 1,
downloadBPSMean: 500,
downloadBPSMax: 500,
uploadBPSMean: 500,
uploadBPSMax: 500,
});
@@ -111,20 +111,24 @@ add_task(function*() {
out.write(TEST_INPUT, TEST_INPUT.length);
out.close();
let testInputStream = testStream.newInputStream(0);
let activityDistributor =
Cc["@mozilla.org/network/http-activity-distributor;1"]
.getService(Ci.nsIHttpActivityDistributor);
let activitySeen = false;
- listener.addActivityCallback(() => activitySeen = true, null, null, null,
- activityDistributor
- .ACTIVITY_SUBTYPE_RESPONSE_COMPLETE,
- null, TEST_INPUT.length, null);
+ listener.addActivityCallback(
+ () => {
+ activitySeen = true;
+ },
+ null, null, null,
+ activityDistributor.ACTIVITY_SUBTYPE_RESPONSE_COMPLETE,
+ null, TEST_INPUT.length, null
+ );
// onDataAvailable is required to immediately read the data.
listener.onDataAvailable(null, null, testInputStream, 0, 6);
equal(testInputStream.available(), 0, "no more data should be available");
equal(testListener.state, "start",
"test listener should not have received data");
equal(activitySeen, false, "activity not distributed yet");