Skip to content

Commit

Permalink
Auto merge of #23310 - KaczuH:add-domain-lookup-start, r=jdm
Browse files Browse the repository at this point in the history
Add domain_lookup_start functionality

<!-- Please describe your changes on the following line: -->
Added the domain_lookup_start functionality in http_loader.rs (http_redirect_fetch function)

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #21259 (GitHub issue number if applicable)

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because ___

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23310)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed Jun 30, 2019
2 parents 23c49bb + 98be2df commit 489ff5e
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 18 deletions.
6 changes: 6 additions & 0 deletions components/net/http_loader.rs
Expand Up @@ -378,6 +378,12 @@ fn obtain_response(
},
}

context
.timing
.lock()
.unwrap()
.set_attribute(ResourceAttribute::DomainLookupStart);

// TODO(#21261) connect_start: set if a persistent connection is *not* used and the last non-redirected
// fetch passes the timing allow check
let connect_start = precise_time_ms();
Expand Down
4 changes: 4 additions & 0 deletions components/net_traits/lib.rs
Expand Up @@ -441,6 +441,7 @@ pub struct ResourceCorsData {

#[derive(Clone, Debug, Deserialize, MallocSizeOf, Serialize)]
pub struct ResourceFetchTiming {
pub domain_lookup_start: u64,
pub timing_type: ResourceTimingType,
/// Number of redirects until final resource (currently limited to 20)
pub redirect_count: u16,
Expand All @@ -462,6 +463,7 @@ pub enum RedirectStartValue {

pub enum ResourceAttribute {
RedirectCount(u16),
DomainLookupStart,
RequestStart,
ResponseStart,
RedirectStart(RedirectStartValue),
Expand All @@ -483,6 +485,7 @@ impl ResourceFetchTiming {
pub fn new(timing_type: ResourceTimingType) -> ResourceFetchTiming {
ResourceFetchTiming {
timing_type: timing_type,
domain_lookup_start: 0,
redirect_count: 0,
request_start: 0,
response_start: 0,
Expand All @@ -498,6 +501,7 @@ impl ResourceFetchTiming {
// time origin (as described in Performance::now)
pub fn set_attribute(&mut self, attribute: ResourceAttribute) {
match attribute {
ResourceAttribute::DomainLookupStart => self.domain_lookup_start = precise_time_ns(),
ResourceAttribute::RedirectCount(count) => self.redirect_count = count,
ResourceAttribute::RequestStart => self.request_start = precise_time_ns(),
ResourceAttribute::ResponseStart => self.response_start = precise_time_ns(),
Expand Down
9 changes: 7 additions & 2 deletions components/script/dom/performanceresourcetiming.rs
Expand Up @@ -86,8 +86,8 @@ impl PerformanceResourceTiming {
redirect_start: 0.,
redirect_end: 0.,
fetch_start: fetch_start,
domain_lookup_start: 0.,
domain_lookup_end: 0.,
domain_lookup_start: 0.,
connect_start: 0.,
connect_end: 0.,
secure_connection_start: 0.,
Expand Down Expand Up @@ -118,7 +118,7 @@ impl PerformanceResourceTiming {
redirect_start: resource_timing.redirect_start as f64,
redirect_end: 0.,
fetch_start: resource_timing.fetch_start as f64,
domain_lookup_start: 0.,
domain_lookup_start: resource_timing.domain_lookup_start as f64,
domain_lookup_end: 0.,
connect_start: resource_timing.connect_start as f64,
connect_end: resource_timing.connect_end as f64,
Expand Down Expand Up @@ -172,6 +172,11 @@ impl PerformanceResourceTimingMethods for PerformanceResourceTiming {
}
}

// https://w3c.github.io/resource-timing/#dom-performanceresourcetiming-domainlookupstart
fn DomainLookupStart(&self) -> DOMHighResTimeStamp {
Finite::wrap(self.domain_lookup_start)
}

// https://w3c.github.io/resource-timing/#dom-performanceresourcetiming-requeststart
fn RequestStart(&self) -> DOMHighResTimeStamp {
Finite::wrap(self.request_start)
Expand Down
Expand Up @@ -15,7 +15,7 @@ interface PerformanceResourceTiming : PerformanceEntry {
readonly attribute DOMHighResTimeStamp redirectStart;
// readonly attribute DOMHighResTimeStamp redirectEnd;
readonly attribute DOMHighResTimeStamp fetchStart;
// readonly attribute DOMHighResTimeStamp domainLookupStart;
readonly attribute DOMHighResTimeStamp domainLookupStart;
// readonly attribute DOMHighResTimeStamp domainLookupEnd;
readonly attribute DOMHighResTimeStamp connectStart;
readonly attribute DOMHighResTimeStamp connectEnd;
Expand Down
12 changes: 0 additions & 12 deletions tests/wpt/metadata/resource-timing/idlharness.any.js.ini
Expand Up @@ -41,15 +41,9 @@
[PerformanceResourceTiming interface: resource must inherit property "secureConnectionStart" with the proper type]
expected: FAIL

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

[PerformanceResourceTiming interface: attribute workerStart]
expected: FAIL

[PerformanceResourceTiming interface: attribute domainLookupStart]
expected: FAIL

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

Expand Down Expand Up @@ -82,9 +76,6 @@
[PerformanceResourceTiming interface: resource must inherit property "transferSize" with the proper type]
expected: FAIL

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

[PerformanceResourceTiming interface: attribute decodedBodySize]
expected: FAIL

Expand Down Expand Up @@ -115,9 +106,6 @@
[PerformanceResourceTiming interface: attribute workerStart]
expected: FAIL

[PerformanceResourceTiming interface: attribute domainLookupStart]
expected: FAIL

[PerformanceResourceTiming interface: attribute redirectEnd]
expected: FAIL

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

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

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

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

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

0 comments on commit 489ff5e

Please sign in to comment.