зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1326412 - Fix eslint issues in devtools/shared/webconsole/test/ r=ntim
MozReview-Commit-ID: HRrPP2p7MVs --HG-- extra : rebase_source : c40964994a4934aa436875b47dbb2b03ba13e39a
This commit is contained in:
Родитель
5e3134b8e0
Коммит
68608ad991
|
@ -0,0 +1,6 @@
|
|||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
// Extend from the shared list of defined globals for mochitests.
|
||||
"extends": "../../../../testing/mochitest/chrome.eslintrc.js"
|
||||
};
|
|
@ -3,9 +3,10 @@
|
|||
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) {
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
"use strict";
|
||||
|
||||
console.log("script evaluation");
|
||||
|
||||
addEventListener("install", function (evt) {
|
||||
|
|
|
@ -6,40 +6,45 @@
|
|||
<!-- 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() {
|
||||
|
@ -47,7 +52,7 @@
|
|||
document.cookie = "omgfoo=bug768096";
|
||||
document.cookie = "badcookie=bug826798=st3fan";
|
||||
}
|
||||
// --></script>
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Web Console HTTP Logging Testpage</h1>
|
||||
|
|
|
@ -15,8 +15,7 @@
|
|||
let expectedConsoleCalls = [];
|
||||
let expectedPageErrors = [];
|
||||
|
||||
function doPageErrors()
|
||||
{
|
||||
function doPageErrors() {
|
||||
Services.console.reset();
|
||||
|
||||
expectedPageErrors = [
|
||||
|
@ -57,8 +56,7 @@ function doPageErrors()
|
|||
document.body.removeChild(container);
|
||||
}
|
||||
|
||||
function doConsoleCalls()
|
||||
{
|
||||
function doConsoleCalls() {
|
||||
ConsoleAPIStorage.clearEvents();
|
||||
|
||||
top.console.log("foobarBaz-log", undefined);
|
||||
|
@ -102,11 +100,10 @@ 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;
|
||||
}
|
||||
|
@ -116,14 +113,13 @@ let handlers = {
|
|||
}
|
||||
},
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -134,8 +130,7 @@ let handlers = {
|
|||
},
|
||||
};
|
||||
|
||||
function startTest()
|
||||
{
|
||||
function startTest() {
|
||||
removeEventListener("load", startTest);
|
||||
|
||||
consoleAPIListener = new ConsoleAPIListener(top, handlers);
|
||||
|
@ -144,22 +139,19 @@ function startTest()
|
|||
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,
|
||||
|
@ -178,29 +170,26 @@ function onCachedConsoleAPI(aState, aResponse)
|
|||
|
||||
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,
|
||||
|
@ -219,7 +208,7 @@ function onCachedPageErrors(aState, aResponse)
|
|||
|
||||
is(expectedPageErrors.length, 0, "all expected messages have been found");
|
||||
|
||||
closeDebugger(aState, function() {
|
||||
closeDebugger(state, function() {
|
||||
SimpleTest.finish();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -39,8 +39,7 @@ const TEST_CASES = [
|
|||
}
|
||||
];
|
||||
|
||||
function startTest()
|
||||
{
|
||||
function startTest() {
|
||||
// Need to enable this pref or pinning headers are rejected due test
|
||||
// certificate.
|
||||
Services.prefs.setBoolPref(HPKP_PREF, true);
|
||||
|
@ -64,19 +63,18 @@ function 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;
|
||||
}
|
||||
|
||||
|
@ -87,18 +85,17 @@ function runNextCase(aState) {
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,17 +16,15 @@ 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");
|
||||
|
||||
|
@ -132,9 +130,8 @@ function onAttach(aState, aResponse)
|
|||
};
|
||||
}
|
||||
|
||||
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");
|
||||
|
||||
|
@ -148,26 +145,25 @@ function onConsoleCall(aState, aType, aPacket)
|
|||
}],
|
||||
});
|
||||
|
||||
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();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -16,8 +16,7 @@ SimpleTest.waitForExplicitFinish();
|
|||
|
||||
let expectedPageErrors = [];
|
||||
|
||||
function doPageErrors()
|
||||
{
|
||||
function doPageErrors() {
|
||||
expectedPageErrors = {
|
||||
"document.body.style.color = 'fooColor';": {
|
||||
errorMessage: /fooColor/,
|
||||
|
@ -128,44 +127,41 @@ function doPageErrors()
|
|||
}
|
||||
}
|
||||
|
||||
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();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -16,24 +16,21 @@ 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();
|
||||
}
|
||||
|
@ -60,13 +57,12 @@ let expectedEvents = [
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,9 +76,9 @@ function checkEvents() {
|
|||
}
|
||||
}
|
||||
|
||||
function finish(aState) {
|
||||
function finish(state) {
|
||||
client.removeListener("reflowActivity", onReflowActivity);
|
||||
closeDebugger(aState, function() {
|
||||
closeDebugger(state, function() {
|
||||
SimpleTest.finish();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ function run_test() {
|
|||
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);
|
||||
|
@ -42,7 +42,6 @@ function run_test() {
|
|||
|
||||
do_print("Running tests with dbgEnv");
|
||||
runChecks(null, dbgEnv);
|
||||
|
||||
}
|
||||
|
||||
function runChecks(dbgObject, dbgEnv) {
|
||||
|
@ -129,7 +128,8 @@ function runChecks(dbgObject, dbgEnv) {
|
|||
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);
|
||||
|
||||
|
@ -149,22 +149,22 @@ function runChecks(dbgObject, dbgEnv) {
|
|||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
|
|
@ -28,11 +28,15 @@ function test_isTextMimeType() {
|
|||
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
|
||||
|
@ -43,5 +47,6 @@ function test_isTextMimeType() {
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ Object.defineProperty(this, "NetworkHelper", {
|
|||
enumerable: true
|
||||
});
|
||||
|
||||
var Ci = Components.interfaces;
|
||||
const DUMMY_CERT = {
|
||||
commonName: "cn",
|
||||
organization: "o",
|
||||
|
|
|
@ -41,7 +41,8 @@ const MockSecurityInfo = {
|
|||
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,
|
||||
}
|
||||
};
|
||||
|
|
|
@ -17,7 +17,6 @@ Object.defineProperty(this, "NetworkHelper", {
|
|||
enumerable: true
|
||||
});
|
||||
|
||||
var Ci = Components.interfaces;
|
||||
const TEST_CASES = [
|
||||
{
|
||||
description: "TLS_VERSION_1",
|
||||
|
|
|
@ -26,7 +26,8 @@ const MockSecurityInfo = {
|
|||
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",
|
||||
}
|
||||
};
|
||||
|
|
|
@ -28,7 +28,8 @@ const MockSecurityInfo = {
|
|||
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: {}
|
||||
},
|
||||
|
|
|
@ -16,15 +16,15 @@ 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);
|
||||
|
@ -32,7 +32,7 @@ TestStreamListener.prototype = {
|
|||
this.setState("data");
|
||||
},
|
||||
|
||||
setState: function(state) {
|
||||
setState: function (state) {
|
||||
this.state = state;
|
||||
if (this._deferred) {
|
||||
this._deferred.resolve(state);
|
||||
|
@ -40,7 +40,7 @@ TestStreamListener.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
onStateChanged: function() {
|
||||
onStateChanged: function () {
|
||||
if (!this._deferred) {
|
||||
this._deferred = promise.defer();
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ function TestChannel() {
|
|||
this._throttleQueue = null;
|
||||
}
|
||||
TestChannel.prototype = {
|
||||
QueryInterface: function() {
|
||||
QueryInterface: function () {
|
||||
return this;
|
||||
},
|
||||
|
||||
|
@ -67,14 +67,14 @@ TestChannel.prototype = {
|
|||
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,
|
||||
|
@ -116,10 +116,14 @@ add_task(function*() {
|
|||
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);
|
||||
|
|
Загрузка…
Ссылка в новой задаче