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

browser polyfill cleanup, debugging improvements #3615

Merged
merged 7 commits into from
Jun 8, 2022
Merged

Conversation

fregante
Copy link
Contributor

@fregante fregante commented Jun 8, 2022

Small fixes I made along the way that didn't fit anywhere else. Details in the commits title and in the reviews

if (!("browser" in globalThis)) {
// @ts-expect-error For debugging only
globalThis.browser = browser;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This lets us finally use browser.* APIs in the console.

pageScript also has a similar jQuery global, so I thought I'd expose that too.

@@ -33,7 +32,7 @@ export async function ensureAuth(
}

try {
const token = await chromeP.identity.getAuthToken({
const token = await browser.identity.getAuthToken({
Copy link
Contributor Author

Choose a reason for hiding this comment

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

chromeP was only ever used because browser lacked the types. I fixed this a while ago:

await browser.tabs.reload(browser.devtools.inspectedWindow.tabId);

browser.runtime?.reload(); // Not guaranteed
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we request the reload, browser.tabs becomes unavailable, so the rest fails.

@@ -15,11 +15,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

const { tabId } = chrome.devtools.inspectedWindow;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was inexplicably providing a tabId global type available in every file. 😰

Mysteries of TypeScript.

this.status = status;
Object.setPrototypeOf(this, Error.prototype);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Remnant of pre-class X extends Error times

@fregante fregante requested a review from twschiller June 8, 2022 10:53
@fregante fregante marked this pull request as ready for review June 8, 2022 10:53
Copy link
Contributor

@twschiller twschiller left a comment

Choose a reason for hiding this comment

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

image

@twschiller twschiller merged commit 8644c3c into main Jun 8, 2022
@twschiller twschiller deleted the F/lint/new branch June 8, 2022 11:47
@twschiller twschiller added this to the 1.6.5 milestone Jun 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants