Skip to content

Replace all script uses of UrlWithBlobClaim::from_url_without_having_claimed_blob with ensure_blob_referenced_by_url_is_kept_alive #48890

Open

Description

@jdm

UrlWithBlobClaim is a type that ensures that the following JavaScript pattern works:

const blob = /* some blob object created from some bytes */;
const url = URL.createObjectURL(blob);
img.src = url;
URL.revokeObjectURL(url);

Usually revoking a blob URL makes it impossible to reference, but any existing URLs referencing are intended to continue working. This pattern applies to any JS API that interacts with URLs, so we need to fix up the remaining uses (and hopefully add tests if they don't trigger any behaviour changes in existing tests).

To work on this, please leave a comment claiming one of the unclaimed files, then make the fix in that file, then run the full WPT testsuite in your github fork. If there are no changes to test results, leave a comment here and we can discuss how to write a new test for the feature.

Fixing these will help us make progress on #25226. We won't assign this issue to a particular person since it can be worked on in parallel.

  • components/script/dom/window/layout_image.rs
  • components/script/navigation.rs (@Anshumancanrock)
  • components/script/dom/servoparser/prefetch.rs
  • components/script/dom/workers/workerglobalscope.rs (@sageliem)
  • components/script/dom/document/websocket.rs (@lukasbauza)
  • components/script/dom/navigator/navigator.rs
  • components/script/dom/serviceworker/serviceworkerglobalscope.rs

Activity

  1. added
    E-less-complex
    A-content/script
    B-meta
    on Oct 13, 2026
  2. servo-highfive commented on Oct 13, 2026

    @servo-highfive

    Hi! If you have any questions regarding this issue, feel free to make a comment here, or ask it in Zulip.

    Please read and follow our AI Usage Policy:

    • You can use AI to help understand the code, make plans, and do code review.
    • You cannot post AI-generated code, comments, or PR descriptions.
  3. v-ju commented on Oct 14, 2026

    @v-ju

    @jdm could i work on this ?

  4. jdm commented on Oct 14, 2026

    @jdm
    MemberAuthor

    @v-ju Yes! Please comment with which file you will work on so we don't duplicate effort.

  5. Anshumancanrock commented on Oct 15, 2026

    @Anshumancanrock

    hi @jdm , I would like to work on components/script/navigation.rs. Could you please assign this to me?

  6. jdm commented on Oct 15, 2026

    @jdm
    MemberAuthor

    We won't assign this issue to a particular person since it can be worked on in parallel.

  7. slimfatima commented on Oct 23, 2026

    @slimfatima

    Good afternoon if they can assign this project to me or any available one

  8. jdm commented on Oct 23, 2026

    @jdm
    MemberAuthor

    The original description has instructions for claiming one of the available files to work on.

  9. slimfatima commented on Oct 23, 2026

    @slimfatima

    yes i have done that already

  10. lukasbauza commented on Oct 25, 2026

    @lukasbauza

    I would like to work on components/script/dom/document/websocket.rs. Can I have this task assigned to me, please?

  11. lukasbauza commented on Oct 25, 2026

    @lukasbauza

    Also, what would be the best approach for naming the branch. Looking at the documentation it seems as though "issue-48890" is the approach that is recommended, as seen here.

    But since there are multiple people that are working on this, would "issue-48890-websockets" suffice, where "websockets" is the file name?

  12. jdm commented on Oct 25, 2026

    @jdm
    MemberAuthor

    Branch names don't matter, since they only exist on your fork! You can use whatever system makes sense for you.

  13. 10 remaining items

  14. jdm commented on Nov 14, 2026

    @jdm
    MemberAuthor

    Ah, that makes sense since we can't use a blob URL with websockets. Let's use UrlWithBlobClaim::for_url instead and call expect("blob URLs were already prevented").

  15. FinalStaticFox commented on Nov 26, 2026

    @FinalStaticFox

    Hello, I would like to work on components/script/dom/servoparser/prefetch.rs

  16. FinalStaticFox commented on Nov 27, 2026

    @FinalStaticFox

    I don't see an obvious way of getting the GlobalScope. There is one inside the Tokenizer constructor, but it's not accessible from the process_token method. Should I add a new field to the PrefetchSink struct, or is there a better way?

  17. jdm commented on Nov 27, 2026

    @jdm
    MemberAuthor

    Yes, adding a new Dom<GlobalScope> field to PrefetchSink looks like the right choice.

  18. FinalStaticFox commented on Nov 27, 2026

    @FinalStaticFox

    Alright, so I ran ./mach try wpt and it seems like it passed: https://github.com/FinalStaticFox/servo/actions/runs/46043258659.
    I assume new tests need to be written then?

  19. jdm commented on Nov 27, 2026

    @jdm
    MemberAuthor

    The only test I can imagine is one that creates an object URL, creates a string that contains an external script that uses the object URL as the src, and pass that as the srcdoc of an iframe. Figuring out when to revoke the object URL.is the tricky part...

    Actually, we can't realistically revoke it before the script element has a chance to load it, either. I don't know if prefetching like this is even observable in a test if we can't revoke it immediately.

    Given that, unless you have any other ideas, I don't think we can write a meaningful test for this.

  20. FinalStaticFox commented on Nov 28, 2026

    @FinalStaticFox

    Well, from what I understand, prefetching could be also triggered with a <link rel="prefetch">, and I just found out there's a whole speculation rules API (although I don't even know if it's currently implemented in servo), but I have no clue if it would make this any easier to test...

    I'll just make a PR with what I have for now.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-content/scriptA-networkB-metaE-less-complex

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions