Skip to content

Commit 2064579

Browse files
committed
Merge branch 'dbajpeyi/fix/infinite-retry-export-id' of github.com:duckduckgo/content-scope-scripts into dbajpeyi/fix/infinite-retry-export-id
2 parents b109211 + 2a540b3 commit 2064579

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+316
-29
lines changed

injected/src/config-feature.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export default class ConfigFeature {
3030
* platform: import('./utils.js').Platform,
3131
* desktopModeEnabled?: boolean,
3232
* forcedZoomEnabled?: boolean,
33+
* isDdgWebView?: boolean,
3334
* featureSettings?: Record<string, unknown>,
3435
* assets?: import('./content-feature.js').AssetConfig | undefined,
3536
* site: import('./content-feature.js').Site,

injected/src/features/windows-permission-usage.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@ export default class WindowsPermissionUsage extends ContentFeature {
1717
Paused: 'paused',
1818
};
1919

20-
const isFrameInsideFrame = window.self !== window.top && window.parent !== window.top;
20+
// isDdgWebView is a Windows-specific property injected via userPreferences
21+
const isDdgWebView = this.args?.isDdgWebView;
22+
23+
const isFrameInsideFrameInWebView2 = isDdgWebView
24+
? false // In DDG WebView, we can handle nested frames properly
25+
: window.self !== window.top && window.parent !== window.top; // In WebView2, we need to deny permission for nested frames
2126

2227
function windowsPostMessage(name, data) {
2328
// @ts-expect-error https://app.asana.com/0/1201614831475344/1203979574128023/f
@@ -38,8 +43,8 @@ export default class WindowsPermissionUsage extends ContentFeature {
3843
// proxy for navigator.geolocation.watchPosition -> show red geolocation indicator
3944
const watchPositionProxy = new DDGProxy(this, Geolocation.prototype, 'watchPosition', {
4045
apply(target, thisArg, args) {
41-
if (isFrameInsideFrame) {
42-
// we can't communicate with iframes inside iframes -> deny permission instead of putting users at risk
46+
if (isFrameInsideFrameInWebView2) {
47+
// we can't communicate with iframes inside iframes in WebView2 -> deny permission instead of putting users at risk
4348
throw new DOMException('Permission denied');
4449
}
4550

@@ -313,8 +318,8 @@ export default class WindowsPermissionUsage extends ContentFeature {
313318
if (window.MediaDevices) {
314319
const getUserMediaProxy = new DDGProxy(this, MediaDevices.prototype, 'getUserMedia', {
315320
apply(target, thisArg, args) {
316-
if (isFrameInsideFrame) {
317-
// we can't communicate with iframes inside iframes -> deny permission instead of putting users at risk
321+
if (isFrameInsideFrameInWebView2) {
322+
// we can't communicate with iframes inside iframes in WebView2-> deny permission instead of putting users at risk
318323
return Promise.reject(new DOMException('Permission denied'));
319324
}
320325

special-pages/pages/history/app/components/Item.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const Item = memo(
1818
* @param {string} props.url - The text to be displayed for the item.
1919
* @param {string} props.domain - The text to be displayed for the domain
2020
* @param {number} props.kind - The kind or type of the item that determines its visual style.
21-
* @param {string} props.dateTimeOfDay - the time of day, like 11.00am.
21+
* @param {string} [props.dateTimeOfDay] - the time of day, like 11.00am.
2222
* @param {string} props.dateRelativeDay - the time of day, like 11.00am.
2323
* @param {string|null} props.etldPlusOne
2424
* @param {number} props.index - original index
@@ -63,7 +63,7 @@ export const Item = memo(
6363
<span class={styles.domain} data-testid="Item.domain" title={props.domain}>
6464
{props.domain}
6565
</span>
66-
<span class={styles.time}>{dateTimeOfDay}</span>
66+
{dateTimeOfDay && <span className={styles.time}>{dateTimeOfDay}</span>}
6767
<button class={styles.dots} data-action={BTN_ACTION_ENTRIES_MENU} data-index={index} value={props.id} tabindex={-1}>
6868
<Dots />
6969
</button>

special-pages/pages/history/app/components/Sidebar.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const iconMap = {
2828
saturday: 'icons/day.svg',
2929
sunday: 'icons/day.svg',
3030
older: 'icons/older.svg',
31+
sites: 'icons/sites.svg',
3132
};
3233

3334
/** @type {Record<RangeId, (t: (s: keyof json) => string) => string>} */
@@ -43,6 +44,7 @@ const titleMap = {
4344
saturday: (t) => t('range_saturday'),
4445
sunday: (t) => t('range_sunday'),
4546
older: (t) => t('range_older'),
47+
sites: (t) => t('range_sites'),
4648
};
4749

4850
/**
@@ -106,7 +108,7 @@ function Item({ current, range, onClick, onDelete, count }) {
106108
if (range === 'all' && current.value === null) {
107109
return cn(styles.item, styles.active);
108110
}
109-
return cn(styles.item, current.value === range && styles.active);
111+
return cn(styles.item, current.value === range && styles.active, styles[`item_${range}`]);
110112
});
111113

112114
return (
@@ -182,6 +184,7 @@ function labels(range, t) {
182184
case 'thursday':
183185
case 'friday':
184186
case 'saturday':
187+
case 'sites':
185188
case 'sunday':
186189
return { linkLabel: t('show_history_for', { range }), buttonLabel: t('delete_history_for', { range }) };
187190
case 'older':

special-pages/pages/history/app/components/Sidebar.module.css

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,23 @@
3939
background: var(--color-white-at-6);
4040
}
4141
}
42+
43+
&.item_sites {
44+
margin-top: 16px;
45+
46+
&::before {
47+
content: '';
48+
position: absolute;
49+
top: -8px;
50+
left: 16px;
51+
right: 16px;
52+
border-top: 1px solid var(--color-black-at-6);
53+
}
54+
55+
[data-theme="dark"] &::before {
56+
border-top: 1px solid var(--color-white-at-6);
57+
}
58+
}
4259
}
4360

4461
.item:hover .delete[aria-disabled="true"] {

special-pages/pages/history/app/history.service.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,7 @@ export function toRange(input) {
421421
'sunday',
422422
'recentlyOpened',
423423
'older',
424+
'sites',
424425
];
425426
return valid.includes(input) ? /** @type {import('../types/history.js').RangeId} */ (input) : null;
426427
}

special-pages/pages/history/app/mocks/mock-transport.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export function mockTransport() {
4040
{ id: 'saturday', count: 1 },
4141
{ id: 'friday', count: 1 },
4242
{ id: 'older', count: 1 },
43+
{ id: 'sites', count: 1 },
4344
],
4445
};
4546

@@ -268,8 +269,10 @@ function queryResponseFrom(memory, msg) {
268269
const response = asResponse(memory.slice(0, 10), msg.params.offset, msg.params.limit);
269270
const range = msg.params.query.range;
270271
response.value = response.value.map((item) => {
272+
if (!('range' in msg.params.query)) return item; // unreachable
271273
return {
272274
...item,
275+
dateTimeOfDay: msg.params.query.range === 'sites' ? undefined : item.dateTimeOfDay,
273276
title: 'range:' + range + ' ' + item.title,
274277
};
275278
});

special-pages/pages/history/app/strings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,5 +106,9 @@
106106
"range_older": {
107107
"title": "Older",
108108
"note": "Label on a button that shows older history entries."
109+
},
110+
"range_sites": {
111+
"title": "Sites",
112+
"note": "Label on a button that shows which sites have been visited"
109113
}
110114
}

special-pages/pages/history/integration-tests/history.page.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,15 @@ export class HistoryTestPage {
601601
const rgb = `rgb(${[r, g, b].join(', ')})`;
602602
await expect(this.page.locator('[data-layout-mode="normal"]')).toHaveCSS('background-color', rgb, { timeout: 50 });
603603
}
604+
605+
async lastItemDividerHasColor({ rgb }) {
606+
const lastItem = this.sidebar().locator('.Sidebar_item').last();
607+
const borderTopColor = await lastItem.evaluate((el) => {
608+
const before = window.getComputedStyle(el, '::before');
609+
return before.borderTopColor;
610+
});
611+
expect(borderTopColor).toBe(rgb);
612+
}
604613
}
605614

606615
/**
1.61 KB
Loading

0 commit comments

Comments
 (0)