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

Fix revoke blob url #24685

Merged
merged 1 commit into from Nov 19, 2019
Merged

Fix revoke blob url #24685

merged 1 commit into from Nov 19, 2019

Conversation

@shnmorimoto
Copy link
Contributor

shnmorimoto commented Nov 7, 2019

fix #24290


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

highfive commented Nov 7, 2019

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

@highfive
Copy link

highfive commented Nov 7, 2019

Heads up! This PR modifies the following files:

  • @asajeffrey: components/script/dom/url.rs
  • @KiChjang: components/net/filemanager_thread.rs, components/script/dom/url.rs, components/net_traits/filemanager_thread.rs
@highfive
Copy link

highfive commented Nov 7, 2019

warning Warning warning

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

jdm commented Nov 7, 2019

@bors-servo try=wpt

@bors-servo
Copy link
Contributor

bors-servo commented Nov 7, 2019

Trying commit 999818e with merge 970a12d...

bors-servo added a commit that referenced this pull request Nov 7, 2019
Fix revoke blob url

<!-- Please describe your changes on the following line: -->

fix #24290

---
<!-- 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 #24290 (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. -->
@bors-servo
Copy link
Contributor

bors-servo commented Nov 7, 2019

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

@jdm
Copy link
Member

jdm commented Nov 7, 2019

Hmm, the goal of #24290 was to get tests/wpt/web-platform-tests/FileAPI/url/url-with-xhr.any.js and tests/wpt/web-platform-tests/FileAPI/url/url-with-fetch.any.js passing, so it's curious that there is no change in test results.

FileManagerThreadMsg::RevokeBlobURL(id, origin, sender) => {
let _ = sender.send(self.store.set_blob_url_validity(false, &id, &origin));
FileManagerThreadMsg::RevokeBlobURL(url, sender) => {
if let Ok((id, origin)) = parse_blob_url(&url) {

This comment has been minimized.

Copy link
@jdm

jdm Nov 7, 2019

Member

Oh - we still are throwing away the fragment and query string from the URL, which is why the tests continue to fail. We need to explicitly deal with those.

This comment has been minimized.

Copy link
@shnmorimoto

shnmorimoto Nov 8, 2019

Author Contributor

Thanks for the review.
I will check and fix it!

@shnmorimoto
Copy link
Contributor Author

shnmorimoto commented Nov 10, 2019

@jdm

I have two quesrtions.

1. About parse_blob_url

parse_blob_url gets uuid and origin from url.

ex.

if "blob:http://web-platform.test:8000/8da840d9fed84875be1e896b8b2cbcc9" is given as url.
And parse_blob_url gets 8da840d9fed84875be1e896b8b2cbcc9 as uuid and http://web-platform.test:8000 as origin.

And, CreateObjectURL seems to store uuid as key.(because it call set_blob_url_validity.)

So I think that it is correct that RevokeObjectURL uses uuid as key and uses parse_blob_url.

2. About failed tests.

I ran the test in my local(macOS Mojave 10.14.6).
And, I got the following results.

> ./mach test-wpt tests/wpt/web-platform-tests/FileAPI/url/url-with-xhr.any.js    

...

web-platform-test
~~~~~~~~~~~~~~~~~
Ran 30 checks (28 subtests, 2 tests)
Expected results: 30
Unexpected results: 0
OK
 0:05.78 INFO Closing logging queue
 0:05.78 INFO queue closed
> ./mach test-wpt tests/wpt/web-platform-tests/FileAPI/url/url-with-fetch.any.js

...

0:04.77 TEST_END: Test OK. Subtests passed 10/15. Unexpected 1
FAIL Revoke blob URL after calling fetch, fetch should succeed - promise_test: Unhandled rejection with value: object "TypeError: Network error occurred"
 0:04.77 INFO No more tests
 0:04.78 INFO Closing logging queue
 0:04.78 INFO queue closed
 0:04.80 TEST_END: Test OK. Subtests passed 10/15. Unexpected 1
FAIL Revoke blob URL after calling fetch, fetch should succeed - promise_test: Unhandled rejection with value: object "TypeError: Network error occurred"
 0:04.80 INFO No more tests
 0:04.81 INFO Closing logging queue
 0:04.81 INFO queue closed
 0:04.82 INFO Got 2 unexpected results
 0:04.82 SUITE_END

web-platform-test
~~~~~~~~~~~~~~~~~
Ran 32 checks (30 subtests, 2 tests)
Expected results: 30
Unexpected results: 2
  subtest: 2 (2 fail)

Unexpected Results
------------------
/FileAPI/url/url-with-fetch.any.html
  FAIL Revoke blob URL after calling fetch, fetch should succeed - promise_test: Unhandled rejection with value: object "TypeError: Network error occurred"
/FileAPI/url/url-with-fetch.any.worker.html
  FAIL Revoke blob URL after calling fetch, fetch should succeed - promise_test: Unhandled rejection with value: object "TypeError: Network error occurred"

Is this the error you said?

And, I tried adding the following to url-with-fetch.any.js.

  ...
  const result = fetch_should_succeed(t, url).then(text => {
    assert_equals(text, blob_contents);
  });

  // added code
  for (i = 0; i < 1000; i ++) {
    console.log("aaaa");
  }

  // Revoke the object URL. fetch should have already resolved the blob URL.
  URL.revokeObjectURL(url);

  return result;
}, 'Revoke blob URL after calling fetch, fetch should succeed');

And, I got the following result.

> ./mach test-wpt tests/wpt/web-platform-tests/FileAPI/url/url-with-fetch.any.js
...

 0:05.20 TEST_END: Test OK. Subtests passed 11/15. Unexpected 0
 0:05.20 INFO No more tests
 0:05.21 INFO Closing logging queue
 0:05.21 INFO queue closed
 0:05.21 INFO Got 0 unexpected results
 0:05.21 SUITE_END

web-platform-test
~~~~~~~~~~~~~~~~~
Ran 32 checks (30 subtests, 2 tests)
Expected results: 32
Unexpected results: 0
OK
 0:05.24 INFO Closing logging queue
 0:05.24 INFO queue closed

So, I think that the cause of the error is the fetch timing.

Is this correct?

@nox
Copy link
Member

nox commented Nov 12, 2019

r? @jdm

@highfive highfive assigned jdm and unassigned nox Nov 12, 2019
@jdm
Copy link
Member

jdm commented Nov 12, 2019

@shnmorimoto With respect to the test output, when a test says:

Ran 30 checks (28 subtests, 2 tests)
Expected results: 30
Unexpected results: 0
OK
 0:05.78 INFO Closing logging queue
 0:05.78 INFO queue closed

That means that the test results matched the expected results. For that test, they are present in this file, which shows that various subtests are currently expected to fail. By making the changes I recommend, our goal is to make the subtests pass and remove these expected failures.

As for the question about parse_blob_url, rather than my original suggestion (make the RevokeBlobURL message accept a URL argument), I think we should modify parse_blob_url to return an Err if the parsed URL contains a fragment or query string. This should achieve the same goal - revoking a blob URL that has a fragment (#foo) attached to it should not cause the blob to be revoked.

@shnmorimoto
Copy link
Contributor Author

shnmorimoto commented Nov 13, 2019

@jdm I misunderstood the test output. Thank you for the detailed explanation.

I think we should modify parse_blob_url to return an Err if the parsed URL contains a fragment or query string. This should achieve the same goal - revoking a blob URL that has a fragment (#foo) attached to it should not cause the blob to be revoked.

I understand. I will fix it that way.

@shnmorimoto shnmorimoto force-pushed the shnmorimoto:fix_revoke_blob_url branch from 999818e to bc9de39 Nov 17, 2019
@shnmorimoto
Copy link
Contributor Author

shnmorimoto commented Nov 17, 2019

@jdm I've fixed it. For fragment, there are following test.

 promise_test(t => {
    const url = URL.createObjectURL(blob);

    return fetch_should_succeed(t, url + '#fragment').then(text => {
      assert_equals(text, blob_contents);
    });
  }, fetch_method + ' with a fragment should succeed');

So, It is only checked in RevokeObjectURL.

What do you think?

@jdm
Copy link
Member

jdm commented Nov 17, 2019

Good find. I agree!

@shnmorimoto
Copy link
Contributor Author

shnmorimoto commented Nov 17, 2019

Thanks! I fixed it as follows and already pushed.

if let Ok(url) = ServoUrl::parse(&url) {
    if url.fragment().is_none() && origin == get_blob_origin(&url) {

I ran the test locally and confirmed that the results changed.

web-platform-test
~~~~~~~~~~~~~~~~~
Ran 30 checks (28 subtests, 2 tests)
Expected results: 24
Unexpected results: 6
  subtest: 6 (6 pass)

Unexpected Results
------------------
/FileAPI/url/url-with-xhr.any.worker.html
  UNEXPECTED-PASS Only exact matches should revoke URLs, using XHR
  UNEXPECTED-PASS Appending a query string should cause XHR to fail
  UNEXPECTED-PASS Appending a path should cause XHR to fail
/FileAPI/url/url-with-xhr.any.html
  UNEXPECTED-PASS Only exact matches should revoke URLs, using XHR
  UNEXPECTED-PASS Appending a query string should cause XHR to fail
  UNEXPECTED-PASS Appending a path should cause XHR to fail
 0:05.07 INFO Closing logging queue
 0:05.08 INFO queue closed
@jdm
Copy link
Member

jdm commented Nov 17, 2019

Please include the updated test results in this PR, in that case :)

@jdm
Copy link
Member

jdm commented Nov 17, 2019

You can use ./mach test-wpt tests/wpt/web-platform-tests/FileAPI as the base command in order to avoid having to run thousands of unnecessary tests, too!

@shnmorimoto shnmorimoto force-pushed the shnmorimoto:fix_revoke_blob_url branch from bc9de39 to 570adf2 Nov 17, 2019
@shnmorimoto
Copy link
Contributor Author

shnmorimoto commented Nov 17, 2019

Oh, Sorry. I updated test results.

I still get unexpected results locally.

> ./mach test-wpt tests/wpt/web-platform-tests/FileAPI                                                                                                                  fix_revoke_blob_url_2 ✱
Running 56 tests in web-platform-tests

  ▶ Unexpected subtest result in /FileAPI/url/url-with-fetch.any.worker.html:
  │ FAIL [expected PASS] Revoke blob URL after calling fetch, fetch should succeed
  └   → promise_test: Unhandled rejection with value: object "TypeError: Network error occurred"

  ▶ Unexpected subtest result in /FileAPI/url/url-in-tags-revoke.window.html:
  │ FAIL [expected TIMEOUT] Opening a blob URL in a new window immediately before revoking it works.
  │   → assert_equals: expected (string) "test_frame_OK" but got (undefined) undefined
  │
  │ win.onload<@http://web-platform.test:8000/FileAPI/url/url-in-tags-revoke.window.js:52:5
  │ Test.prototype.step@http://web-platform.test:8000/resources/testharness.js:1908:25
  └ Test.prototype.step_func_done/<@http://web-platform.test:8000/resources/testharness.js:1948:32

  ▶ Unexpected subtest result in /FileAPI/url/url-with-fetch.any.html:
  │ FAIL [expected PASS] Revoke blob URL after calling fetch, fetch should succeed
  └   → promise_test: Unhandled rejection with value: object "TypeError: Network error occurred"

Ran 56 tests finished in 117.0 seconds.
  • 53 ran as expected. 0 tests skipped.
  • 3 tests had unexpected subtest results  

But, I get same results with master branch too.
So, I ignored it this time.

@bors-servo
Copy link
Contributor

bors-servo commented Nov 17, 2019

The latest upstream changes (presumably #24761) made this pull request unmergeable. Please resolve the merge conflicts.

@shnmorimoto shnmorimoto force-pushed the shnmorimoto:fix_revoke_blob_url branch from 570adf2 to be3cc5c Nov 17, 2019
@shnmorimoto shnmorimoto force-pushed the shnmorimoto:fix_revoke_blob_url branch from be3cc5c to 2d995ba Nov 18, 2019
@shnmorimoto
Copy link
Contributor Author

shnmorimoto commented Nov 18, 2019

I did rebase and resolved merge conflicts.

@jdm
Copy link
Member

jdm commented Nov 18, 2019

@bors-servo r+
Thanks for fixing this!

@bors-servo
Copy link
Contributor

bors-servo commented Nov 18, 2019

📌 Commit 2d995ba has been approved by jdm

@bors-servo
Copy link
Contributor

bors-servo commented Nov 19, 2019

Testing commit 2d995ba with merge cc4d3c0...

bors-servo added a commit that referenced this pull request Nov 19, 2019
Fix revoke blob url

<!-- Please describe your changes on the following line: -->

fix #24290

---
<!-- 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 #24290 (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. -->
@bors-servo
Copy link
Contributor

bors-servo commented Nov 19, 2019

💔 Test failed - status-taskcluster

@jdm
Copy link
Member

jdm commented Nov 19, 2019

@bors-servo
Copy link
Contributor

bors-servo commented Nov 19, 2019

💣 Failed to start rebuilding: 405 Not Allowed

@bors-servo
Copy link
Contributor

bors-servo commented Nov 19, 2019

Testing commit 2d995ba with merge d553158...

bors-servo added a commit that referenced this pull request Nov 19, 2019
Fix revoke blob url

<!-- Please describe your changes on the following line: -->

fix #24290

---
<!-- 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 #24290 (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. -->
@bors-servo
Copy link
Contributor

bors-servo commented Nov 19, 2019

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

@bors-servo bors-servo merged commit 2d995ba into servo:master Nov 19, 2019
2 checks passed
2 checks passed
Community-TC (pull_request) TaskGroup: success
Details
homu Test successful
Details
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.