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

Handle opaque origin error when using document.browsingTopics #235

Merged
merged 1 commit into from
Nov 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 16 additions & 13 deletions packages/extension/src/contentScript/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -516,20 +516,23 @@ class WebpageContentScript {
* Set topics to be used in the Topics landing page.
*/
async setTopics() {
if (
!document.prerendering &&
'browsingTopics' in document &&
document.featurePolicy &&
document.featurePolicy.allowsFeature('browsing-topics')
) {
const activeTabUrl = window.location.origin;
const topicsObjArr = await document.browsingTopics();
const topicsIdArr = topicsObjArr.map(
(topic: { [key: string]: string | number }) => topic.topic
);
try {
if (
!document.prerendering &&
'browsingTopics' in document &&
document.featurePolicy &&
document.featurePolicy.allowsFeature('browsing-topics')
) {
const activeTabUrl = window.location.origin;
const topicsObjArr = await document.browsingTopics();
const topicsIdArr = topicsObjArr.map(
(topic: { [key: string]: string | number }) => topic.topic
);

CookieStore.setTopics(activeTabUrl, topicsIdArr);
}
CookieStore.setTopics(activeTabUrl, topicsIdArr);
}
// eslint-disable-next-line no-empty
} catch (error) {}
}
}

Expand Down