forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ImageLoader: Stop storing request KURL in Task
This CL removes |ImageLoader::Task::request_url_| in favor of lazily parsing the image request's absolute URL when ImageLoader::Task is run. Currently ImageLoader::Task stores a KURL |request_url_|, which is a snapshot of the image's absolute URL, parsed relative to the image element's node document at the time ImageLoader::Task is queued. We shouldn't have to store a snapshot of the parsed URL, because the source URL at the time an ImageLoader::Task is run is the same as when the task is queued. The reason we stored a snapshot of the parsed URL is because what *can* change in between when an ImageLoader::Task is queued and run, is the document's base URL, via a `<base>` element. In https://crbug.com/569760 a CL was landed that takes this snapshot, so that if a `<base>` element was dynamically-inserted before the ImageLoader::Task was run, the URL would be unaffected by the addition of the `<base>`. However, the spec is very clear that the parsing of an image request's URL [1] happens after the microtask is run, meaning our snapshot is unnecessary, and incorrect. This CL: - Removes the snapshot - Fixes the associated test - Exports the test to external/wpt so other impls can benefit [1]: https://html.spec.whatwg.org/multipage/images.html#updating-the-image-data:parse-a-url-2 Bug: 569760,1061685 Change-Id: I8d9e3dbefd27a26626bb930acc809196753c7506 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2103987 Commit-Queue: Dominic Farolino <dom@chromium.org> Reviewed-by: Kinuko Yasuda <kinuko@chromium.org> Reviewed-by: Fredrik Söderquist <fs@opera.com> Cr-Commit-Position: refs/heads/master@{#756376}
- Loading branch information
1 parent
3c0f255
commit c39d736
Showing
4 changed files
with
40 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...ts/external/wpt/html/semantics/embedded-content/the-img-element/image-parse-url-base.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Image load parses URL after microtask runs</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
</head> | ||
|
||
<body> | ||
<img id="img"> | ||
<script> | ||
const t = async_test("An image request's parsed URL should be affected by a " + | ||
"dynamically-inserted <base>, if it was inserted before " + | ||
"the image request microtask runs"); | ||
|
||
t.step(() => { | ||
const elm = document.getElementById('img'); | ||
elm.src = 'resources/image.png'; | ||
elm.onload = t.unreached_func("The image should have failed to load, as " + | ||
"the request URL should be affected by the " + | ||
"<base> element"); | ||
elm.onerror = t.step_func_done(); | ||
|
||
const base = document.createElement("base"); | ||
base.setAttribute("href", "bogus/"); | ||
document.head.appendChild(base); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
This file was deleted.
Oops, something went wrong.