Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change XHRContext and resource timing information to use request URL #23372

Merged
merged 1 commit into from Jun 3, 2019

Conversation

@sreeise
Copy link
Contributor

sreeise commented May 13, 2019

Change resource timing information to return the URL used to create the XHR and store the URL in XHRContext.


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #23329 (GitHub issue number if applicable)
  • There are tests for these changes OR
  • These changes do not require tests because ___

This change is Reviewable

@highfive
Copy link

highfive commented May 13, 2019

Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @ferjm (or someone else) soon.

@highfive
Copy link

highfive commented May 13, 2019

Heads up! This PR modifies the following files:

  • @asajeffrey: components/script/dom/xmlhttprequest.rs
  • @KiChjang: components/script/dom/xmlhttprequest.rs
@highfive
Copy link

highfive commented May 13, 2019

warning Warning warning

  • These commits modify script code, but no tests are modified. Please consider adding a test!
@jdm
Copy link
Member

jdm commented May 13, 2019

@bors-servo try=wpt

bors-servo added a commit that referenced this pull request May 13, 2019
Change XHRContext and resource timing information to use request URL

<!-- Please describe your changes on the following line: -->
Change resource timing information to return the URL used to create the XHR and store the URL in XHRContext.

---
<!-- 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 #23329 (GitHub issue number if applicable)

<!-- Either: -->
- [X] 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/23372)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented May 13, 2019

Trying commit a61311a with merge 2292be6...

@bors-servo
Copy link
Contributor

bors-servo commented May 13, 2019

☀️ Test successful - linux-rel-css, linux-rel-wpt, status-taskcluster
State: approved= try=True

@jdm
Copy link
Member

jdm commented May 14, 2019

Looks like we should write a test for this. I suspect there are already some test cases that exercise this, but they're probably part of tests that fail in other ways so it's hard to notice if this is correct or not. We should add a new one to tests/wpt/mozilla/tests/mozilla that makes an XMLHttpRequest. When the XHR succeeds, we can call window.performance.getEntriesByType("xmlhttprequest") and verify that there is one entry that has the correct URL.

@jdm jdm added S-needs-tests and removed S-awaiting-review labels May 14, 2019
@jdm jdm assigned jdm and unassigned ferjm May 14, 2019
@sreeise sreeise force-pushed the sreeise:xhr_resource_url branch from a61311a to 845a5ee May 15, 2019
@sreeise
Copy link
Contributor Author

sreeise commented May 15, 2019

Looks like we should write a test for this. I suspect there are already some test cases that exercise this, but they're probably part of tests that fail in other ways so it's hard to notice if this is correct or not. We should add a new one to tests/wpt/mozilla/tests/mozilla that makes an XMLHttpRequest. When the XHR succeeds, we can call window.performance.getEntriesByType("xmlhttprequest") and verify that there is one entry that has the correct URL.

In the test the entries are taken from window.performance.getEntriesByType("resource"). I thought that there were only specific names that could be used for getEntriesByType without using performance.mark("name"). I say that just because you wrote getEntriesBy("xmlhttprequest") so I wasn't sure.

@jdm
Copy link
Member

jdm commented May 23, 2019

Er, yes. I was thinking of code like performance.getEntriesByType("resource").filter(entry => entry.initiatorType == "xmlhttprequest"); and got confused.

return a.href;
}

onload = function () {

This comment has been minimized.

Copy link
@jdm

jdm May 23, 2019

Member

No need to wait for onload here. We can write this test like this:

async_test(function(t) {
  let href = window.location.href;
  let request = new XMLHttpRequest();
  let url = resolve("./test.txt");
  request.open('GET', url, true);

  request.onload = t.step_func_done(function() {
    let entries = window.performance.getEntriesByType("resource");
    assert_equals(entries.length, 1);
    assert_equals(entries[0].name, href);
  });
}, "Performance entries should contain the URL where the XMLHttpRequest originated");

I'm a bit surprised that the test passes right now, since I would expect the test harness <script> elements to be included in the resulting performance entries :<

This comment has been minimized.

Copy link
@sreeise

sreeise May 24, 2019

Author Contributor

Hmm, I'm not sure why it doesn't show the performance entries for script elements. Calling getEntries() only shows the new xmlhttprequest as well. I am wondering whether it would be better to clear out the resource entries beforehand just in case: window.performance.clearResourceTimings();.
Or, maybe get the names of the entries first and then test for the new entry, Something like:

   let entries = window.performance.getEntriesByType("resource");
   let nameEntries = [];
   entries.forEach(entry => {
       nameEntries.push(entry.name);
   });
   assert_true(nameEntries.includes(href));

As far as the entries for the script elements, again I am not sure why but I can try to find out what may be the issue there.

This comment has been minimized.

Copy link
@jdm

jdm Jun 2, 2019

Member

I would rather have the test yell at us if we change the implementation in a way that makes it no longer report expected results. Let's merge it as-is.

@jdm
Copy link
Member

jdm commented May 23, 2019

Thanks for writing the test! Sorry about the delay in reviewing it.

…instead of XHR's global URL r?@jdm
@sreeise sreeise force-pushed the sreeise:xhr_resource_url branch from 845a5ee to e169278 May 24, 2019
@jdm
Copy link
Member

jdm commented May 24, 2019

@bors-servo try=wpt

bors-servo added a commit that referenced this pull request May 24, 2019
Change XHRContext and resource timing information to use request URL

<!-- Please describe your changes on the following line: -->
Change resource timing information to return the URL used to create the XHR and store the URL in XHRContext.

---
<!-- 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 #23329 (GitHub issue number if applicable)

<!-- Either: -->
- [X] 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/23372)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented May 24, 2019

Trying commit e169278 with merge f42db56...

@jdm
Copy link
Member

jdm commented May 24, 2019

@jdm jdm closed this May 24, 2019
@jdm jdm reopened this May 24, 2019
@jdm
Copy link
Member

jdm commented Jun 2, 2019

@bors-servo
Copy link
Contributor

bors-servo commented Jun 2, 2019

📌 Commit e169278 has been approved by jdm

bors-servo added a commit that referenced this pull request Jun 2, 2019
Change XHRContext and resource timing information to use request URL

<!-- Please describe your changes on the following line: -->
Change resource timing information to return the URL used to create the XHR and store the URL in XHRContext.

---
<!-- 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 #23329 (GitHub issue number if applicable)

<!-- Either: -->
- [X] 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/23372)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Jun 2, 2019

Testing commit e169278 with merge b59ee42...

@bors-servo
Copy link
Contributor

bors-servo commented Jun 2, 2019

💔 Test failed - status-taskcluster

@jdm
Copy link
Member

jdm commented Jun 2, 2019

@bors-servo retry

  • network failure
@bors-servo
Copy link
Contributor

bors-servo commented Jun 2, 2019

Testing commit e169278 with merge 707a319...

bors-servo added a commit that referenced this pull request Jun 2, 2019
Change XHRContext and resource timing information to use request URL

<!-- Please describe your changes on the following line: -->
Change resource timing information to return the URL used to create the XHR and store the URL in XHRContext.

---
<!-- 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 #23329 (GitHub issue number if applicable)

<!-- Either: -->
- [X] 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/23372)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Jun 2, 2019

💔 Test failed - status-taskcluster

@jdm
Copy link
Member

jdm commented Jun 3, 2019

@bors-servo
Copy link
Contributor

bors-servo commented Jun 3, 2019

Testing commit e169278 with merge 7f7eead...

bors-servo added a commit that referenced this pull request Jun 3, 2019
Change XHRContext and resource timing information to use request URL

<!-- Please describe your changes on the following line: -->
Change resource timing information to return the URL used to create the XHR and store the URL in XHRContext.

---
<!-- 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 #23329 (GitHub issue number if applicable)

<!-- Either: -->
- [X] 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/23372)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Jun 3, 2019

☀️ Test successful - arm64, linux-rel-css, linux-rel-wpt, status-taskcluster
Approved by: jdm
Pushing 7f7eead to master...

@bors-servo bors-servo merged commit e169278 into servo:master Jun 3, 2019
4 checks passed
4 checks passed
Taskcluster (pull_request) TaskGroup: success
Details
Travis CI - Pull Request Build Passed
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
homu Test successful
Details
@sreeise sreeise deleted the sreeise:xhr_resource_url branch Jun 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

5 participants
You can’t perform that action at this time.