Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upChange XHRContext and resource timing information to use request URL #23372
Conversation
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
commented
May 13, 2019
|
Heads up! This PR modifies the following files:
|
highfive
commented
May 13, 2019
|
@bors-servo try=wpt |
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 -->
|
|
|
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 |
In the test the entries are taken from |
|
Er, yes. I was thinking of code like |
| return a.href; | ||
| } | ||
|
|
||
| onload = function () { |
This comment has been minimized.
This comment has been minimized.
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.
This comment has been minimized.
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.
This comment has been minimized.
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.
|
Thanks for writing the test! Sorry about the delay in reviewing it. |
|
@bors-servo try=wpt |
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 try- |
|
@bors-servo r+ |
|
|
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 retry
|
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 retry |
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 -->
|
|
sreeise commentedMay 13, 2019
•
edited by SimonSapin
Change resource timing information to return the URL used to create the XHR and store the URL in XHRContext.
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is