Skip to content

Fix SharedWorker partitioned reuse - #45741

Merged
Taym95 merged 2 commits into
servo:mainfrom
Taym95:sharedworker-partition-storage-key
Jun 18, 2026
Merged

Taym95 merged 2 commits into
servo:mainfrom
Taym95:sharedworker-partition-storage-key

Conversation

@Taym95

@Taym95 Taym95 commented Jun 16, 2026 •

Copy link
Copy Markdown
Member

SharedWorkers from different top-level sites should not share the same worker,
even when they use the same URL and name.

Testing: shared-worker-partitioned.tentative.html pass..

part of #7458

@Taym95
Taym95 requested a review from gterzian as a code owner June 16, 2026 21:56
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Jun 16, 2026

@gterzian gterzian left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think the change itself is wrong, because shared workers should be shared per origin; regarding the passing test, I don't understand what is actually making it pass.

The test in question seems to pass a worker as the url, and expects a range error, so I'm guessing to make it pass we need to add some validation of the url that fails in such as case. This might be something to do at the bindings layer actually.

}

impl SharedWorkerSite {
/// <https://html.spec.whatwg.org/multipage/#obtain-a-site>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

do we not have something like that already? If not, I think it belongs somewhere as a function for other parts of script to use as well.


impl SharedWorkerStorageKey {
/// <https://storage.spec.whatwg.org/#storage-key>
fn for_window(global: &GlobalScope, window: &Window) -> Self {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

see #44034

prefs: [dom_sharedworker_enabled: true]

[SharedWorker-constructor.html]
[Test recursive worker creation results in exception.]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

So the tests wants an exception thrown, and I don't understand what in the current changes makes it pass.

// A `SharedWorkerGlobalScope` object has associated constructor origin (an origin), constructor URL (a URL record), and credentials (a credentials mode), and extended lifetime (a boolean).
#[no_trace]
storage_key: ImmutableOrigin,
storage_key: SharedWorkerStorageKey,

@gterzian gterzian Jun 17, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@Taym95

Taym95 commented Jun 17, 2026

Copy link
Copy Markdown
Member Author

I think the change itself is wrong, because shared workers should be shared per origin; regarding the passing test, I don't understand what is actually making it pass.

The test in question seems to pass a worker as the url, and expects a range error, so I'm guessing to make it pass we need to add some validation of the url that fails in such as case. This might be something to do at the bindings layer actually.

@gterzian The change is correct, I just committed the wrong test metadata. It should be shared-worker-partitioned.tentative.html, not SharedWorker-constructor.html. I’m working on all remaining failing SharedWorker tests locally and committed the wrong one by mistake.
The test in question is this:
shared-worker-partitioned.tentative.html

The test checks that SharedWorkers are separated by top-level site.
It creates one SharedWorker, then opens another top-level site that creates a SharedWorker with the same URL/name. The expected counter is 1 again, meaning a new worker was created.
It was failing because Servo reused SharedWorkers using an origin-only key. The fix adds the top-level site to the SharedWorker key, so workers from different top-level sites no longer share the same instance.

@gterzian gterzian left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ok thanks for clarifying; since every browser is passing it we should do the same (even thought the spec hasn't been updated and still only partitions by origin).

https://wpt.fyi/results/workers/shared-worker-partitioned.tentative.html?label=experimental&label=master&aligned

@servo-highfive servo-highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Jun 17, 2026
@Taym95
Taym95 enabled auto-merge June 17, 2026 12:46
@Taym95
Taym95 added this pull request to the merge queue Jun 17, 2026
@servo-highfive servo-highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Jun 17, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 17, 2026
@servo-highfive servo-highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Jun 17, 2026
@Taym95
Taym95 added this pull request to the merge queue Jun 17, 2026
@servo-highfive servo-highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-tests-failed The changes caused existing tests to fail. labels Jun 17, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 18, 2026
@servo-highfive servo-highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Jun 18, 2026

@yezhizhen yezhizhen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

https://github.com/servo/servo/runs/82043218799

Seems shared-worker-partitioned.tentative.html still fail, or is it intermittent now?

@Taym95

Taym95 commented Jun 18, 2026

Copy link
Copy Markdown
Member Author

https://github.com/servo/servo/runs/82043218799

Seems shared-worker-partitioned.tentative.html still fail, or is it intermittent now?

SharedWorker is not defined, means SharedWorker is not enabled.

Signed-off-by: Taym Haddadi <[email protected]>
@Taym95
Taym95 force-pushed the sharedworker-partition-storage-key branch from 1a5a4a3 to a238070 Compare June 18, 2026 08:40
@servo-highfive servo-highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-tests-failed The changes caused existing tests to fail. labels Jun 18, 2026
@Taym95
Taym95 enabled auto-merge June 18, 2026 08:40
@Taym95
Taym95 added this pull request to the merge queue Jun 18, 2026
@servo-highfive servo-highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Jun 18, 2026
Merged via the queue into servo:main with commit 316430b Jun 18, 2026
34 checks passed
@Taym95
Taym95 deleted the sharedworker-partition-storage-key branch June 18, 2026 09:50
@servo-highfive servo-highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Jun 18, 2026
@mrobinson mrobinson added the T-linux-wpt Do a try run of the WPT label Jun 18, 2026
@github-actions github-actions Bot removed the T-linux-wpt Do a try run of the WPT label Jun 18, 2026
@github-actions

Copy link
Copy Markdown

🔨 Triggering try run (#27751831813) for Linux (WPT)

@github-actions

Copy link
Copy Markdown

Test results for linux-wpt from try job (#27751831813):

Flaky unexpected result (21)
  • TIMEOUT /FileAPI/url/url-in-tags-revoke.window.html (#19978)
    • PASS [expected TIMEOUT] subtest: Fetching a blob URL immediately before revoking it works in &lt;script&gt; tags.
  • OK [expected TIMEOUT] /content-security-policy/inheritance/auxiliary-blank-document.html (#44821)
    • PASS [expected TIMEOUT] subtest: window.open() inherits CSPs on transient about:blank.
  • CRASH [expected OK] /content-security-policy/meta/sandbox-iframe.html (#43478)
  • FAIL [expected PASS] /css/css-backgrounds/background-size-042.html
  • PASS [expected FAIL] /css/css-fonts/font-feature-settings-descriptor-01.html (#45418)
  • OK /css/css-fonts/variations/font-weight-matching.html (#38577)
    • FAIL [expected PASS] subtest: Test @font-face matching for weight 470

      assert_approx_equals: @font-face should be mapped to CSSTest Weights 300. expected 90 +/- 2 but got 180
      

  • FAIL [expected PASS] /css/css-sizing/dynamic-available-size-iframe.html (#45763)
  • FAIL [expected PASS] /css/css-text-decor/text-underline-position-from-font-variable.html (#45615)
  • OK /fetch/content-length/api-and-duplicate-headers.any.html (#35873)
    • FAIL [expected PASS] subtest: fetch() and duplicate Content-Length/Content-Type headers

      promise_test: Unhandled rejection with value: object "TypeError: Network error: HTTP failure: client error (SendRequest)"
      

  • OK /html/browsers/history/the-history-interface/traverse_the_history_3.html (#21383)
    • PASS [expected FAIL] subtest: Multiple history traversals, last would be aborted
  • CRASH [expected OK] /html/browsers/origin/api/origin-from-global.any.worker.html
  • TIMEOUT /html/semantics/embedded-content/media-elements/preserves-pitch.html (#40352)
    • PASS [expected TIMEOUT] subtest: Speed-ups should not change the pitch when preservesPitch=true
    • TIMEOUT [expected NOTRUN] subtest: Slow-downs should not change the pitch when preservesPitch=true

      Test timed out
      

  • OK /html/semantics/embedded-content/the-iframe-element/iframe-loading-lazy-nav-location-replace-set-src.html (#32697)
    • PASS [expected FAIL] subtest: Navigating iframe loading='lazy' and then setting src: location.replace
  • OK /html/semantics/forms/form-submission-0/jsurl-form-submit.tentative.html (#36489)
    • PASS [expected FAIL] subtest: Verifies that form submissions scheduled inside javascript: urls take precedence over the javascript: url's return value.
  • OK /html/semantics/scripting-1/the-script-element/module/dynamic-import/blob-url.any.html (#33948)
    • FAIL [expected PASS] subtest: Revoking a blob URL immediately after calling import will not fail

      promise_test: Unhandled rejection with value: object "TypeError: Module fetching failed"
      

  • OK /html/webappapis/user-prompts/print-during-unload.html (#35944)
    • FAIL [expected PASS] subtest: print() during unload

      assert_array_equals: expected property 1 to be "destination" but got "error: window.print is not a function" (expected array ["start", "destination"] got ["start", "error: window.print is not a function"])
      

  • TIMEOUT [expected OK] /pointerevents/compat/pointerevent_touch-action_two-finger_interaction.html (#44693)
    • NOTRUN [expected PASS] subtest: touch two-finger pan on 'touch-action: pan-x pan-y'
    • NOTRUN [expected FAIL] subtest: touch two-finger pan on 'touch-action: pinch-zoom'
  • OK /resource-timing/test_resource_timing.https.html (#25216)
    • PASS [expected FAIL] subtest: PerformanceEntry has correct name, initiatorType, startTime, and duration (iframe)
  • OK /sanitizer-api/sanitizer-inert-document.html (#45260)
    • PASS [expected FAIL] subtest: Test whether setHTML loads the image.
    • FAIL [expected PASS] subtest: Test whether setHTMLUnsafe loads the image.

      promise_test: Unhandled rejection with value: "The server observed a request. It shouldn't have."
      

  • TIMEOUT [expected OK] /trusted-types/trusted-types-navigation.html?16-20 (#44835)
    • FAIL [expected PASS] subtest: Navigate a frame via area with javascript:-urls in report-only mode.

      promise_test: Unhandled rejection with value: "Unexpected message received: \"No securitypolicyviolation reported!\""
      

    • TIMEOUT [expected PASS] subtest: Navigate a frame via area with javascript:-urls w/ default policy in report-only mode.

      Test timed out
      

  • OK /visual-viewport/resize-event-order.html (#41981)
    • PASS [expected FAIL] subtest: Popup: DOMWindow resize fired before VisualViewport.
Stable unexpected results that are known to be intermittent (15)
  • OK /_webgl/conformance/textures/misc/texture-upload-size.html (#21770)
    • FAIL [expected PASS] subtest: WebGL test #45

      assert_true: Texture was smaller than the expected size 2x2 expected true got false
      

    • FAIL [expected PASS] subtest: WebGL test #47

      assert_true: getError expected: INVALID_VALUE. Was NO_ERROR : when calling texSubImage2D with the same texture upload with offset 1, 1 expected true got false
      

    • FAIL [expected PASS] subtest: WebGL test #49

      assert_true: Texture was smaller than the expected size 2x2 expected true got false
      

    • FAIL [expected PASS] subtest: WebGL test #51

      assert_true: getError expected: INVALID_VALUE. Was NO_ERROR : when calling texSubImage2D with the same texture upload with offset 1, 1 expected true got false
      

    • PASS [expected FAIL] subtest: WebGL test #53
    • PASS [expected FAIL] subtest: WebGL test #55
    • PASS [expected FAIL] subtest: WebGL test #57
    • PASS [expected FAIL] subtest: WebGL test #59
    • FAIL [expected PASS] subtest: WebGL test #61

      assert_true: Texture was smaller than the expected size 2x2 expected true got false
      

    • FAIL [expected PASS] subtest: WebGL test #63

      assert_true: getError expected: INVALID_VALUE. Was NO_ERROR : when calling texSubImage2D with the same texture upload with offset 1, 1 expected true got false
      

    • And 18 more unexpected results...
  • ERROR [expected OK] /fetch/fetch-later/quota/same-origin-iframe/accumulated-oversized-payload.https.window.html (#41705)
  • OK /html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/load-pageshow-events-window-open.html (#28691)
    • FAIL [expected PASS] subtest: load event does not fire on window.open('about:blank')

      assert_unreached: load should not be fired Reached unreachable code
      

  • OK /html/browsers/browsing-the-web/navigating-across-documents/navigation-unload-same-origin.window.html (#29049)
    • PASS [expected FAIL] subtest: Same-origin navigation started from unload handler must be ignored
  • OK /html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/a-click.html (#28697)
    • PASS [expected FAIL] subtest: aElement.click() before the load event must NOT replace
  • OK [expected TIMEOUT] /html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/form-submit.html (#44028)
  • OK /html/browsers/history/the-history-interface/traverse_the_history_4.html (#21383)
    • PASS [expected FAIL] subtest: Multiple history traversals, last would be aborted
  • ERROR [expected CRASH] /html/browsers/history/the-location-interface/location_replace_session_history.html (#41896)
  • TIMEOUT [expected OK] /html/infrastructure/urls/base-url/document-base-url-window-initiator-is-not-opener.https.window.html (#30970)
  • TIMEOUT /html/interaction/focus/the-autofocus-attribute/supported-elements.html (#24145)
    • TIMEOUT [expected FAIL] subtest: Element with tabindex should support autofocus

      Test timed out
      

    • NOTRUN [expected PASS] subtest: Non-HTMLElement should not support autofocus
    • NOTRUN [expected FAIL] subtest: Host element with delegatesFocus should support autofocus
    • NOTRUN [expected FAIL] subtest: Host element with delegatesFocus including no focusable descendants should be skipped
  • OK /html/semantics/scripting-1/the-script-element/execution-timing/077.html (#22139)
    • PASS [expected FAIL] subtest: adding several types of scripts through the DOM and removing some of them confuses scheduler
  • OK /html/semantics/scripting-1/the-script-element/module/dynamic-import/blob-url.any.worker-module.html (#43510)
    • FAIL [expected PASS] subtest: Revoking a blob URL immediately after calling import will not fail

      promise_test: Unhandled rejection with value: object "TypeError: Module fetching failed"
      

  • OK /html/user-activation/navigation-state-reset-sameorigin.html (#45151)
    • FAIL [expected PASS] subtest: Post-navigation state reset.

      assert_true: child-two sticky user activation state after loaded expected true got false
      

  • OK /preload/prefetch-document.html (#37210)
    • PASS [expected FAIL] subtest: different-site document prefetch with 'as=document' should not be consumed
  • OK [expected CRASH] /resource-timing/render-blocking-status-link.html (#41664)
    • FAIL [expected PASS] subtest: Validate render blocking status of link resources in PerformanceResourceTiming

      assert_equals: render blocking status for http://web-platform.test:8000/resource-timing/resources/empty_style.css?stylesheet-head-dynamic-docWrite should be blocking expected (string) "blocking" but got (undefined) undefined
      

@github-actions

Copy link
Copy Markdown

✨ Try run (#27751831813) succeeded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-awaiting-review There is new code that needs to be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants