Skip to content

Commit

Permalink
Bug 1576768 - Automatically format .sjs files using prettier. r=Stand…
Browse files Browse the repository at this point in the history
…ard8,agi,zombie,extension-reviewers

# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D128482
  • Loading branch information
janekotovich committed Oct 17, 2021
1 parent a7f5530 commit 3e3dff1
Show file tree
Hide file tree
Showing 421 changed files with 7,268 additions and 5,021 deletions.
5 changes: 4 additions & 1 deletion accessible/tests/mochitest/events/slow_image.sjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ const IMG_BYTES = atob(

// stolen from file_blocked_script.sjs
function setGlobalState(data, key) {
x = { data: data, QueryInterface: function(iid) { return this } };
x = {
data,
QueryInterface: ChromeUtils.generateQI([]),
};
x.wrappedJSObject = x;
setObjectState(key, x);
}
Expand Down
10 changes: 7 additions & 3 deletions browser/base/content/test/about/csp_iframe.sjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@

function handleRequest(request, response) {
// let's enjoy the amazing CSP setting
response.setHeader("Content-Security-Policy", "frame-ancestors 'self'", false);
response.setHeader(
"Content-Security-Policy",
"frame-ancestors 'self'",
false
);

// let's avoid caching issues
response.setHeader("Pragma", "no-cache");
Expand All @@ -18,8 +22,8 @@ function handleRequest(request, response) {
let cookie = request.hasHeader("Cookie")
? request.getHeader("Cookie")
: "<html><body>" +
"<h2 id='strictCookie'>No same site strict cookie header</h2>" +
"</body></html>";
"<h2 id='strictCookie'>No same site strict cookie header</h2>" +
"</body></html>";
response.write(cookie);

if (!request.hasHeader("Cookie")) {
Expand Down
11 changes: 7 additions & 4 deletions browser/base/content/test/about/print_postdata.sjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
const CC = Components.Constructor;
const BinaryInputStream = CC("@mozilla.org/binaryinputstream;1",
"nsIBinaryInputStream",
"setInputStream");
const BinaryInputStream = CC(
"@mozilla.org/binaryinputstream;1",
"nsIBinaryInputStream",
"setInputStream"
);

function handleRequest(request, response) {
response.setHeader("Content-Type", "text/plain", false);
Expand All @@ -13,8 +15,9 @@ function handleRequest(request, response) {
var avail;
var bytes = [];

while ((avail = body.available()) > 0)
while ((avail = body.available()) > 0) {
Array.prototype.push.apply(bytes, body.readByteArray(avail));
}

var data = String.fromCharCode.apply(null, bytes);
response.bodyOutputStream.write(data, data.length);
Expand Down
7 changes: 4 additions & 3 deletions browser/base/content/test/about/xfo_iframe.sjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ function handleRequest(request, response) {
response.setStatusLine(request.httpVersion, 200);

response.setHeader("Content-Type", "text/html", false);
let txt = "<html><head><title>XFO page</title></head>" +
let txt =
"<html><head><title>XFO page</title></head>" +
"<body><h1>" +
"XFO blocked page opened in new window!" +
"</h1></body></html>";
Expand All @@ -22,8 +23,8 @@ function handleRequest(request, response) {
let cookie = request.hasHeader("Cookie")
? request.getHeader("Cookie")
: "<html><body>" +
"<h2 id='strictCookie'>No same site strict cookie header</h2></body>" +
"</html>";
"<h2 id='strictCookie'>No same site strict cookie header</h2></body>" +
"</html>";
response.write(cookie);

if (!request.hasHeader("Cookie")) {
Expand Down
5 changes: 4 additions & 1 deletion browser/base/content/test/favicons/cookie_favicon.sjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ function handleRequest(request, response) {

response.setStatusLine(request.httpVersion, 302, "Moved Temporarily");
response.setHeader("Set-Cookie", `faviconCookie=${++state}`);
response.setHeader("Location", "http://example.com/browser/browser/base/content/test/favicons/moz.png");
response.setHeader(
"Location",
"http://example.com/browser/browser/base/content/test/favicons/moz.png"
);
setState("cache_cookie", `${state}`);
}
3 changes: 1 addition & 2 deletions browser/base/content/test/general/browser_star_hsts.sjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

function handleRequest(request, response)
{
function handleRequest(request, response) {
let page = "<!DOCTYPE html><html><body><p>HSTS page</p></body></html>";
response.setStatusLine(request.httpVersion, "200", "OK");
response.setHeader("Strict-Transport-Security", "max-age=60");
Expand Down
14 changes: 7 additions & 7 deletions browser/base/content/test/general/bug792517.sjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
*/

function handleRequest(aRequest, aResponse) {
aResponse.setStatusLine(aRequest.httpVersion, 200);
if (aRequest.hasHeader('Cookie')) {
aResponse.write("cookie-present");
} else {
aResponse.setHeader("Set-Cookie", "foopy=1");
aResponse.write("cookie-not-present");
}
aResponse.setStatusLine(aRequest.httpVersion, 200);
if (aRequest.hasHeader("Cookie")) {
aResponse.write("cookie-present");
} else {
aResponse.setHeader("Set-Cookie", "foopy=1");
aResponse.write("cookie-not-present");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,17 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

function handleRequest(request, response)
{
function handleRequest(request, response) {
let page = "download";
response.setStatusLine(request.httpVersion, "200", "OK");

let [first, second] = request.queryString.split('=');
let [first, second] = request.queryString.split("=");
let headerStr = first;
if (second !== "none") {
headerStr += "; filename=" + second;
}

response.setHeader(
"Content-Disposition",
headerStr);
response.setHeader("Content-Disposition", headerStr);
response.setHeader("Content-Type", "text/plain", false);
response.setHeader("Content-Length", page.length + "", false);
response.write(page);
Expand Down
11 changes: 7 additions & 4 deletions browser/base/content/test/general/print_postdata.sjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
const CC = Components.Constructor;
const BinaryInputStream = CC("@mozilla.org/binaryinputstream;1",
"nsIBinaryInputStream",
"setInputStream");
const BinaryInputStream = CC(
"@mozilla.org/binaryinputstream;1",
"nsIBinaryInputStream",
"setInputStream"
);

function handleRequest(request, response) {
response.setHeader("Content-Type", "text/plain", false);
Expand All @@ -13,8 +15,9 @@ function handleRequest(request, response) {
var avail;
var bytes = [];

while ((avail = body.available()) > 0)
while ((avail = body.available()) > 0) {
Array.prototype.push.apply(bytes, body.readByteArray(avail));
}

var data = String.fromCharCode.apply(null, bytes);
response.bodyOutputStream.write(data, data.length);
Expand Down
4 changes: 3 additions & 1 deletion browser/base/content/test/general/redirect_download.sjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ function handleRequest(request, response) {
response.setStatusLine("1.1", 302, "Found");
response.setHeader(
"Location",
`download_with_content_disposition_header.sjs?${queryStr}`, false);
`download_with_content_disposition_header.sjs?${queryStr}`,
false
);
}
2 changes: 1 addition & 1 deletion browser/base/content/test/general/refresh_header.sjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ function handleRequest(request, response) {
response.setStatusLine(request.httpVersion, "200", "Found");
response.setHeader("refresh", `${delay}; url=${page}`);
response.write("OK");
}
}
2 changes: 1 addition & 1 deletion browser/base/content/test/general/refresh_meta.sjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ function handleRequest(request, response) {
response.setStatusLine(request.httpVersion, "200", "Found");
response.setHeader("Cache-Control", "no-cache", false);
response.write(html);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ function handleRequest(req, resp) {

let timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
resp.write(AUTOPLAY_HTML);
timer.init(() => {
resp.write("");
resp.finish();
}, DELAY_MS, Ci.nsITimer.TYPE_ONE_SHOT);
timer.init(
() => {
resp.write("");
resp.finish();
},
DELAY_MS,
Ci.nsITimer.TYPE_ONE_SHOT
);
}
12 changes: 8 additions & 4 deletions browser/base/content/test/protectionsUI/cookieServer.sjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@

// A 1x1 PNG image.
// Source: https://commons.wikimedia.org/wiki/File:1x1.png (Public Domain)
const IMAGE = atob("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAA" +
"ACnej3aAAAAAXRSTlMAQObYZgAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=");
const IMAGE = atob(
"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAA" +
"ACnej3aAAAAAXRSTlMAQObYZgAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII="
);

function handleRequest(request, response) {
response.setStatusLine(request.httpVersion, 200);
if (request.queryString &&
request.queryString.includes("type=image-no-cookie")) {
if (
request.queryString &&
request.queryString.includes("type=image-no-cookie")
) {
response.setHeader("Content-Type", "image/png", false);
response.write(IMAGE);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
* Used in browser_referrer_*.js, bug 1113431.
* Arguments: ?scheme=http://&policy=origin&rel=noreferrer
*/
function handleRequest(request, response)
{
function handleRequest(request, response) {
Components.utils.importGlobalProperties(["URLSearchParams"]);
let query = new URLSearchParams(request.queryString);

Expand All @@ -14,11 +13,14 @@ function handleRequest(request, response)
let cross = query.get("cross");

let host = cross ? "example.com" : "test1.example.com";
let linkUrl = scheme + host +
"/browser/browser/base/content/test/referrer/" +
"file_referrer_testserver.sjs";
let metaReferrerTag =
policy ? `<meta name='referrer' content='${policy}'>` : "";
let linkUrl =
scheme +
host +
"/browser/browser/base/content/test/referrer/" +
"file_referrer_testserver.sjs";
let metaReferrerTag = policy
? `<meta name='referrer' content='${policy}'>`
: "";

let html = `<!DOCTYPE HTML>
<html>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
* Used in browser_referrer_*.js, bug 1113431.
* Arguments: ?scheme=http://&policy=origin&rel=noreferrer
*/
function handleRequest(request, response)
{
function handleRequest(request, response) {
Components.utils.importGlobalProperties(["URLSearchParams"]);
let query = new URLSearchParams(request.queryString);

Expand All @@ -14,12 +13,13 @@ function handleRequest(request, response)
let cross = query.get("cross");

let host = cross ? "example.com" : "test1.example.com";
let linkUrl = scheme + host +
"/browser/browser/base/content/test/referrer/" +
"file_referrer_testserver.sjs";
let linkUrl =
scheme +
host +
"/browser/browser/base/content/test/referrer/" +
"file_referrer_testserver.sjs";

let referrerPolicy =
policy ? `referrerpolicy="${policy}"` : "";
let referrerPolicy = policy ? `referrerpolicy="${policy}"` : "";

let html = `<!DOCTYPE HTML>
<html>
Expand All @@ -28,7 +28,9 @@ function handleRequest(request, response)
<title>Test referrer</title>
</head>
<body>
<a id='testlink' href='${linkUrl}' ${referrerPolicy} ${rel ? ` rel='${rel}'` : ""}>
<a id='testlink' href='${linkUrl}' ${referrerPolicy} ${
rel ? ` rel='${rel}'` : ""
}>
referrer test link</a>
</body>
</html>`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
* Renders the HTTP Referer header up to the second path slash.
* Used in browser_referrer_*.js, bug 1113431.
*/
function handleRequest(request, response)
{
function handleRequest(request, response) {
let referrer = "";
try {
referrer = request.getHeader("referer");
Expand All @@ -12,7 +11,10 @@ function handleRequest(request, response)
}

// Strip it past the first path slash. Makes tests easier to read.
referrer = referrer.split("/").slice(0, 4).join("/");
referrer = referrer
.split("/")
.slice(0, 4)
.join("/");

let html = `<!DOCTYPE HTML>
<html>
Expand Down
5 changes: 3 additions & 2 deletions browser/base/content/test/siteIdentity/file_bug906190.sjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
function handleRequest(request, response) {
var page = "<!DOCTYPE html><html><body>bug 906190</body></html>";
var path = "https://test1.example.com/browser/browser/base/content/test/siteIdentity/";
var path =
"https://test1.example.com/browser/browser/base/content/test/siteIdentity/";
var url;

if (request.queryString.includes('bad-redirection=1')) {
if (request.queryString.includes("bad-redirection=1")) {
url = path + "this_page_does_not_exist.html";
} else {
url = path + "file_bug906190_redirected.html";
Expand Down
11 changes: 7 additions & 4 deletions browser/base/content/test/siteIdentity/test_mcb_redirect.sjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
function handleRequest(request, response) {
var page = "<!DOCTYPE html><html><body>bug 418354 and bug 1082837</body></html>";
var page =
"<!DOCTYPE html><html><body>bug 418354 and bug 1082837</body></html>";

if (request.queryString === "script") {
var redirect = "http://example.com/browser/browser/base/content/test/siteIdentity/test_mcb_redirect.js";
if (request.queryString === "script") {
var redirect =
"http://example.com/browser/browser/base/content/test/siteIdentity/test_mcb_redirect.js";
response.setHeader("Cache-Control", "no-cache", false);
} else if (request.queryString === "image_http") {
var redirect = "http://example.com/tests/image/test/mochitest/blue.png";
response.setHeader("Cache-Control", "max-age=3600", false);
} else if (request.queryString === "image_redirect_http_sjs") {
var redirect = "http://example.com/browser/browser/base/content/test/siteIdentity/test_mcb_redirect.sjs?image_redirect_https";
var redirect =
"http://example.com/browser/browser/base/content/test/siteIdentity/test_mcb_redirect.sjs?image_redirect_https";
response.setHeader("Cache-Control", "max-age=3600", false);
} else if (request.queryString === "image_redirect_https") {
var redirect = "https://example.com/tests/image/test/mochitest/blue.png";
Expand Down
16 changes: 13 additions & 3 deletions browser/components/contextualidentity/test/browser/saveLink.sjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const HTTP_ORIGIN = "http://example.com";
const HTTPS_ORIGIN = "https://example.com";
const URI_PATH = "/browser/browser/components/contextualidentity/test/browser/saveLink.sjs";
const URI_PATH =
"/browser/browser/components/contextualidentity/test/browser/saveLink.sjs";

Components.utils.importGlobalProperties(["URLSearchParams"]);

Expand All @@ -11,15 +12,24 @@ function handleRequest(aRequest, aResponse) {
if (params.has("UCI")) {
aResponse.setStatusLine(aRequest.httpVersion, 200);
aResponse.setHeader("Set-Cookie", "UCI=" + params.get("UCI"));
aResponse.write("<html><body><a href='" + HTTPS_ORIGIN + URI_PATH + "?redirect=1' id='fff'>this is a link</a></body></html>");
aResponse.write(
"<html><body><a href='" +
HTTPS_ORIGIN +
URI_PATH +
"?redirect=1' id='fff'>this is a link</a></body></html>"
);
return;
}

// Second request. This is the save-as content, but we make a redirect to see
// if we are able to follow it.
if (params.has("redirect")) {
aResponse.setStatusLine(aRequest.httpVersion, 302, "Found");
aResponse.setHeader("Location", HTTP_ORIGIN + URI_PATH + "?download=1", false);
aResponse.setHeader(
"Location",
HTTP_ORIGIN + URI_PATH + "?download=1",
false
);
aResponse.write("Redirect!");
return;
}
Expand Down
Loading

0 comments on commit 3e3dff1

Please sign in to comment.