Bug 1899734 Comment 0 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

(this requires 2 files for testcase, so I'm not attaching it)

Steps to reproduce:
  1. prepare local server (e.g. `python3 -m http.server 8000`) providing the following 2 files
  2. run Nightly 128.0a1 (2024-05-30) (64-bit) on macOS
  3. open `http://localhost:8000/a.js`
  4. open Web Console
  5. Reload the page with F5

Actual result:
  * 1 is logged at steps 3-4
  * 0 is logged at step 5

Expected result:
The same number is loggged between steps 3-4 and step 5.

Testcase:

 * `test.html`
```html
<html>
<head>
<title>test</title>
<script>
function onLoad() {
  console.log(performance.getEntriesByType("resource").length);
}
</script>
<link rel="stylesheet" href="test.css" onload="onLoad()">
</head>
<body>
Hello
</body>
</html>
```

 * `test.css`
```css
body { color: red }
```

Some observation:

Chrome and Safari shows 1 for both case.

This is caused by `SharedStyleSheetCache` (`SharedSubResourceCache`) or its consumer not creating corresponding `PerformanceEntry` when the cache is used.
This issue disappears when [mozilla::SharedStyleSheetCache::InsertIfNeeded](https://searchfox.org/mozilla-central/rev/23efe2c8c5b3a3182d449211ff9036fb34fe0219/layout/style/SharedStyleSheetCache.cpp#72) is modified to immediately return, so that it doesn't cache anything.

```
void SharedStyleSheetCache::InsertIfNeeded(css::SheetLoadData& aData) {
  return;
...
```

I'm still not sure how strict the requirement for `PerformanceEntry` existence is tho, at least there's behavior difference between browsers.
(this requires 2 files for testcase, so I'm not attaching it)

Steps to reproduce:
  1. prepare local server (e.g. `python3 -m http.server 8000`) providing the following 2 files
  2. run Nightly 128.0a1 (2024-05-30) (64-bit) on macOS
  3. open `http://localhost:8000/test.js`
  4. open Web Console
  5. Reload the page with F5

Actual result:
  * 1 is logged at steps 3-4
  * 0 is logged at step 5

Expected result:
The same number is loggged between steps 3-4 and step 5.

Testcase:

 * `test.html`
```html
<html>
<head>
<title>test</title>
<script>
function onLoad() {
  console.log(performance.getEntriesByType("resource").length);
}
</script>
<link rel="stylesheet" href="test.css" onload="onLoad()">
</head>
<body>
Hello
</body>
</html>
```

 * `test.css`
```css
body { color: red }
```

Some observation:

Chrome and Safari shows 1 for both case.

This is caused by `SharedStyleSheetCache` (`SharedSubResourceCache`) or its consumer not creating corresponding `PerformanceEntry` when the cache is used.
This issue disappears when [mozilla::SharedStyleSheetCache::InsertIfNeeded](https://searchfox.org/mozilla-central/rev/23efe2c8c5b3a3182d449211ff9036fb34fe0219/layout/style/SharedStyleSheetCache.cpp#72) is modified to immediately return, so that it doesn't cache anything.

```
void SharedStyleSheetCache::InsertIfNeeded(css::SheetLoadData& aData) {
  return;
...
```

I'm still not sure how strict the requirement for `PerformanceEntry` existence is tho, at least there's behavior difference between browsers.
(this requires 2 files for testcase, so I'm not attaching it)

Steps to reproduce:
  1. prepare local server (e.g. `python3 -m http.server 8000`) providing the following 2 files
  2. run Nightly 128.0a1 (2024-05-30) (64-bit) on macOS
  3. open `http://localhost:8000/test.html`
  4. open Web Console
  5. Reload the page with F5

Actual result:
  * 1 is logged at steps 3-4
  * 0 is logged at step 5

Expected result:
The same number is loggged between steps 3-4 and step 5.

Testcase:

 * `test.html`
```html
<html>
<head>
<title>test</title>
<script>
function onLoad() {
  console.log(performance.getEntriesByType("resource").length);
}
</script>
<link rel="stylesheet" href="test.css" onload="onLoad()">
</head>
<body>
Hello
</body>
</html>
```

 * `test.css`
```css
body { color: red }
```

Some observation:

Chrome and Safari shows 1 for both case.

This is caused by `SharedStyleSheetCache` (`SharedSubResourceCache`) or its consumer not creating corresponding `PerformanceEntry` when the cache is used.
This issue disappears when [mozilla::SharedStyleSheetCache::InsertIfNeeded](https://searchfox.org/mozilla-central/rev/23efe2c8c5b3a3182d449211ff9036fb34fe0219/layout/style/SharedStyleSheetCache.cpp#72) is modified to immediately return, so that it doesn't cache anything.

```
void SharedStyleSheetCache::InsertIfNeeded(css::SheetLoadData& aData) {
  return;
...
```

I'm still not sure how strict the requirement for `PerformanceEntry` existence is tho, at least there's behavior difference between browsers.

Back to Bug 1899734 Comment 0