Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

block autoplay shield-study extension #3

Closed
wants to merge 91 commits into from
Closed

block autoplay shield-study extension #3

wants to merge 91 commits into from

Conversation

alastor0325
Copy link
Owner

In order to understand how do people think about the "doorhanger" project which provides a prompt to ask autoplay permission for site, we need to write a shield-study extension to collect related data and response.

According to [1], the clientId should be a part of outer common ping format, instead
of being a part of payload.

[1] https://firefox-source-docs.mozilla.org/toolkit/components/telemetry/telemetry/data/common-ping.html#common-ping-format
Should also change the config of "xpinstall.signatures.required" and "extensions.legacy.enabled" when the extension hasn't be signed yet.
User can have different ways to interact with the prompt, they can either click a button, hit the
‘escape’ key, or ignore it and do nothing.

Therefore, we add new attribute `interact` with string enum value {interact, escape, ignore}.

In addition, `rememberCheckbox` and `allowAutoPlay` will only be included if the value of `interact` is `interact`.
`responseTime` is measuring how long the prompt shows before users make their response.
`responseTime` is measuring how long the prompt shows before users make their response.
According to our final decision, we would change the number of testing cohorts to 4.

1. control (always allow)
2. block (always block)
3. allow-and-remember
4. allow-and-notRemember
Modify the description about testing branches.
Copy link

@rhelmer rhelmer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm overall - I have not tried running it locally etc. just looked over the code. I don't think any of these suggestions are blocking but could probably make things clearer here and there.

configure(studyInfo) {
const feature = this;
const { variation, isFirstRun } = studyInfo;
function generateRandomString() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a service in Firefox privileged JS to generate UUIDs if you need that.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought that we can only use privileged JS code in experiments API, not in background script?

}

function getHostName(url) {
return url.match(/^(?:https?:\/\/)?(?:[^@\n]+@)?(?:www\.)?([^:\/\n]+)/im)[1];
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could use the standard URL API to tell if a URL is valid, extract the hostname etc. instead of having to do your own regex.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In about:preferences, user can set any url into "Autoplay - Exception" which might include some formats which URL API doesn't accept. (eg. "123.com" is not a valid input format for URL API.)

Therefore, it means I need to do an additional transformation and check for every input, it would be more complicated. I would prefer to use my own regex rather than doing that.

return Services.strings.createBundle("chrome://browser/locale/browser.properties");
});

function _once(target, name) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm. I might be misunderstanding the intent here, but addEventListener takes a boolean named once if you just want an event listener to fire a single time:

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since I want to use await pattern here for waiting until the event happen, _once is just a wrapper helper function.

const { AddonStudies } = ChromeUtils.import("resource://normandy/lib/AddonStudies.jsm", {});
const { EventManager } = ExtensionCommon;

XPCOMUtils.defineLazyGetter(this, "gBrowserBundle", function() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to import XPCOMUtils for this anymore, ChromeUtils supports it like this:

ChromeUtils.defineModuleGetter(this, "MyModule",
                               "resource://MyModule.jsm");

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But here I don't define a module, I defined a getter for the variable. It seems not equal to the usage of defineModuleGetter()?

src/privileged/autoplay/api.js Outdated Show resolved Hide resolved
src/privileged/autoplay/api.js Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants