-
Notifications
You must be signed in to change notification settings - Fork 23
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
Changes from all commits
59fb9fa
639eddd
c7c8169
655727f
f1fa4fd
65ff1f5
d3a9313
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,5 +13,3 @@ updates: | |
time: "08:42" | ||
timezone: "Etc/UTC" | ||
open-pull-requests-limit: 20 | ||
reviewers: | ||
- "fregante" |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,6 @@ | |
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import chromeP from "webext-polyfill-kinda"; | ||
import { getErrorMessage } from "@/errors/errorHelpers"; | ||
import { forbidContext } from "@/utils/expectContext"; | ||
|
||
|
@@ -33,7 +32,7 @@ export async function ensureAuth( | |
} | ||
|
||
try { | ||
const token = await chromeP.identity.getAuthToken({ | ||
const token = await browser.identity.getAuthToken({ | ||
interactive, | ||
scopes, | ||
}); | ||
|
@@ -54,10 +53,9 @@ class PermissionsError extends Error { | |
|
||
public readonly status: number; | ||
|
||
constructor(m: string, status: number) { | ||
super(m); | ||
constructor(message: string, status: number) { | ||
super(message); | ||
this.status = status; | ||
Object.setPrototypeOf(this, Error.prototype); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remnant of pre- |
||
} | ||
} | ||
|
||
|
@@ -80,7 +78,7 @@ export async function handleRejection( | |
} | ||
|
||
if ([403, 401].includes(status)) { | ||
await chromeP.identity.removeCachedAuthToken({ token }); | ||
await browser.identity.removeCachedAuthToken({ token }); | ||
console.debug( | ||
"Bad Google OAuth token. Removed the auth token from the cache so the user can re-authenticate" | ||
); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,3 +25,11 @@ enrichAxiosErrors(); | |
|
||
// https://webpack.js.org/guides/public-path/#on-the-fly | ||
__webpack_public_path__ = chrome.runtime.getURL("/"); | ||
|
||
// @ts-expect-error For debugging only | ||
globalThis.$ = $; | ||
|
||
if (!("browser" in globalThis)) { | ||
// @ts-expect-error For debugging only | ||
globalThis.browser = browser; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This lets us finally use
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,9 +79,10 @@ const ReloadButton: React.VoidFunctionComponent = () => ( | |
className="mt-auto" | ||
onClick={async (event) => { | ||
if (event.shiftKey) { | ||
browser.runtime?.reload(); // Not guaranteed | ||
await browser.tabs.reload(browser.devtools.inspectedWindow.tabId); | ||
|
||
browser.runtime?.reload(); // Not guaranteed | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we request the reload, |
||
|
||
// We must wait before reloading or else the loading fails | ||
// https://github.com/pixiebrix/pixiebrix-extension/pull/2381 | ||
await sleep(2000); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,11 +15,10 @@ | |
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
const { tabId } = chrome.devtools.inspectedWindow; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was inexplicably providing a Mysteries of TypeScript. |
||
if (typeof tabId === "number") { | ||
if (typeof chrome.devtools.inspectedWindow.tabId === "number") { | ||
chrome.devtools.panels.create( | ||
"PixieBrix", | ||
"", | ||
`pageEditor.html?tabId=${tabId}` | ||
`pageEditor.html?tabId=${chrome.devtools.inspectedWindow.tabId}` | ||
); | ||
} |
There was a problem hiding this comment.
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 becausebrowser
lacked the types. I fixed this a while ago: