Skip to content

Websockets do not prevent bfcache #39872

@jdm

Description

@jdm

We implement a subset of checks from https://html.spec.whatwg.org/#unloading-document-cleanup-steps right now, which influence whether a document is considered salvageable or not:

  • let event_sources_canceled = self.window.as_global_scope().close_event_sources();
    if loads_cancelled || event_sources_canceled {
    // If any loads were canceled.
    self.salvageable.set(false);
    };
  • // https://html.spec.whatwg.org/multipage/#unloading-document-cleanup-steps
    if !self.salvageable.get() {
    // Step 1 of clean-up steps.
    global_scope.close_event_sources();
    let msg = ScriptToConstellationMessage::DiscardDocument;
    let _ = global_scope.script_to_constellation_chan().send(msg);

Unsalvageable documents do not get put in the bfcache. There are a bunch of WPT tests that rely on the websocket checks to force a document to be kept out of the bfcache, and we don't implement that right now.

We should use a similar model as the EventSource code in globalscope.rs for tracking all WebSocket objects so we can implement the checks correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions