mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
storage: Isolate sessionStorage per top-level browsing context and copy sessionStorage when creating a new auxiliary browsing context (#37803)
This pull request introduces changes to the storage subsystem to: - Isolate sessionStorage per top-level browsing context (WebViewId), in addition to origin. - Copy sessionStorage when creating a new auxiliary browsing context without noopener, as required by the corresponding spec These changes bring Servo closer to spec compliance, matching expected browser behavior. Testing: This work affects observable behavior. As a result, some previously failing WPT tests now pass. No new tests are added, since the behavior is already covered by existing web-platform-tests. Fixes: #21291 --------- Signed-off-by: Jan Varga <jan.varga@gmail.com>
This commit is contained in:
parent
aaf04883dd
commit
934b3341d7
6 changed files with 234 additions and 122 deletions
|
@ -32,7 +32,9 @@ use js::jsval::{NullValue, PrivateValue, UndefinedValue};
|
|||
use js::rust::wrappers::{JS_TransplantObject, NewWindowProxy, SetWindowProxy};
|
||||
use js::rust::{Handle, MutableHandle, MutableHandleValue, get_object_class};
|
||||
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
|
||||
use net_traits::IpcSend;
|
||||
use net_traits::request::Referrer;
|
||||
use net_traits::storage_thread::StorageThreadMsg;
|
||||
use script_traits::NewLayoutInfo;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use servo_url::{ImmutableOrigin, ServoUrl};
|
||||
|
@ -334,8 +336,6 @@ impl WindowProxy {
|
|||
theme: window.theme(),
|
||||
};
|
||||
ScriptThread::process_attach_layout(new_layout_info, document.origin().clone());
|
||||
// TODO: if noopener is false, copy the sessionStorage storage area of the creator origin.
|
||||
// See step 14 of https://html.spec.whatwg.org/multipage/#creating-a-new-browsing-context
|
||||
let new_window_proxy = ScriptThread::find_document(response.new_pipeline_id)
|
||||
.and_then(|doc| doc.browsing_context())?;
|
||||
if name.to_lowercase() != "_blank" {
|
||||
|
@ -343,6 +343,26 @@ impl WindowProxy {
|
|||
}
|
||||
if noopener {
|
||||
new_window_proxy.disown();
|
||||
} else {
|
||||
// After creating a new auxiliary browsing context and document,
|
||||
// the session storage is copied over.
|
||||
// See https://html.spec.whatwg.org/multipage/#the-sessionstorage-attribute
|
||||
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
|
||||
let msg = StorageThreadMsg::Clone {
|
||||
sender,
|
||||
src: window.window_proxy().webview_id(),
|
||||
dest: response.new_webview_id,
|
||||
};
|
||||
|
||||
document
|
||||
.global()
|
||||
.resource_threads()
|
||||
.sender()
|
||||
.send(msg)
|
||||
.unwrap();
|
||||
receiver.recv().unwrap();
|
||||
}
|
||||
Some(new_window_proxy)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue