aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/request.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom/request.rs')
-rw-r--r--components/script/dom/request.rs28
1 files changed, 20 insertions, 8 deletions
diff --git a/components/script/dom/request.rs b/components/script/dom/request.rs
index 48499901c5d..5736311e942 100644
--- a/components/script/dom/request.rs
+++ b/components/script/dom/request.rs
@@ -38,7 +38,7 @@ use crate::dom::globalscope::GlobalScope;
use crate::dom::headers::{Guard, Headers};
use crate::dom::promise::Promise;
use crate::dom::readablestream::ReadableStream;
-use crate::script_runtime::JSContext as SafeJSContext;
+use crate::script_runtime::{CanGc, JSContext as SafeJSContext};
#[dom_struct]
pub struct Request {
@@ -59,8 +59,18 @@ impl Request {
}
}
- fn new(global: &GlobalScope, proto: Option<HandleObject>, url: ServoUrl) -> DomRoot<Request> {
- reflect_dom_object_with_proto(Box::new(Request::new_inherited(global, url)), global, proto)
+ fn new(
+ global: &GlobalScope,
+ proto: Option<HandleObject>,
+ url: ServoUrl,
+ can_gc: CanGc,
+ ) -> DomRoot<Request> {
+ reflect_dom_object_with_proto(
+ Box::new(Request::new_inherited(global, url)),
+ global,
+ proto,
+ can_gc,
+ )
}
// https://fetch.spec.whatwg.org/#dom-request
@@ -68,6 +78,7 @@ impl Request {
pub fn Constructor(
global: &GlobalScope,
proto: Option<HandleObject>,
+ can_gc: CanGc,
mut input: RequestInfo,
init: RootedTraceableBox<RequestInit>,
) -> Fallible<DomRoot<Request>> {
@@ -283,7 +294,7 @@ impl Request {
// Step 27 TODO: "If init["priority"] exists..."
// Step 28
- let r = Request::from_net_request(global, proto, request);
+ let r = Request::from_net_request(global, proto, request, can_gc);
// Step 29 TODO: "Set this's signal to new AbortSignal object..."
// Step 30 TODO: "If signal is not null..."
@@ -436,17 +447,18 @@ impl Request {
global: &GlobalScope,
proto: Option<HandleObject>,
net_request: NetTraitsRequest,
+ can_gc: CanGc,
) -> DomRoot<Request> {
- let r = Request::new(global, proto, net_request.current_url());
+ let r = Request::new(global, proto, net_request.current_url(), can_gc);
*r.request.borrow_mut() = net_request;
r
}
- fn clone_from(r: &Request) -> Fallible<DomRoot<Request>> {
+ fn clone_from(r: &Request, can_gc: CanGc) -> Fallible<DomRoot<Request>> {
let req = r.request.borrow();
let url = req.url();
let headers_guard = r.Headers().get_guard();
- let r_clone = Request::new(&r.global(), None, url);
+ let r_clone = Request::new(&r.global(), None, url, can_gc);
r_clone.request.borrow_mut().pipeline_id = req.pipeline_id;
{
let mut borrowed_r_request = r_clone.request.borrow_mut();
@@ -614,7 +626,7 @@ impl RequestMethods for Request {
}
// Step 2
- Request::clone_from(self)
+ Request::clone_from(self, CanGc::note())
}
// https://fetch.spec.whatwg.org/#dom-body-text