Skip to content

Commit

Permalink
Add connectEnd attribute to PerformanceResourceTiming interface
Browse files Browse the repository at this point in the history
  • Loading branch information
pylbrecht committed Apr 4, 2019
1 parent 9be40ac commit f478357
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 16 deletions.
8 changes: 7 additions & 1 deletion components/net/http_loader.rs
Expand Up @@ -349,6 +349,7 @@ fn obtain_response(
iters: u32,
request_id: Option<&str>,
is_xhr: bool,
context: &FetchContext,
) -> Box<
dyn Future<
Item = (HyperResponse<Decoder>, Option<ChromeToDevtoolsControlMsg>),
Expand Down Expand Up @@ -400,8 +401,12 @@ fn obtain_response(
};
*request.headers_mut() = headers.clone();

//TODO(#21262) connect_end
let connect_end = precise_time_ms();
context
.timing
.lock()
.unwrap()
.set_attribute(ResourceAttribute::ConnectEnd(connect_end));

let request_id = request_id.map(|v| v.to_owned());
let pipeline_id = pipeline_id.clone();
Expand Down Expand Up @@ -1190,6 +1195,7 @@ fn http_network_fetch(
request.redirect_count + 1,
request_id.as_ref().map(Deref::deref),
is_xhr,
context,
);

let pipeline_id = request.pipeline_id;
Expand Down
5 changes: 4 additions & 1 deletion components/net_traits/lib.rs
Expand Up @@ -452,7 +452,7 @@ pub struct ResourceFetchTiming {
pub redirect_start: u64,
// pub redirect_end: u64,
// pub connect_start: u64,
// pub connect_end: u64,
pub connect_end: u64,
}

pub enum RedirectStartValue {
Expand All @@ -467,6 +467,7 @@ pub enum ResourceAttribute {
ResponseStart,
RedirectStart(RedirectStartValue),
FetchStart,
ConnectEnd(u64),
}

#[derive(Clone, Copy, Debug, Deserialize, MallocSizeOf, PartialEq, Serialize)]
Expand All @@ -486,6 +487,7 @@ impl ResourceFetchTiming {
response_start: 0,
fetch_start: 0,
redirect_start: 0,
connect_end: 0,
}
}

Expand All @@ -505,6 +507,7 @@ impl ResourceFetchTiming {
},
},
ResourceAttribute::FetchStart => self.fetch_start = precise_time_ns(),
ResourceAttribute::ConnectEnd(val) => self.connect_end = val,
}
}
}
Expand Down
7 changes: 6 additions & 1 deletion components/script/dom/performanceresourcetiming.rs
Expand Up @@ -122,7 +122,7 @@ impl PerformanceResourceTiming {
domain_lookup_start: 0.,
domain_lookup_end: 0.,
connect_start: 0.,
connect_end: 0.,
connect_end: resource_timing.connect_end as f64,
secure_connection_start: 0.,
request_start: resource_timing.request_start as f64,
response_start: resource_timing.response_start as f64,
Expand Down Expand Up @@ -194,4 +194,9 @@ impl PerformanceResourceTimingMethods for PerformanceResourceTiming {
fn FetchStart(&self) -> DOMHighResTimeStamp {
Finite::wrap(self.fetch_start)
}

// https://w3c.github.io/resource-timing/#dom-performanceresourcetiming-connectend
fn ConnectEnd(&self) -> DOMHighResTimeStamp {
Finite::wrap(self.connect_end)
}
}
Expand Up @@ -18,7 +18,7 @@ interface PerformanceResourceTiming : PerformanceEntry {
// readonly attribute DOMHighResTimeStamp domainLookupStart;
// readonly attribute DOMHighResTimeStamp domainLookupEnd;
// readonly attribute DOMHighResTimeStamp connectStart;
// readonly attribute DOMHighResTimeStamp connectEnd;
readonly attribute DOMHighResTimeStamp connectEnd;
// readonly attribute DOMHighResTimeStamp secureConnectionStart;
readonly attribute DOMHighResTimeStamp requestStart;
readonly attribute DOMHighResTimeStamp responseStart;
Expand Down
9 changes: 0 additions & 9 deletions tests/wpt/metadata/resource-timing/idlharness.any.js.ini
Expand Up @@ -62,9 +62,6 @@
[PerformanceResourceTiming interface: resource must inherit property "responseEnd" with the proper type]
expected: FAIL

[PerformanceResourceTiming interface: attribute connectEnd]
expected: FAIL

[PerformanceResourceTiming interface: resource must inherit property "redirectEnd" with the proper type]
expected: FAIL

Expand All @@ -77,9 +74,6 @@
[PerformanceResourceTiming interface: attribute domainLookupEnd]
expected: FAIL

[PerformanceResourceTiming interface: resource must inherit property "connectEnd" with the proper type]
expected: FAIL

[PerformanceResourceTiming interface: default toJSON operation on resource]
expected: FAIL

Expand Down Expand Up @@ -175,9 +169,6 @@
[PerformanceResourceTiming interface: attribute connectStart]
expected: FAIL

[PerformanceResourceTiming interface: attribute connectEnd]
expected: FAIL

[PerformanceResourceTiming interface: attribute redirectEnd]
expected: FAIL

Expand Down
3 changes: 0 additions & 3 deletions tests/wpt/metadata/resource-timing/resource_TAO_zero.htm.ini
Expand Up @@ -8,9 +8,6 @@
[secureConnectionStart should be 0 in cross-origin request.]
expected: FAIL

[connectEnd should be 0 in cross-origin request.]
expected: FAIL

[domainLookupStart should be 0 in cross-origin request.]
expected: FAIL

Expand Down

0 comments on commit f478357

Please sign in to comment.