Skip to content

Commit

Permalink
No bug - Run prettier on the remainder of the repo.
Browse files Browse the repository at this point in the history
  • Loading branch information
denschub committed Jul 17, 2019
1 parent 905998e commit ad25ac9
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 81 deletions.
12 changes: 2 additions & 10 deletions CODE_OF_CONDUCT.md
@@ -1,15 +1,7 @@
# Community Participation Guidelines

This repository is governed by Mozilla's code of conduct and etiquette guidelines.
For more details, please read the
[Mozilla Community Participation Guidelines](https://www.mozilla.org/about/governance/policies/participation/).
This repository is governed by Mozilla's code of conduct and etiquette guidelines. For more details, please read the [Mozilla Community Participation Guidelines](https://www.mozilla.org/about/governance/policies/participation/).

## How to Report
For more information on how to report violations of the Community Participation Guidelines, please read our '[How to Report](https://www.mozilla.org/about/governance/policies/participation/reporting/)' page.

<!--
## Project Specific Etiquette

In some cases, there will be additional project etiquette i.e.: (https://bugzilla.mozilla.org/page.cgi?id=etiquette.html).
Please update for your project.
-->
For more information on how to report violations of the Community Participation Guidelines, please read our '[How to Report](https://www.mozilla.org/about/governance/policies/participation/reporting/)' page.
42 changes: 20 additions & 22 deletions Jakefile
Expand Up @@ -23,17 +23,13 @@ const SRC_DIR = "./src";
* List of files or directories that should not get exported into
* mozilla-central.
*/
const BUILD_IGNORE_PATHS = [
".eslintrc.js"
];
const BUILD_IGNORE_PATHS = [".eslintrc.js"];

/**
* List of files or directories that should not get exported into
* an .xpi.
*/
const XPI_IGNORE_PATHS = [
"moz.build"
];
const XPI_IGNORE_PATHS = ["moz.build"];

/**
* You generally should not need to touch anything below this line for making
Expand All @@ -48,7 +44,9 @@ const XPI_IGNORE_PATHS = [
* @returns {string} the location of mozilla-central
*/
function getMozillaCentralLocation() {
let mcLocation = path.resolve(process.env.EXPORT_MC_LOCATION || "../gecko-dev");
let mcLocation = path.resolve(
process.env.EXPORT_MC_LOCATION || "../gecko-dev"
);

try {
fs.statSync(mcLocation).isDirectory();
Expand All @@ -68,9 +66,9 @@ function getMozillaCentralLocation() {
*/
function replaceFilelistPlaceholders(cssInjections, jsInjections) {
return new Promise((resolve, reject) => {
let formatList = (files) => {
files = files.map((filename) => filename.replace("build/", ""));
return "'" + files.join("',\n '") + "'"
let formatList = files => {
files = files.map(filename => filename.replace("build/", ""));
return "'" + files.join("',\n '") + "'";
};

let mozBuildFilename = path.join(BUILD_DIR, "moz.build");
Expand All @@ -83,7 +81,7 @@ function replaceFilelistPlaceholders(cssInjections, jsInjections) {
let mozBuildContents = fs.readFileSync(mozBuildFilename).toString();
mozBuildContents = mozBuildContents
.replace("@CSS_INJECTIONS@", formatList(cssInjections))
.replace("@JS_INJECTIONS@", formatList(jsInjections))
.replace("@JS_INJECTIONS@", formatList(jsInjections));

fs.writeFileSync(mozBuildFilename, mozBuildContents);
resolve();
Expand All @@ -92,7 +90,6 @@ function replaceFilelistPlaceholders(cssInjections, jsInjections) {

/**
* Exports the files to a target, used to export into mozilla-central
*
*/
function exportFiles(target) {
let mcLocation = getMozillaCentralLocation();
Expand All @@ -104,7 +101,11 @@ function exportFiles(target) {
}

desc(`Builds the extension into the ${BUILD_DIR}/ directory`);
task("build", ["building:cleanup", "building:copy", "building:injectionfilelist"], () => {});
task(
"build",
["building:cleanup", "building:copy", "building:injectionfilelist"],
() => {}
);

desc("Exports the sources into mozilla-central");
task("export-mc", ["build"], () => {
Expand All @@ -117,8 +118,8 @@ task("export-mc-android", ["build"], () => {
});

desc("Exports the sources into an .xpi for update shipping");
task("export-xpi", ["build"], {async: true}, () => {
XPI_IGNORE_PATHS.forEach((ignorePath) => {
task("export-xpi", ["build"], { async: true }, () => {
XPI_IGNORE_PATHS.forEach(ignorePath => {
jake.rmRf(path.join(BUILD_DIR, ignorePath));
});

Expand All @@ -134,21 +135,18 @@ namespace("building", () => {
desc(`Copies files into ${BUILD_DIR}/`);
task("copy", () => {
jake.cpR(SRC_DIR, BUILD_DIR);
BUILD_IGNORE_PATHS.forEach((ignorePath) => {
BUILD_IGNORE_PATHS.forEach(ignorePath => {
jake.rmRf(path.join(BUILD_DIR, ignorePath));
});
});

desc("Generates a list of injection files required for 'moz.build'");
task("injectionfilelist", () => {
let getFilelist = (injectionType) => {
let getFilelist = injectionType => {
let files = path.join(BUILD_DIR, "injections", injectionType, "*");
return (new jake.FileList()).include(files).toArray()
return new jake.FileList().include(files).toArray();
};

replaceFilelistPlaceholders(
getFilelist("css"),
getFilelist("js")
);
replaceFilelistPlaceholders(getFilelist("css"), getFilelist("js"));
});
});
33 changes: 10 additions & 23 deletions README.md
@@ -1,28 +1,18 @@
WebCompat Go Faster add-on
==========================
# WebCompat Go Faster add-on

This is the development repository for the Firefox WebCompat Go Faster add-on.

Writing site patches, overrides and injections
----------------------------------------------
## Writing site patches, overrides and injections

Detailed information on our policies on writing overrides, as well as technical
information, can be found in the [Mozilla Wiki](https://wiki.mozilla.org/Compatibility/Go_Faster_Addon/Override_Policies_and_Workflows).
Detailed information on our policies on writing overrides, as well as technical information, can be found in the [Mozilla Wiki](https://wiki.mozilla.org/Compatibility/Go_Faster_Addon/Override_Policies_and_Workflows).

Build instructions
------------------
## Build instructions

This guide assumes you've got a copy of `mozilla-central` checked out on your
machine and you already have set up Node.js 5 or newer. The build script
assumes your `mozilla-central` is located at `../fx-team` relative to inside
the root folder. If not, please set the `EXPORT_MC_LOCATION` environment
accordingly.
This guide assumes you've got a copy of `mozilla-central` checked out on your machine and you already have set up Node.js 5 or newer. The build script assumes your `mozilla-central` is located at `../fx-team` relative to inside the root folder. If not, please set the `EXPORT_MC_LOCATION` environment accordingly.

Running the extension without a built and set up `mozilla-central` is not
possible at the moment.
Running the extension without a built and set up `mozilla-central` is not possible at the moment.

If this is the first time you're working with this repository, install the
dependencies with `npm install`.
If this is the first time you're working with this repository, install the dependencies with `npm install`.

### Exporting the sources to `mozilla-central`

Expand All @@ -33,8 +23,7 @@ dependencies with `npm install`.

#### Via `about:debugging`

If you want to debug this extension on recent Desktop versions, you can use
`about:debugging`:
If you want to debug this extension on recent Desktop versions, you can use `about:debugging`:

1. Open `about:debugging` in Firefox
2. Click the `Load Temporary Add-on...` button
Expand All @@ -48,8 +37,7 @@ For Fennec, `about:debugging` is not an option. To test Fennec:
1. Run `npm start`
2. Test!

`npm start` calls [`web-ext`](https://github.com/mozilla/web-ext), check their
documentation for available parameters, including debugging options.
`npm start` calls [`web-ext`](https://github.com/mozilla/web-ext), check their documentation for available parameters, including debugging options.

### Building `webcompat.xpi`

Expand All @@ -61,7 +49,6 @@ documentation for available parameters, including debugging options.
1. Run `npm run test`
2. Wait!

License
-------
## License

MPL.
9 changes: 7 additions & 2 deletions spec/available_injections.spec.js
Expand Up @@ -39,7 +39,9 @@ for (const injection of AVAILABLE_INJECTIONS) {
});

it("provides a valid platform", () => {
expect(["all", "desktop", "android"].includes(injection.platform)).toBeTruthy();
expect(
["all", "desktop", "android"].includes(injection.platform)
).toBeTruthy();
});

it("provides a domain", () => {
Expand All @@ -61,7 +63,10 @@ for (const injection of AVAILABLE_INJECTIONS) {
continue;
}

let filename = path.join("src/", injection.contentScripts[type][0].file);
let filename = path.join(
"src/",
injection.contentScripts[type][0].file
);
let exists = fs.existsSync(filename);
expect(exists).toBe(true);
}
Expand Down
11 changes: 8 additions & 3 deletions spec/available_ua_overrides.spec.js
Expand Up @@ -5,7 +5,8 @@
"use strict";

const AVAILABLE_UA_OVERRIDES = require("../src/data/ua_overrides");
const TEST_UA = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:69.0) Gecko/20100101 Firefox/69.0";
const TEST_UA =
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:69.0) Gecko/20100101 Firefox/69.0";

describe("AVAILABLE_UA_OVERRIDES", () => {
it("contains at least one UA override definition", () => {
Expand Down Expand Up @@ -37,7 +38,9 @@ for (const override of AVAILABLE_UA_OVERRIDES) {
});

it("provides a valid platform", () => {
expect(["all", "desktop", "android"].includes(override.platform)).toBeTruthy();
expect(
["all", "desktop", "android"].includes(override.platform)
).toBeTruthy();
});

it("provides a domain", () => {
Expand All @@ -53,7 +56,9 @@ for (const override of AVAILABLE_UA_OVERRIDES) {
});

it("provides an uaTransformer that does return a string", () => {
expect(override.config.uaTransformer(TEST_UA)).toEqual(jasmine.any(String));
expect(override.config.uaTransformer(TEST_UA)).toEqual(
jasmine.any(String)
);
});
});
}
4 changes: 2 additions & 2 deletions spec/helpers/mock_about_compat_broker.js
Expand Up @@ -7,6 +7,6 @@
module.exports = {
filterOverrides: () => {},
portsToAboutCompatTabs: {
broadcast: () => {}
}
broadcast: () => {},
},
};
18 changes: 9 additions & 9 deletions spec/helpers/mock_webextension_apis.js
Expand Up @@ -16,25 +16,25 @@ jasmine.getGlobal().browser = {
return true;
},
onPrefChange: {
addListener: () => {}
}
addListener: () => {},
},
},
contentScripts: {
register: () => {}
register: () => {},
},
runtime: {
getPlatformInfo: async () => {
return {
os: "test runner"
os: "test runner",
};
}
},
},
webRequest: {
onBeforeRequest: {
addListener: () => {}
addListener: () => {},
},
onBeforeSendHeaders: {
addListener: () => {}
}
}
addListener: () => {},
},
},
};
2 changes: 1 addition & 1 deletion spec/injections.spec.js
Expand Up @@ -16,7 +16,7 @@ function buildInjection(platform) {
bug: "0",
contentScripts: {
matches: ["https://example.com/*"],
js: [{file: "test.js"}],
js: [{ file: "test.js" }],
runAt: "document_start",
},
};
Expand Down
2 changes: 1 addition & 1 deletion spec/ua_overrides.spec.js
Expand Up @@ -16,7 +16,7 @@ function buildOverride(platform) {
bug: "0",
config: {
matches: ["*://example.com/*"],
uaTransformer: (originalUA) => {
uaTransformer: originalUA => {
return originalUA + " TestingFirefox";
},
},
Expand Down
16 changes: 8 additions & 8 deletions src/data/ua_overrides.js
Expand Up @@ -15,20 +15,20 @@
const AVAILABLE_UA_OVERRIDES = [
{
/*
* Bug 1563839 - rolb.santanderbank.com - Build UA override
* WebCompat issue #33462 - https://webcompat.com/issues/33462
*
* santanderbank expects UA to have 'like Gecko', otherwise it runs
* xmlDoc.onload whose support has been dropped. It results in missing labels in forms
* and some other issues. Adding 'like Gecko' fixes those issues.
*/
* Bug 1563839 - rolb.santanderbank.com - Build UA override
* WebCompat issue #33462 - https://webcompat.com/issues/33462
*
* santanderbank expects UA to have 'like Gecko', otherwise it runs
* xmlDoc.onload whose support has been dropped. It results in missing labels in forms
* and some other issues. Adding 'like Gecko' fixes those issues.
*/
id: "bug1563839",
platform: "all",
domain: "rolb.santanderbank.com",
bug: "1563839",
config: {
matches: ["*://rolb.santanderbank.com/*"],
uaTransformer: (originalUA) => {
uaTransformer: originalUA => {
return originalUA.replace("Gecko", "like Gecko");
},
},
Expand Down

0 comments on commit ad25ac9

Please sign in to comment.