forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1637329 - add support for shimming resources blocking by tracking…
… protection to webcompat built-in addon; r=dimi,robwu,webcompat-reviewers,denschub,miketaylr Differential Revision: https://phabricator.services.mozilla.com/D77724
- Loading branch information
1 parent
49b2920
commit 8af08e8
Showing
40 changed files
with
2,632 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,253 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* 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/. */ | ||
|
||
"use strict"; | ||
|
||
/* globals module, require */ | ||
|
||
const AVAILABLE_SHIMS = [ | ||
{ | ||
id: "LiveTestShim", | ||
platform: "all", | ||
name: "Live test shim", | ||
bug: "livetest", | ||
file: "live-test-shim.js", | ||
matches: ["*://webcompat-addon-testbed.herokuapp.com/shims_test.js"], | ||
needsShimHelpers: ["getOptions", "optIn"], | ||
}, | ||
{ | ||
id: "MochitestShim", | ||
platform: "all", | ||
name: "Test shim for Mochitests", | ||
bug: "mochitest", | ||
file: "mochitest-shim-1.js", | ||
matches: [ | ||
"*://example.com/browser/browser/extensions/webcompat/tests/browser/shims_test.js", | ||
], | ||
needsShimHelpers: ["getOptions", "optIn"], | ||
options: { | ||
simpleOption: true, | ||
complexOption: { a: 1, b: "test" }, | ||
branchValue: { value: true, branches: [] }, | ||
platformValue: { value: true, platform: "neverUsed" }, | ||
}, | ||
unblocksOnOptIn: ["*://trackertest.org/*"], | ||
}, | ||
{ | ||
disabled: true, | ||
id: "MochitestShim2", | ||
platform: "all", | ||
name: "Test shim for Mochitests (disabled by default)", | ||
bug: "mochitest", | ||
file: "mochitest-shim-2.js", | ||
matches: [ | ||
"*://example.com/browser/browser/extensions/webcompat/tests/browser/shims_test_2.js", | ||
], | ||
needsShimHelpers: ["getOptions", "optIn"], | ||
options: { | ||
simpleOption: true, | ||
complexOption: { a: 1, b: "test" }, | ||
branchValue: { value: true, branches: [] }, | ||
platformValue: { value: true, platform: "neverUsed" }, | ||
}, | ||
unblocksOnOptIn: ["*://trackertest.org/*"], | ||
}, | ||
{ | ||
id: "MochitestShim3", | ||
platform: "all", | ||
name: "Test shim for Mochitests (host)", | ||
bug: "mochitest", | ||
file: "mochitest-shim-3.js", | ||
notHosts: ["example.com"], | ||
matches: [ | ||
"*://example.com/browser/browser/extensions/webcompat/tests/browser/shims_test_3.js", | ||
], | ||
}, | ||
{ | ||
id: "MochitestShim4", | ||
platform: "all", | ||
name: "Test shim for Mochitests (notHost)", | ||
bug: "mochitest", | ||
file: "mochitest-shim-3.js", | ||
hosts: ["example.net"], | ||
matches: [ | ||
"*://example.com/browser/browser/extensions/webcompat/tests/browser/shims_test_3.js", | ||
], | ||
}, | ||
{ | ||
id: "MochitestShim5", | ||
platform: "all", | ||
name: "Test shim for Mochitests (branch)", | ||
bug: "mochitest", | ||
file: "mochitest-shim-3.js", | ||
branches: ["never matches"], | ||
matches: [ | ||
"*://example.com/browser/browser/extensions/webcompat/tests/browser/shims_test_3.js", | ||
], | ||
}, | ||
{ | ||
id: "MochitestShim6", | ||
platform: "never matches", | ||
name: "Test shim for Mochitests (platform)", | ||
bug: "mochitest", | ||
file: "mochitest-shim-3.js", | ||
matches: [ | ||
"*://example.com/browser/browser/extensions/webcompat/tests/browser/shims_test_3.js", | ||
], | ||
}, | ||
{ | ||
id: "AdSafeProtectedGoogleIMAAdapter", | ||
platform: "all", | ||
branches: ["nightly"], | ||
name: "Ad Safe Protected Google IMA Adapter", | ||
bug: "1508639", | ||
file: "adsafeprotected-ima.js", | ||
matches: ["*://static.adsafeprotected.com/vans-adapter-google-ima.js"], | ||
needsShimHelpers: ["optIn"], | ||
onlyIfBlockedByETP: true, | ||
unblocksOnOptIn: ["*://pubads.g.doubleclick.net/gampad/ads"], | ||
}, | ||
{ | ||
id: "AdsByGoogle", | ||
platform: "all", | ||
branches: ["nightly"], | ||
name: "Ads by Google", | ||
bug: "1629644", | ||
file: "empty-script.js", | ||
matches: ["*://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"], | ||
onlyIfBlockedByETP: true, | ||
}, | ||
{ | ||
id: "BmAuth", | ||
platform: "all", | ||
branches: ["nightly"], | ||
name: "BmAuth by 9c9media", | ||
bug: "1486337", | ||
file: "bmauth.js", | ||
matches: ["*://auth.9c9media.ca/auth/main.js"], | ||
onlyIfBlockedByETP: true, | ||
}, | ||
{ | ||
id: "Eluminate", | ||
platform: "all", | ||
branches: ["nightly"], | ||
name: "Eluminate", | ||
bug: "1503211", | ||
file: "eluminate.js", | ||
matches: ["*://libs.coremetrics.com/eluminate.js"], | ||
onlyIfBlockedByETP: true, | ||
}, | ||
{ | ||
id: "FacebookSDK", | ||
platform: "all", | ||
branches: ["nightly"], | ||
name: "Facebook SDK", | ||
bug: "1226498", | ||
file: "facebook-sdk.js", | ||
matches: [ | ||
"*://connect.facebook.net/*/sdk.js*", | ||
"*://connect.facebook.net/*/all.js*", | ||
], | ||
needsShimHelpers: ["optIn"], | ||
onlyIfBlockedByETP: true, | ||
unblocksOnOptIn: [ | ||
"*://*.xx.fbcdn.net/*", // covers: | ||
// "*://scontent-.*-\d.xx.fbcdn.net/*", | ||
// "*://static.xx.fbcdn.net/rsrc.php/*", | ||
|
||
"*://www.facebook.com/plugins/comments.php*", | ||
"*://www.facebook.com/plugins/comments/async/*", | ||
"*://www.facebook.com/plugins/feedback.php*", | ||
"*://www.facebook.com/plugins/like_box.php*", | ||
], | ||
}, | ||
{ | ||
id: "GoogleAnalytics", | ||
platform: "all", | ||
branches: ["nightly"], | ||
name: "Google Analytics", | ||
bug: "1493602", | ||
file: "google-analytics.js", | ||
matches: ["*://www.google-analytics.com/analytics.js"], | ||
onlyIfBlockedByETP: true, | ||
}, | ||
{ | ||
id: "GoogleAnalyticsECommercePlugin", | ||
platform: "all", | ||
branches: ["nightly"], | ||
name: "Google Analytics E-Commerce Plugin", | ||
bug: "1620533", | ||
file: "google-analytics-ecommerce-plugin.js", | ||
matches: ["*://www.google-analytics.com/plugins/ua/ec.js"], | ||
onlyIfBlockedByETP: true, | ||
}, | ||
{ | ||
id: "GoogleAnalyticsTagManager", | ||
platform: "all", | ||
branches: ["nightly"], | ||
name: "Google Analytics Tag Manager", | ||
bug: "1478593", | ||
file: "google-analytics-tag-manager.js", | ||
matches: ["*://www.google-analytics.com/gtm/js"], | ||
onlyIfBlockedByETP: true, | ||
}, | ||
{ | ||
id: "GoogleAnalyticsLegacy", | ||
platform: "all", | ||
branches: ["nightly"], | ||
name: "Legacy Google Analytics", | ||
bug: "1487072", | ||
file: "google-analytics-legacy.js", | ||
matches: ["*://ssl.google-analytics.com/ga.js"], | ||
onlyIfBlockedByETP: true, | ||
}, | ||
{ | ||
id: "GooglePublisherTags", | ||
platform: "all", | ||
branches: ["nightly"], | ||
name: "Google Publisher Tags", | ||
bug: "1600538", | ||
file: "google-publisher-tags.js", | ||
matches: [ | ||
"*://www.googletagservices.com/tag/js/gpt.js", | ||
"*://securepubads.g.doubleclick.net/tag/js/gpt.js", | ||
"*://securepubads.g.doubleclick.net/gpt/pubads_impl_*.js", | ||
], | ||
onlyIfBlockedByETP: true, | ||
unblocksOnOptIn: ["*://pubads.g.doubleclick.net/ssai/event/*/streams"], | ||
}, | ||
{ | ||
id: "IMA3", | ||
platform: "all", | ||
branches: ["nightly"], | ||
name: "IMA3", | ||
bug: "1487373", | ||
file: "empty-script.js", | ||
onlyIfBlockedByETP: true, | ||
matches: ["*://s0.2mdn.net/instream/html5/ima3.js"], | ||
}, | ||
{ | ||
id: "Rambler", | ||
platform: "all", | ||
branches: ["nightly"], | ||
name: "Rambler Authenticator", | ||
bug: "1606428", | ||
file: "rambler-authenticator.js", | ||
matches: ["*://id.rambler.ru/rambler-id-helper/auth_events.js"], | ||
needsShimHelpers: ["optIn"], | ||
onlyIfBlockedByETP: true, | ||
}, | ||
{ | ||
id: "RichRelevance", | ||
platform: "all", | ||
branches: ["nightly"], | ||
name: "Rich Relevance", | ||
bug: "1449347", | ||
file: "rich-relevance.js", | ||
matches: ["*://media.richrelevance.com/rrserver/js/1.2/p13n.js"], | ||
onlyIfBlockedByETP: true, | ||
}, | ||
]; | ||
|
||
module.exports = AVAILABLE_SHIMS; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
browser/extensions/webcompat/experiment-apis/appConstants.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* 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/. */ | ||
|
||
"use strict"; | ||
|
||
/* global ExtensionAPI, XPCOMUtils */ | ||
|
||
XPCOMUtils.defineLazyModuleGetters(this, { | ||
AppConstants: "resource://gre/modules/AppConstants.jsm", | ||
}); | ||
|
||
this.appConstants = class extends ExtensionAPI { | ||
getAPI(context) { | ||
return { | ||
appConstants: { | ||
getReleaseBranch: () => { | ||
if (AppConstants.NIGHTLY_BUILD) { | ||
return "nightly"; | ||
} else if (AppConstants.MOZ_DEV_EDITION) { | ||
return "dev_edition"; | ||
} else if (AppConstants.EARLY_BETA_OR_EARLIER) { | ||
return "early_beta_or_earlier"; | ||
} else if (AppConstants.BETA_OR_RELEASE) { | ||
return "beta_or_release"; | ||
} | ||
return "unknown"; | ||
}, | ||
}, | ||
}; | ||
} | ||
}; |
15 changes: 15 additions & 0 deletions
15
browser/extensions/webcompat/experiment-apis/appConstants.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[ | ||
{ | ||
"namespace": "appConstants", | ||
"description": "experimental API to expose some app constants", | ||
"functions": [ | ||
{ | ||
"name": "getReleaseBranch", | ||
"type": "function", | ||
"description": "", | ||
"async": true, | ||
"parameters": [] | ||
} | ||
] | ||
} | ||
] |
30 changes: 30 additions & 0 deletions
30
browser/extensions/webcompat/experiment-apis/matchPatterns.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* 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/. */ | ||
|
||
"use strict"; | ||
|
||
/* global ExtensionAPI */ | ||
|
||
this.matchPatterns = class extends ExtensionAPI { | ||
getAPI(context) { | ||
return { | ||
matchPatterns: { | ||
getMatcher(patterns) { | ||
const set = new MatchPatternSet(patterns); | ||
return Cu.cloneInto( | ||
{ | ||
matches: url => { | ||
return set.matches(url); | ||
}, | ||
}, | ||
context.cloneScope, | ||
{ | ||
cloneFunctions: true, | ||
} | ||
); | ||
}, | ||
}, | ||
}; | ||
} | ||
}; |
29 changes: 29 additions & 0 deletions
29
browser/extensions/webcompat/experiment-apis/matchPatterns.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
[ | ||
{ | ||
"namespace": "matchPatterns", | ||
"description": "experimental API extension to expose MatchPattern functionality", | ||
"functions": [ | ||
{ | ||
"name": "getMatcher", | ||
"type": "function", | ||
"description": "get a MatchPatternSet", | ||
"parameters": [ | ||
{ | ||
"name": "patterns", | ||
"description": "Array of string URL patterns to whitelist", | ||
"type": "array", | ||
"items": { | ||
"type": "string" | ||
} | ||
} | ||
], | ||
"returns": { | ||
"type": "object", | ||
"properties": { | ||
"matches": { "type": "function" } | ||
} | ||
} | ||
} | ||
] | ||
} | ||
] |
Oops, something went wrong.