forked from mirrors/gecko-dev
Bug 1561435 - Format parser/, a=automatic-formatting
# ignore-this-changeset Differential Revision: https://phabricator.services.mozilla.com/D35923 --HG-- extra : source : 03ab20f6337a695a31afb301410182972e4195a9
This commit is contained in:
parent
27cc1e6092
commit
572c392d30
9 changed files with 659 additions and 481 deletions
|
|
@ -45,7 +45,6 @@ module.exports = {
|
||||||
"overrides": [{
|
"overrides": [{
|
||||||
"files": [
|
"files": [
|
||||||
"devtools/**",
|
"devtools/**",
|
||||||
"parser/**",
|
|
||||||
"python/**",
|
"python/**",
|
||||||
"remote/**",
|
"remote/**",
|
||||||
"security/**",
|
"security/**",
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,6 @@ toolkit/components/telemetry/datareporting-prefs.js
|
||||||
toolkit/components/telemetry/healthreport-prefs.js
|
toolkit/components/telemetry/healthreport-prefs.js
|
||||||
|
|
||||||
# Ignore all top-level directories for now.
|
# Ignore all top-level directories for now.
|
||||||
parser/**
|
|
||||||
python/**
|
python/**
|
||||||
remote/**
|
remote/**
|
||||||
security/**
|
security/**
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,10 @@
|
||||||
|
|
||||||
add_task(async function() {
|
add_task(async function() {
|
||||||
const PAGE_URL = getRootDirectory(gTestPath) + "file_viewsource.html";
|
const PAGE_URL = getRootDirectory(gTestPath) + "file_viewsource.html";
|
||||||
let viewSourceTab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "view-source:" + PAGE_URL);
|
let viewSourceTab = await BrowserTestUtils.openNewForegroundTab(
|
||||||
|
gBrowser,
|
||||||
|
"view-source:" + PAGE_URL
|
||||||
|
);
|
||||||
|
|
||||||
let xhrPromise = new Promise(resolve => {
|
let xhrPromise = new Promise(resolve => {
|
||||||
let xhr = new XMLHttpRequest();
|
let xhr = new XMLHttpRequest();
|
||||||
|
|
@ -11,12 +14,15 @@ add_task(async function() {
|
||||||
xhr.send();
|
xhr.send();
|
||||||
});
|
});
|
||||||
|
|
||||||
let viewSourceContentPromise = ContentTask.spawn(viewSourceTab.linkedBrowser, null, async function() {
|
let viewSourceContentPromise = ContentTask.spawn(
|
||||||
return content.document.body.textContent;
|
viewSourceTab.linkedBrowser,
|
||||||
});
|
null,
|
||||||
|
async function() {
|
||||||
|
return content.document.body.textContent;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
let results = await Promise.all([viewSourceContentPromise, xhrPromise]);
|
let results = await Promise.all([viewSourceContentPromise, xhrPromise]);
|
||||||
is(results[0], results[1], "Sources should match");
|
is(results[0], results[1], "Sources should match");
|
||||||
BrowserTestUtils.removeTab(viewSourceTab);
|
BrowserTestUtils.removeTab(viewSourceTab);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
/* globals state:true */
|
/* globals state:true */
|
||||||
is(document.readyState, "interactive", "readyState should be interactive during defer.");
|
is(
|
||||||
|
document.readyState,
|
||||||
|
"interactive",
|
||||||
|
"readyState should be interactive during defer."
|
||||||
|
);
|
||||||
is(state, "readyState interactive", "Bad state upon defer");
|
is(state, "readyState interactive", "Bad state upon defer");
|
||||||
state = "defer";
|
state = "defer";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,7 @@
|
||||||
/* globals state:true */
|
/* globals state:true */
|
||||||
is(document.readyState, "interactive", "readyState should be interactive during defer.");
|
is(
|
||||||
|
document.readyState,
|
||||||
|
"interactive",
|
||||||
|
"readyState should be interactive during defer."
|
||||||
|
);
|
||||||
state = "defer";
|
state = "defer";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,16 +13,14 @@
|
||||||
/**
|
/**
|
||||||
* A few utility functions.
|
* A few utility functions.
|
||||||
*/
|
*/
|
||||||
function log(entry) {
|
function log(entry) {}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function startsWith(s, s2) {
|
function startsWith(s, s2) {
|
||||||
return s.indexOf(s2) == 0;
|
return s.indexOf(s2) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function trimString(s) {
|
function trimString(s) {
|
||||||
return (s.replace(/^\s+/, "").replace(/\s+$/, ""));
|
return s.replace(/^\s+/, "").replace(/\s+$/, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -40,8 +38,9 @@ function parseTestcase(testcase) {
|
||||||
if (!line || startsWith(line, "##")) {
|
if (!line || startsWith(line, "##")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (line == "#data")
|
if (line == "#data") {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
log(lines);
|
log(lines);
|
||||||
throw new Error("Unknown test format.");
|
throw new Error("Unknown test format.");
|
||||||
}
|
}
|
||||||
|
|
@ -56,10 +55,14 @@ function parseTestcase(testcase) {
|
||||||
todo(false, line.substring(6));
|
todo(false, line.substring(6));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!(startsWith(line, "#error") ||
|
if (
|
||||||
startsWith(line, "#document") ||
|
!(
|
||||||
startsWith(line, "#document-fragment") ||
|
startsWith(line, "#error") ||
|
||||||
startsWith(line, "#data"))) {
|
startsWith(line, "#document") ||
|
||||||
|
startsWith(line, "#document-fragment") ||
|
||||||
|
startsWith(line, "#data")
|
||||||
|
)
|
||||||
|
) {
|
||||||
currentList.push(line);
|
currentList.push(line);
|
||||||
} else if (line == "#errors") {
|
} else if (line == "#errors") {
|
||||||
currentList = errors;
|
currentList = errors;
|
||||||
|
|
@ -110,10 +113,11 @@ function docToTestOutput(doc) {
|
||||||
* @param an element
|
* @param an element
|
||||||
*/
|
*/
|
||||||
function createFragmentWalker(elt) {
|
function createFragmentWalker(elt) {
|
||||||
return elt.ownerDocument.createTreeWalker(elt, NodeFilter.SHOW_ALL,
|
return elt.ownerDocument.createTreeWalker(elt, NodeFilter.SHOW_ALL, function(
|
||||||
function(node) {
|
node
|
||||||
return elt == node ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
|
) {
|
||||||
});
|
return elt == node ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -165,19 +169,25 @@ function addLevels(walker, buf, indent) {
|
||||||
}
|
}
|
||||||
var keys = Object.keys(valuesByName).sort();
|
var keys = Object.keys(valuesByName).sort();
|
||||||
for (let i = 0; i < keys.length; ++i) {
|
for (let i = 0; i < keys.length; ++i) {
|
||||||
buf += "\n" + indent + " " + keys[i] +
|
buf +=
|
||||||
"=\"" + valuesByName[keys[i]] + "\"";
|
"\n" +
|
||||||
|
indent +
|
||||||
|
" " +
|
||||||
|
keys[i] +
|
||||||
|
'="' +
|
||||||
|
valuesByName[keys[i]] +
|
||||||
|
'"';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Node.DOCUMENT_TYPE_NODE:
|
case Node.DOCUMENT_TYPE_NODE:
|
||||||
buf += "<!DOCTYPE " + walker.currentNode.name;
|
buf += "<!DOCTYPE " + walker.currentNode.name;
|
||||||
if (walker.currentNode.publicId || walker.currentNode.systemId) {
|
if (walker.currentNode.publicId || walker.currentNode.systemId) {
|
||||||
buf += " \"";
|
buf += ' "';
|
||||||
buf += walker.currentNode.publicId;
|
buf += walker.currentNode.publicId;
|
||||||
buf += "\" \"";
|
buf += '" "';
|
||||||
buf += walker.currentNode.systemId;
|
buf += walker.currentNode.systemId;
|
||||||
buf += "\"";
|
buf += '"';
|
||||||
}
|
}
|
||||||
buf += ">";
|
buf += ">";
|
||||||
break;
|
break;
|
||||||
|
|
@ -185,7 +195,7 @@ function addLevels(walker, buf, indent) {
|
||||||
buf += "<!-- " + walker.currentNode.nodeValue + " -->";
|
buf += "<!-- " + walker.currentNode.nodeValue + " -->";
|
||||||
break;
|
break;
|
||||||
case Node.TEXT_NODE:
|
case Node.TEXT_NODE:
|
||||||
buf += "\"" + walker.currentNode.nodeValue + "\"";
|
buf += '"' + walker.currentNode.nodeValue + '"';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
buf += "\n";
|
buf += "\n";
|
||||||
|
|
@ -204,4 +214,3 @@ function addLevels(walker, buf, indent) {
|
||||||
}
|
}
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,13 +21,17 @@
|
||||||
|
|
||||||
var functionsToRunAsync = [];
|
var functionsToRunAsync = [];
|
||||||
|
|
||||||
window.addEventListener("message", function(event) {
|
window.addEventListener(
|
||||||
if (event.source == window && event.data == "async-run") {
|
"message",
|
||||||
event.stopPropagation();
|
function(event) {
|
||||||
var fn = functionsToRunAsync.shift();
|
if (event.source == window && event.data == "async-run") {
|
||||||
fn();
|
event.stopPropagation();
|
||||||
}
|
var fn = functionsToRunAsync.shift();
|
||||||
}, true);
|
fn();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
function asyncRun(fn) {
|
function asyncRun(fn) {
|
||||||
functionsToRunAsync.push(fn);
|
functionsToRunAsync.push(fn);
|
||||||
|
|
@ -74,22 +78,24 @@ function makeTestChecker(input, expected, errors) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeFragmentTestChecker(input,
|
function makeFragmentTestChecker(input, expected, errors, fragment, testframe) {
|
||||||
expected,
|
|
||||||
errors,
|
|
||||||
fragment,
|
|
||||||
testframe) {
|
|
||||||
return function() {
|
return function() {
|
||||||
var context;
|
var context;
|
||||||
if (fragment.startsWith("svg ")) {
|
if (fragment.startsWith("svg ")) {
|
||||||
context = document.createElementNS("http://www.w3.org/2000/svg",
|
context = document.createElementNS(
|
||||||
fragment.substring(4));
|
"http://www.w3.org/2000/svg",
|
||||||
|
fragment.substring(4)
|
||||||
|
);
|
||||||
} else if (fragment.startsWith("math ")) {
|
} else if (fragment.startsWith("math ")) {
|
||||||
context = document.createElementNS("http://www.w3.org/1998/Math/MathML",
|
context = document.createElementNS(
|
||||||
fragment.substring(5));
|
"http://www.w3.org/1998/Math/MathML",
|
||||||
|
fragment.substring(5)
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
context = document.createElementNS("http://www.w3.org/1999/xhtml",
|
context = document.createElementNS(
|
||||||
fragment);
|
"http://www.w3.org/1999/xhtml",
|
||||||
|
fragment
|
||||||
|
);
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line no-unsanitized/property
|
// eslint-disable-next-line no-unsanitized/property
|
||||||
context.innerHTML = input;
|
context.innerHTML = input;
|
||||||
|
|
@ -104,18 +110,16 @@ function makeFragmentTestChecker(input,
|
||||||
|
|
||||||
var testcases;
|
var testcases;
|
||||||
function nextTest(testframe) {
|
function nextTest(testframe) {
|
||||||
var {done, value} = testcases.next();
|
var { done, value } = testcases.next();
|
||||||
if (done) {
|
if (done) {
|
||||||
SimpleTest.finish();
|
SimpleTest.finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var [input, output, errors, fragment] = value;
|
var [input, output, errors, fragment] = value;
|
||||||
if (fragment) {
|
if (fragment) {
|
||||||
asyncRun(makeFragmentTestChecker(input,
|
asyncRun(
|
||||||
output,
|
makeFragmentTestChecker(input, output, errors, fragment, testframe)
|
||||||
errors,
|
);
|
||||||
fragment,
|
|
||||||
testframe));
|
|
||||||
} else {
|
} else {
|
||||||
testframe.onload = makeTestChecker(input, output, errors);
|
testframe.onload = makeTestChecker(input, output, errors);
|
||||||
testframe.srcdoc = input;
|
testframe.srcdoc = input;
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,4 +1,6 @@
|
||||||
const {AppConstants} = ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
|
const { AppConstants } = ChromeUtils.import(
|
||||||
|
"resource://gre/modules/AppConstants.jsm"
|
||||||
|
);
|
||||||
if (AppConstants.platform != "android") {
|
if (AppConstants.platform != "android") {
|
||||||
// We load HTML documents, which try to track link state, which requires
|
// We load HTML documents, which try to track link state, which requires
|
||||||
// the history service, which requires a profile.
|
// the history service, which requires a profile.
|
||||||
|
|
@ -20,17 +22,26 @@ function run_test() {
|
||||||
// is set to true *before* profile-change-teardown notifications are fired.
|
// is set to true *before* profile-change-teardown notifications are fired.
|
||||||
// To work around this, just force the history service to be created earlier:
|
// To work around this, just force the history service to be created earlier:
|
||||||
|
|
||||||
let {PlacesUtils} = ChromeUtils.import("resource://gre/modules/PlacesUtils.jsm");
|
let { PlacesUtils } = ChromeUtils.import(
|
||||||
Assert.ok(PlacesUtils.history.databaseStatus <= 1, "ensure places database is successfully initialized.");
|
"resource://gre/modules/PlacesUtils.jsm"
|
||||||
|
);
|
||||||
|
Assert.ok(
|
||||||
|
PlacesUtils.history.databaseStatus <= 1,
|
||||||
|
"ensure places database is successfully initialized."
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
var ParserUtils = Cc["@mozilla.org/parserutils;1"].getService(Ci.nsIParserUtils);
|
var ParserUtils = Cc["@mozilla.org/parserutils;1"].getService(
|
||||||
var sanitizeFlags = ParserUtils.SanitizerCidEmbedsOnly | ParserUtils.SanitizerDropForms | ParserUtils.SanitizerDropNonCSSPresentation;
|
Ci.nsIParserUtils
|
||||||
|
);
|
||||||
|
var sanitizeFlags =
|
||||||
|
ParserUtils.SanitizerCidEmbedsOnly |
|
||||||
|
ParserUtils.SanitizerDropForms |
|
||||||
|
ParserUtils.SanitizerDropNonCSSPresentation;
|
||||||
// flags according to
|
// flags according to
|
||||||
// http://mxr.mozilla.org/comm-central/source/mailnews/mime/src/mimemoz2.cpp#2218
|
// http://mxr.mozilla.org/comm-central/source/mailnews/mime/src/mimemoz2.cpp#2218
|
||||||
// and default settings
|
// and default settings
|
||||||
|
|
||||||
|
|
||||||
for (var item in vectors) {
|
for (var item in vectors) {
|
||||||
var evil = vectors[item].data;
|
var evil = vectors[item].data;
|
||||||
var sanitized = vectors[item].sanitized;
|
var sanitized = vectors[item].sanitized;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue