Skip to content

Conversation

@jonathanKingston
Copy link
Contributor

@jonathanKingston jonathanKingston commented Oct 24, 2025

Asana Task/Github Issue: https://app.asana.com/1/137249556945/project/72649045549333/task/1211717809403184?focus=true

Description

Add support for conditionalChanges for preview builds.

Testing Steps

Checklist

Please tick all that apply:

  • I have tested this change locally
  • I have tested this change locally in all supported browsers
  • This change will be visible to users
  • I have added automated tests that cover this change
  • I have ensured the change is gated by config
  • This change was covered by a ship review
  • This change was covered by a tech design
  • Any dependent config has been merged

Note

Adds preview build condition to conditionalChanges, updates Platform typings/docs, and adds unit tests.

  • Config logic:
    • Add preview condition handling in injected/src/config-feature.js (_matchPreviewConditional) and include it in condition checks for conditionalChanges.
  • Types:
    • Extend Platform with preview flag in injected/src/utils.js.
  • Docs:
    • Document platform.preview in injected/docs/platform-integration.md.
  • Tests:
    • Add comprehensive unit tests for preview condition in injected/unit-test/content-feature.js.

Written by Cursor Bugbot for commit 3132755. This will update automatically on new commits. Configure here.

@netlify
Copy link

netlify bot commented Oct 24, 2025

Deploy Preview for content-scope-scripts ready!

Name Link
🔨 Latest commit 3132755
🔍 Latest deploy log https://app.netlify.com/projects/content-scope-scripts/deploys/68fbda9d0335b80008680109
😎 Deploy Preview https://deploy-preview-2032--content-scope-scripts.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions
Copy link

github-actions bot commented Oct 24, 2025

Temporary Branch Update

The temporary branch has been updated with the latest changes. Below are the details:

Please use the above install command to update to the latest version.

@github-actions
Copy link

github-actions bot commented Oct 24, 2025

[Beta] Generated file diff

Time updated: Tue, 28 Oct 2025 00:12:29 GMT

Android
    - android/adsjsContentScope.js
  • android/autofillImport.js
  • android/brokerProtection.js
  • android/contentScope.js

File has changed

Apple
    - apple/contentScope.js
  • apple/contentScopeIsolated.js

File has changed

Chrome-mv3
    - chrome-mv3/inject.js

File has changed

Firefox
    - firefox/inject.js

File has changed

Integration
    - integration/contentScope.js

File has changed

Windows
    - windows/contentScope.js

File has changed

@noisysocks noisysocks requested a review from Copilot October 27, 2025 05:17
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for conditionalChanges based on preview build status, allowing content features to conditionally apply changes depending on whether the code is running in a preview build.

Key changes:

  • Added a new preview conditional property to the config feature system
  • Implemented _matchPreviewConditional method to evaluate preview conditions
  • Added comprehensive test coverage for preview condition matching

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
injected/src/config-feature.js Implements the core preview conditional matching logic and registers it in the condition handlers map
injected/src/utils.js Adds JSDoc documentation for the new preview property in the Platform type definition
injected/docs/platform-integration.md Updates documentation to include the preview flag in platform configuration
injected/unit-test/content-feature.js Adds comprehensive test suite for preview conditional matching functionality

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@noisysocks
Copy link
Contributor

I tested this PR and https://github.com/duckduckgo/windows-browser/pull/5508 together by:

  1. Checking out pr-releases/pr-2032 in submodules/content-scope-scripts.

  2. Serving a config with ”preview”: true locally in windows-overrides.json:

        "pageContext": {
            "state": “enabled”,
            "exceptions": [],
            "settings": {
                "additionalCheck": “disabled”,
                "maxContentLength": 9500,
                "excludeSelectors": [
                    ".ad”,
                    ".sidebar”,
                    ".footer”,
                    ".nav”,
                    ".header”,
                    ".banner”,
                    .popup”
                ],
                "conditionalChanges": [
                    {
                        "condition": {
                            “preview": true
                        },
                        "patchSettings": [
                            {
                                "op": “replace”,
                                "path": "/additionalCheck”,
                                "value": “enabled”
                            }
                        ]
                    },
                    {
                        "condition": {
                            "domain": “reddit.com”
                        },
                        "patchSettings": [
                            {
                                "op": “add”,
                                "path": "/excludeSelectors/-“,
                                "value": "shreddit-comments-page-ad”
                            }
                        ]
                    }
                ]
            }
        },
  1. Overriding the value of IsOneOfPreviewChannelsOrDev to true:
public static bool IsOneOfPreviewChannelsOrDev(this IPackageInformationProvider packageInformationProvider)
{
    return true;
}

I then verified that:

  • ✅ With ”preview”: true in the config and IsOneOfPreviewChannelsOrDev = true in build, page context can be attached.
  • ✅ With ”preview”: true in the config and IsOneOfPreviewChannelsOrDev = false in build, page context can not be attached. (The UI appears but attaching does nothing. Expected.)
  • ✅ With no ”preview”: true in the config and IsOneOfPreviewChannelsOrDev = true in build, page context can not be attached. (The UI appears but attaching does nothing. Expected.)

@noisysocks noisysocks marked this pull request as ready for review October 28, 2025 00:11
@noisysocks noisysocks requested a review from a team as a code owner October 28, 2025 00:11
@noisysocks
Copy link
Contributor

noisysocks commented Oct 28, 2025

Oh right I’m not in @duckduckgo/content-scope-scripts-owners :)

@shakyShane – mind taking a look at this?

@noisysocks noisysocks added this pull request to the merge queue Oct 28, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 28, 2025
@noisysocks noisysocks added this pull request to the merge queue Oct 28, 2025
Merged via the queue into main with commit d926037 Oct 28, 2025
28 checks passed
@noisysocks noisysocks deleted the jkt/preview-support branch October 28, 2025 10:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants