Closed Bug 1886518 Opened 11 months ago Closed 4 months ago

Add tests for BiDi network events for cached images

Categories

(Remote Protocol :: WebDriver BiDi, task, P3)

task
Points:
2

Tracking

(firefox133 fixed)

RESOLVED FIXED
133 Branch
Tracking Status
firefox133 --- fixed

People

(Reporter: jdescottes, Assigned: jdescottes)

References

(Blocks 3 open bugs)

Details

(Whiteboard: [webdriver:m13], [wptsync upstream])

Attachments

(2 files)

Similar to cached stylesheets (Bug 1879438), cached images need to be monitored in the content process.

See DevTools implementation over at https://searchfox.org/mozilla-central/rev/b73676a106c1655030bb876fd5e0a6825aee6044/devtools/server/actors/resources/network-events-content.js#52-62

The severity field is not set for this bug.
:whimboo, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(hskupin)
Severity: -- → S3
Priority: -- → P3
Whiteboard: [webdriver:backlog]
Flags: needinfo?(hskupin)
See Also: → 1919218

This should be fixed by Bug 1919218, so let's repurpose this bug to add browser mochitests for JS+image and wdspec tests for cached image requests.

Severity: S3 → --
Type: defect → task
Summary: Missing BiDi network events for cached images → Add tests for BiDi network events for cached images

Quick question for images, as I was adding a test for this resource with the BiDi CachedResourceListener:

If an image is already loaded and cached in the page, and we add an iframe in the page which attempts to load the same image, should this new image trigger a fetch and hit the cache?

In other words for the following markup:
(top level page)

<html>
  <body>
    <img src="https://example.com/browser/remote/shared/listeners/test/browser/cached_resource.sjs?type=image">
    <iframe src="https://example.com/document-builder.sjs?html=cached_css_frame"></iframe>
  </body>
</html>

(iframe)

<html>
  <body>
    <img src="https://example.com/browser/remote/shared/listeners/test/browser/cached_resource.sjs?type=image">
  </body>
</html>

Should we expect to perform a fetch for the image in the iframe?
Testing locally I don't see any request at least.

Flags: needinfo?(arai.unmht)

While writing a wdspec test for images I noticed another discrepancy compared to chrome.

The scenario is as follows:

  • load a page with an <img> tag pointing to a URL returning proper caching headers
  • reload the page (-> here we get a notification for the cached image request)
  • load a similar page, but which includes 2 <img> tags for the same URL as in the previous page

Here I get no notification at all, whereas in Chrome I do get an event. Is this something which might be wrong in our implementation?

I don't know much about the image cache's implementation.

My understanding is that the behavior is reflecting the following spec steps, which uses "the list of available images" below.
If the "the list of available images" contains the image, it doesn't reach the "fetch" step.

https://html.spec.whatwg.org/#updating-the-image-data:list-of-available-images

When the user agent is to update the image data of an img element, optionally with the restart animations flag set, optionally with the maybe omit events flag set, it must run the following steps:

...
7. If selected source is not null, then:
  ...
  4. If the list of available images contains an entry for key, then:
    ...
    8. Abort the update the image data algorithm.
...
26. Fetch the image: Fetch request. ...

Then, the spec says the entries in the list of available images "may" be copied to another documents. Which would mean that the number of fetches is not actually deterministic in term of the spec, and it's up to the implementation, maybe?

https://html.spec.whatwg.org/#the-list-of-available-images

Each Document object must have a list of available images. Each image in this list is identified by a tuple consisting of an absolute URL, a CORS settings attribute mode, and, if the mode is not No CORS, an origin. Each image furthermore has an ignore higher-layer caching flag.
User agents may copy entries from one Document object's list of available images to another at any time (e.g. when the Document is created, user agents can add to it all the images that are loaded in other Documents), but must not change the keys of entries copied in this way when doing so, and must unset the ignore higher-layer caching flag for the copied entry.
User agents may also remove images from such lists at any time (e.g. to save memory). User agents must remove entries in the list of available images as appropriate given higher-layer caching semantics for the resource (e.g. the HTTP Cache-Control response header) when the ignore higher-layer caching flag is unset.

anyway, it would be better asking people who implements the image loading.
forwarding to emilio.

Flags: needinfo?(arai.unmht) → needinfo?(emilio)

Thanks for the insights. It might be something difficult to test in a cross browser way in that case.

Yeah if you want to test the available image cache you need to basically start fresh (add a dummy query parameter or something), and that still only works for the same-document case.

Flags: needinfo?(emilio)
Assignee: nobody → jdescottes
Status: NEW → ASSIGNED

(In reply to Emilio Cobos Álvarez (:emilio) from comment #7)

Yeah if you want to test the available image cache you need to basically start fresh (add a dummy query parameter or something), and that still only works for the same-document case.

Thanks! Do you also confirm that

User agents may copy entries from one Document object's list of available images to another at any time

implies that we can't really test scenarios where cached images are reused from one document to another in a cross browser manner?

Flags: needinfo?(emilio)

Correct

Flags: needinfo?(emilio)
Attachment #9428865 - Attachment description: Bug 1886518 - [wdspec] Add wdspec tests for image cache network requests → Bug 1886518 - [wdspec] Add mozilla specific wdspec tests for image cache network requests
Attachment #9428865 - Attachment description: Bug 1886518 - [wdspec] Add mozilla specific wdspec tests for image cache network requests → Bug 1886518 - [wdspec] Add wdspec tests for image cache network requests
Pushed by jdescottes@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/700db3fe7394 [remote] Add cached resource test for images and scripts r=webdriver-reviewers,Sasha https://hg.mozilla.org/integration/autoland/rev/f22ae80101e8 [wdspec] Add wdspec tests for image cache network requests r=webdriver-reviewers,Sasha
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/48595 for changes under testing/web-platform/tests
Whiteboard: [webdriver:backlog] → [webdriver:backlog], [wptsync upstream]
Status: ASSIGNED → RESOLVED
Closed: 4 months ago
Resolution: --- → FIXED
Target Milestone: --- → 133 Branch
Upstream PR merged by moz-wptsync-bot
Points: --- → 2
Whiteboard: [webdriver:backlog], [wptsync upstream] → [webdriver:m13], [wptsync upstream]
Regressions: 1926482
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: