Skip to content

Commit 3e9a73f

Browse files
Release build 4.5.0 [ci release]
1 parent 801b7f2 commit 3e9a73f

File tree

23 files changed

+708
-249
lines changed

23 files changed

+708
-249
lines changed

CODEOWNERS

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,7 @@ src/locales/click-to-load/ @kzar @ladamski
1111
inject/android.js @jonathanKingston @joshliebe
1212
inject/chrome-mv3.js @kzar @sammacbeth
1313
inject/chrome.js @jonathanKingston @sammacbeth
14-
inject/windows.js @jonathanKingston @q71114 @szanto90balazs
14+
inject/windows.js @jonathanKingston @q71114 @szanto90balazs
15+
16+
# Test owners
17+
integration-tests/test-pages/ @kdzwinel @jonathanKingston

Sources/ContentScopeScripts/dist/contentScope.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,17 @@
346346
* @returns The value of the config setting or the default value
347347
*/
348348
function getFeatureAttr (featureName, args, prop, defaultValue) {
349-
let configSetting = getFeatureSetting(featureName, args, prop);
349+
const configSetting = getFeatureSetting(featureName, args, prop);
350+
return processAttr(configSetting, defaultValue)
351+
}
350352

353+
/**
354+
* Handles the processing of a config setting.
355+
* @param {*} configSetting
356+
* @param {*} defaultValue
357+
* @returns
358+
*/
359+
function processAttr (configSetting, defaultValue) {
351360
if (configSetting === undefined) {
352361
return defaultValue
353362
}
@@ -440,10 +449,22 @@
440449
}
441450
return proxyObject.apply(...args)
442451
};
452+
const getMethod = (target, prop, receiver) => {
453+
if (prop === 'toString') {
454+
const method = Reflect.get(target, prop, receiver).bind(target);
455+
Object.defineProperty(method, 'toString', {
456+
value: String.toString.bind(String.toString),
457+
enumerable: false
458+
});
459+
return method
460+
}
461+
return DDGReflect.get(target, prop, receiver)
462+
};
443463
{
444464
this._native = objectScope[property];
445465
const handler = {};
446466
handler.apply = outputHandler;
467+
handler.get = getMethod;
447468
this.internal = new globalObj.Proxy(objectScope[property], handler);
448469
}
449470
}

build/android/contentScope.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,17 @@
346346
* @returns The value of the config setting or the default value
347347
*/
348348
function getFeatureAttr (featureName, args, prop, defaultValue) {
349-
let configSetting = getFeatureSetting(featureName, args, prop);
349+
const configSetting = getFeatureSetting(featureName, args, prop);
350+
return processAttr(configSetting, defaultValue)
351+
}
350352

353+
/**
354+
* Handles the processing of a config setting.
355+
* @param {*} configSetting
356+
* @param {*} defaultValue
357+
* @returns
358+
*/
359+
function processAttr (configSetting, defaultValue) {
351360
if (configSetting === undefined) {
352361
return defaultValue
353362
}
@@ -440,10 +449,22 @@
440449
}
441450
return proxyObject.apply(...args)
442451
};
452+
const getMethod = (target, prop, receiver) => {
453+
if (prop === 'toString') {
454+
const method = Reflect.get(target, prop, receiver).bind(target);
455+
Object.defineProperty(method, 'toString', {
456+
value: String.toString.bind(String.toString),
457+
enumerable: false
458+
});
459+
return method
460+
}
461+
return DDGReflect.get(target, prop, receiver)
462+
};
443463
{
444464
this._native = objectScope[property];
445465
const handler = {};
446466
handler.apply = outputHandler;
467+
handler.get = getMethod;
447468
this.internal = new globalObj.Proxy(objectScope[property], handler);
448469
}
449470
}

build/chrome-mv3/inject.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,17 @@
280280
* @returns The value of the config setting or the default value
281281
*/
282282
function getFeatureAttr (featureName, args, prop, defaultValue) {
283-
let configSetting = getFeatureSetting(featureName, args, prop);
283+
const configSetting = getFeatureSetting(featureName, args, prop);
284+
return processAttr(configSetting, defaultValue)
285+
}
284286

287+
/**
288+
* Handles the processing of a config setting.
289+
* @param {*} configSetting
290+
* @param {*} defaultValue
291+
* @returns
292+
*/
293+
function processAttr (configSetting, defaultValue) {
285294
if (configSetting === undefined) {
286295
return defaultValue
287296
}
@@ -374,10 +383,22 @@
374383
}
375384
return proxyObject.apply(...args)
376385
};
386+
const getMethod = (target, prop, receiver) => {
387+
if (prop === 'toString') {
388+
const method = Reflect.get(target, prop, receiver).bind(target);
389+
Object.defineProperty(method, 'toString', {
390+
value: String.toString.bind(String.toString),
391+
enumerable: false
392+
});
393+
return method
394+
}
395+
return DDGReflect.get(target, prop, receiver)
396+
};
377397
{
378398
this._native = objectScope[property];
379399
const handler = {};
380400
handler.apply = outputHandler;
401+
handler.get = getMethod;
381402
this.internal = new globalObj.Proxy(objectScope[property], handler);
382403
}
383404
}

build/chrome/inject.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/firefox/inject.js

Lines changed: 23 additions & 2 deletions
Large diffs are not rendered by default.

build/integration/contentScope.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,17 @@
259259
* @returns The value of the config setting or the default value
260260
*/
261261
function getFeatureAttr (featureName, args, prop, defaultValue) {
262-
let configSetting = getFeatureSetting(featureName, args, prop);
262+
const configSetting = getFeatureSetting(featureName, args, prop);
263+
return processAttr(configSetting, defaultValue)
264+
}
263265

266+
/**
267+
* Handles the processing of a config setting.
268+
* @param {*} configSetting
269+
* @param {*} defaultValue
270+
* @returns
271+
*/
272+
function processAttr (configSetting, defaultValue) {
264273
if (configSetting === undefined) {
265274
return defaultValue
266275
}
@@ -353,10 +362,22 @@
353362
}
354363
return proxyObject.apply(...args)
355364
};
365+
const getMethod = (target, prop, receiver) => {
366+
if (prop === 'toString') {
367+
const method = Reflect.get(target, prop, receiver).bind(target);
368+
Object.defineProperty(method, 'toString', {
369+
value: String.toString.bind(String.toString),
370+
enumerable: false
371+
});
372+
return method
373+
}
374+
return DDGReflect.get(target, prop, receiver)
375+
};
356376
{
357377
this._native = objectScope[property];
358378
const handler = {};
359379
handler.apply = outputHandler;
380+
handler.get = getMethod;
360381
this.internal = new globalObj.Proxy(objectScope[property], handler);
361382
}
362383
}

build/windows/contentScope.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,17 @@
348348
* @returns The value of the config setting or the default value
349349
*/
350350
function getFeatureAttr (featureName, args, prop, defaultValue) {
351-
let configSetting = getFeatureSetting(featureName, args, prop);
351+
const configSetting = getFeatureSetting(featureName, args, prop);
352+
return processAttr(configSetting, defaultValue)
353+
}
352354

355+
/**
356+
* Handles the processing of a config setting.
357+
* @param {*} configSetting
358+
* @param {*} defaultValue
359+
* @returns
360+
*/
361+
function processAttr (configSetting, defaultValue) {
353362
if (configSetting === undefined) {
354363
return defaultValue
355364
}
@@ -442,10 +451,22 @@
442451
}
443452
return proxyObject.apply(...args)
444453
};
454+
const getMethod = (target, prop, receiver) => {
455+
if (prop === 'toString') {
456+
const method = Reflect.get(target, prop, receiver).bind(target);
457+
Object.defineProperty(method, 'toString', {
458+
value: String.toString.bind(String.toString),
459+
enumerable: false
460+
});
461+
return method
462+
}
463+
return DDGReflect.get(target, prop, receiver)
464+
};
445465
{
446466
this._native = objectScope[property];
447467
const handler = {};
448468
handler.apply = outputHandler;
469+
handler.get = getMethod;
449470
this.internal = new globalObj.Proxy(objectScope[property], handler);
450471
}
451472
}

integration-test/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ export default {
33
jsLoader: 'import',
44
spec_files: [
55
'**/*.js',
6+
'!test-pages/**/*.js',
67
'!pages/**/*.js',
78
'!extension/**/*.js'
89
],

integration-test/helpers/harness.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,29 @@ export async function setup (ops = {}) {
6464
* @returns {http.Server}
6565
*/
6666
function setupServer (port) {
67+
return _startupServerInternal('../pages', port)
68+
}
69+
70+
/**
71+
* @param {number|string} [port]
72+
* @returns {http.Server}
73+
*/
74+
function setupIntegrationPagesServer (port) {
75+
return _startupServerInternal('../test-pages', port)
76+
}
77+
78+
/**
79+
* @param {string} pathName
80+
* @param {number|string} [port]
81+
* @returns {http.Server}
82+
*/
83+
function _startupServerInternal (pathName, port) {
6784
const server = http.createServer(function (req, res) {
6885
const url = new URL(req.url, `http://${req.headers.host}`)
6986
// @ts-expect-error https://app.asana.com/0/1201614831475344/1203979574128023/f
7087
const importUrl = new URL(import.meta.url)
7188
const dirname = importUrl.pathname.replace(/\/[^/]*$/, '')
72-
const pathname = path.join(dirname, '../pages', url.pathname)
89+
const pathname = path.join(dirname, pathName, url.pathname)
7390

7491
fs.readFile(pathname, (err, data) => {
7592
if (err) {
@@ -118,10 +135,11 @@ export async function setup (ops = {}) {
118135

119136
// wait until contentScopeFeatures.init(args) has completed
120137
await page.waitForFunction(() => {
138+
window.dispatchEvent(new Event('content-scope-init-complete'))
121139
// @ts-expect-error https://app.asana.com/0/1201614831475344/1203979574128023/f
122140
return window.__content_scope_status === 'initialized'
123141
})
124142
}
125143

126-
return { browser, teardown, setupServer, gotoAndWait }
144+
return { browser, teardown, setupServer, setupIntegrationPagesServer, gotoAndWait }
127145
}

0 commit comments

Comments
 (0)