Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Webextension review changes #2591

Merged
merged 22 commits into from
Apr 10, 2017
Merged

Webextension review changes #2591

merged 22 commits into from
Apr 10, 2017

Conversation

jaredhirsch
Copy link
Member

@jaredhirsch jaredhirsch commented Apr 6, 2017

This seems to be working fine for me locally. The outerHTML commit is reverted, I'll work on fixing that right now.

Still unaddressed things from the big review:

edited to add bug numbers

[Ian] Also added:

@jaredhirsch
Copy link
Member Author

@ianb It seems like setting the iframe's contentDocument innerHTML works equivalently to the previous use of DOMParser (see most recent commit, 7f03043). The html document inside the iframe is now not fully replaced when the overlay is rendered, but if I take multiple screenshots without reloading a content page, I don't see any errors related to multiple copies of scripts or handlers running in the iframe. Thoughts?

@jaredhirsch jaredhirsch force-pushed the webextension-review-changes branch from 7f03043 to ded7390 Compare April 7, 2017 00:40
@jaredhirsch
Copy link
Member Author

Rebased against current master

@@ -29,8 +31,8 @@ window.auth = (function () {

function generateRegistrationInfo() {
let info = {
deviceId: "anon" + makeUuid() + "",
secret: makeUuid()+"",
deviceId: `anon ${makeUuid()}`,
Copy link
Contributor

Choose a reason for hiding this comment

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

This introduces a space into the string, so anon UUID instead of anonUUID

@@ -13,7 +15,7 @@ window.analytics = (function () {
return Promise.resolve();
}
if (! telemetryPref) {
console.info(`Cancelled sendEvent ${eventCategory}/${action}/${label || 'none'} ${JSON.stringify(options)}`);
dump(`Cancelled sendEvent ${eventCategory}/${action}/${label || 'none'} ${JSON.stringify(options)}`);
Copy link
Contributor

Choose a reason for hiding this comment

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

I opened #2604 for this, which I would prefer to dump()

@@ -108,11 +110,6 @@ window.main = (function () {
title: browser.i18n.getMessage("contextMenuLabel"),
contexts: ["page"],
documentUrlPatterns: ["<all_urls>"]
}, () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this catcher is the only way to catch an error from contextMenu, unlike some of the other uses of lastError.

console.error(e.stack);
exports.unhandled(makeError(e));
throw e;
});
};

exports.registerHandler = function (h) {
if (handler) {
console.error("registerHandler called after handler was already registered");
Copy link
Contributor

Choose a reason for hiding this comment

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

We should have catcher.unhandled(new Exception("registerHandler called after handler was already registered"))

Copy link
Contributor

Choose a reason for hiding this comment

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

I take that back, catcher calling catcher will lead to bad things

@ianb ianb force-pushed the webextension-review-changes branch from f7239ca to 37c23a2 Compare April 7, 2017 17:32
} else {
num = Math.floor(Math.random() * 46656);
num = Math.floor(Math.random() * Math.pow(36, 3));
Copy link
Contributor

Choose a reason for hiding this comment

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

Do these ids need to be globally unique or just within a single account? If global, can we use crypto here? Date.now() and Math.random() make me nervous here.

Copy link
Contributor

Choose a reason for hiding this comment

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

We only want the ids for clips generated within a single shot to not conflict. This isn't used for any security-conscious situation. Things like clip image URLs are generated with UUIDs on the server.

@jaredhirsch
Copy link
Member Author

@ianb Should I merge this, or do you want to leave it open till Kris finishes responding to the review?

@ianb
Copy link
Contributor

ianb commented Apr 10, 2017

@6a68 I think Kris can still leave comments after it closes, and it's already bitrotting, let's get it landed

@jaredhirsch
Copy link
Member Author

👍 I"ll squash, rebase and land and push the fixes commit to the PR branch Kris is looking at

Addresses comments 2 and 3 inside selector/ui.js
Addresses selector/documentMetadata.js comment 1

#2471 (comment)
Addresses selector/shooter.js comment 1

#2471 (comment)
- add onActivated listener to ensure the button state is properly
  toggled when switching between tabs
TODO: investigate executeScript return value...
…into iframe"

This reverts commit 224927a0b072d2bfb851e6b45ac0ed367ab6bb93.
@jaredhirsch jaredhirsch force-pushed the webextension-review-changes branch from 549a61b to 7fc0e61 Compare April 10, 2017 23:09
@jaredhirsch jaredhirsch merged commit ebe57df into master Apr 10, 2017
@jaredhirsch jaredhirsch deleted the webextension-review-changes branch April 10, 2017 23:19
jaredhirsch added a commit that referenced this pull request Apr 10, 2017
* Add strict mode statement to all files

Addresses review comment #2471 (comment)

* Do not assign properties to `window`.

Addresses review comment #2471 (comment)

* Use docElement.outerHTML, not DOMParser, to insert html page into iframe

Addresses comments 2 and 3 inside selector/ui.js

* Use for..of instead of for-loop

Addresses selector/documentMetadata.js comment 1

#2471 (comment)

* Replace IIFE with block scope, yay es6

Addresses selector/shooter.js comment 1

#2471 (comment)

* Use spread/rest operators to simplify assert() fn logic

Addresses shared/shot.js comment 1

#2471 (comment)

* WIP fixes to shared/shot

* Nit - replace let..in with let..of

* Nit: replace foo+"" with String(foo)

* nits related to catcher.js

* auth updates

* review changes to main.js

- add onActivated listener to ensure the button state is properly
  toggled when switching between tabs

* selectorLoader changes

TODO: investigate executeScript return value...

* last few review nits

* Revert "Use docElement.outerHTML, not DOMParser, to insert html page into iframe"

This reverts commit 224927a0b072d2bfb851e6b45ac0ed367ab6bb93.

* Use innerHTML: outerHTML throws a NoModificationAllowedError

* Please the linter

* Fix #2596, address review nit in randomString.js

* Remove space in deviceId generation

* Restore lastError handler for contextMenus.create

* Rename shot.js makeUuid to more accurate makeRandomId

* Fix #2603, abstract out sendToBootstrap error checking
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants