Skip to content

Jkt/enum block frame conditional #1725

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

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ injected/src/features/Scriptlets
**/*.json
**/*.md
**/*.html
!injected/integration-test/test-pages/infra/pages/conditional-matching.html
**/*.har
**/*.css
24 changes: 24 additions & 0 deletions injected/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,30 @@ Everything within `integration-test` is integration tests controlled by Playwrig
npm run test-int
```

**Running specific tests:**

To run a specific test or test suite, you can use the `--grep` flag to filter tests by name:

```shell
# Run tests containing "Test infra" in their name
npx playwright test pages.spec.js --grep "Test infra"

# Run tests containing "Conditional frame matching" in their name
npx playwright test pages.spec.js --grep "Conditional frame matching"

# Run tests in headed mode (shows browser window)
npx playwright test pages.spec.js --grep "Test infra" --headed
```

**Debugging tests:**

For debugging, you can run tests in headed mode and add debugging output:

```shell
# Run with browser visible and debugging enabled
npx playwright test pages.spec.js --grep "Test infra" --headed --debug
```

#### Feature Build process

To produce all artefacts that are used by platforms, just run the `npm run build` command.
Expand Down
27 changes: 9 additions & 18 deletions injected/entry-points/integration.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
import { load, init } from '../src/content-scope-features.js';
import { TestTransportConfig } from '../../messaging/index.js';
function getTopLevelURL() {
try {
// FROM: https://stackoverflow.com/a/7739035/73479
// FIX: Better capturing of top level URL so that trackers in embedded documents are not considered first party
if (window.location !== window.parent.location) {
return new URL(window.location.href !== 'about:blank' ? document.referrer : window.parent.location.href);
} else {
return new URL(window.location.href);
}
} catch (error) {
return new URL(location.href);
}
}
import { getTabUrl } from '../src/utils.js';

function generateConfig() {
const topLevelUrl = getTopLevelURL();
const topLevelUrl = getTabUrl();
return {
debug: false,
sessionKey: 'randomVal',
Expand All @@ -35,8 +23,8 @@ function generateConfig() {
},
],
site: {
domain: topLevelUrl.hostname,
url: topLevelUrl.href,
domain: topLevelUrl?.hostname || '',
url: topLevelUrl?.href || '',
isBroken: false,
allowlisted: false,
enabledFeatures: [
Expand Down Expand Up @@ -86,7 +74,7 @@ function mergeDeep(target, ...sources) {
}

async function initCode() {
const topLevelUrl = getTopLevelURL();
const topLevelUrl = getTabUrl();
const processedConfig = generateConfig();

// mock Messaging and allow for tests to intercept them
Expand Down Expand Up @@ -116,7 +104,7 @@ async function initCode() {
// mark this phase as loaded
setStatus('loaded');

if (!topLevelUrl.searchParams.has('wait-for-init-args')) {
if (!topLevelUrl?.searchParams.has('wait-for-init-args')) {
await init(processedConfig);
setStatus('initialized');
return;
Expand All @@ -128,11 +116,14 @@ async function initCode() {
async (evt) => {
// @ts-expect-error https://app.asana.com/0/1201614831475344/1203979574128023/f
const merged = mergeDeep(processedConfig, evt.detail);
// @ts-expect-error https://app.asana.com/0/1201614831475344/1203979574128023/f
window.__testContentScopeArgs = merged;
// init features
await init(merged);

// set status to initialized so that tests can resume
setStatus('initialized');
document.dispatchEvent(new CustomEvent('content-scope-init-completed'));
},
{ once: true },
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,22 @@
"type": "number",
"value": 222
}
},
"testApi1": {
"type": "descriptor",
"getterValue": {
"type": "number",
"value": 100
},
"define": true
},
"testApi2": {
"type": "descriptor",
"getterValue": {
"type": "number",
"value": 200
},
"define": true
}
},
"conditionalChanges": [
Expand All @@ -27,11 +43,39 @@
"value": 333
}
]
},
{
"condition": {
"context": {
"top": true
}
},
"patchSettings": [
{
"op": "replace",
"path": "/apiChanges/testApi1/getterValue/value",
"value": 43339
}
]
},
{
"condition": {
"context": {
"frame": true
}
},
"patchSettings": [
{
"op": "replace",
"path": "/apiChanges/testApi1/getterValue/value",
"value": 43338
}
]
}
]
}
}
},
"unprotectedTemporary": []
}
}

Loading
Loading