Skip to content

Commit 7ed6d48

Browse files
mingycchromium-wpt-export-bot
authored andcommitted
Reland "[bfcache] Add wpt for embed/object elements"
Fixed flaky tests caused by occasional timeout by splitting test cases into individual files. This is a reland of ae805e49a41f82a2c191a587c08f031e437a7187 Original change's description: > [bfcache] Add wpt for embed/object elements > > Bug: 1325192 > > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3661804 > Reviewed-by: Fergal Daly <[email protected]> > Commit-Queue: Ming-Ying Chung <[email protected]> > Cr-Commit-Position: refs/heads/main@{#1011458} > Change-Id: ae805e49a41f82a2c191a587c08f031e437a7187 Bug: 1325192 Change-Id: Ifb1fdf7c4106bf86d545c3e09925db521c2d1ddd Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3694854 Reviewed-by: Fergal Daly <[email protected]> Commit-Queue: Ming-Ying Chung <[email protected]> Cr-Commit-Position: refs/heads/main@{#1011950}
1 parent 88dd965 commit 7ed6d48

File tree

7 files changed

+101
-0
lines changed

7 files changed

+101
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!doctype html>
2+
<link rel="help" href="http://crbug.com/1325192">
3+
<script src="/resources/testharness.js"></script>
4+
<script src="/resources/testharnessreport.js"></script>
5+
<script src="/resources/test-only-api.js"></script>
6+
7+
<script type="module">
8+
import * as common from "./resources/common.js";
9+
common.runBfcacheTestForEmbeds({"type": "text/html", "src": "/resources/blank.html"});
10+
</script>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!doctype html>
2+
<link rel="help" href="http://crbug.com/1325192">
3+
<script src="/resources/testharness.js"></script>
4+
<script src="/resources/testharnessreport.js"></script>
5+
<script src="/resources/test-only-api.js"></script>
6+
7+
<script type="module">
8+
import * as common from "./resources/common.js";
9+
common.runBfcacheTestForEmbeds({'type': 'image/png', 'src': '/images/blue.png'});
10+
</script>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!doctype html>
2+
<link rel="help" href="http://crbug.com/1325192">
3+
<script src="/resources/testharness.js"></script>
4+
<script src="/resources/testharnessreport.js"></script>
5+
<script src="/resources/test-only-api.js"></script>
6+
7+
<script type="module">
8+
import * as common from "./resources/common.js";
9+
common.runBfcacheTestForEmbeds(
10+
{'type': 'application/javascript', 'src': '/resources/test-only-api.js'});
11+
</script>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!doctype html>
2+
<link rel="help" href="http://crbug.com/1325192">
3+
<script src="/resources/testharness.js"></script>
4+
<script src="/resources/testharnessreport.js"></script>
5+
<script src="/resources/test-only-api.js"></script>
6+
7+
<script type="module">
8+
import * as common from "./resources/common.js";
9+
common.runBfcacheTestForEmbeds({'src': '/media/white.mp4'});
10+
</script>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!doctype html>
2+
<link rel="help" href="http://crbug.com/1325192">
3+
<script src="/resources/testharness.js"></script>
4+
<script src="/resources/testharnessreport.js"></script>
5+
<script src="/resources/test-only-api.js"></script>
6+
7+
<script type="module">
8+
import * as common from "./resources/common.js";
9+
common.runBfcacheTestForEmbeds({'type': 'image/png', 'src': '/404.png'});
10+
</script>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!doctype html>
2+
<link rel="help" href="http://crbug.com/1325192">
3+
<script src="/resources/testharness.js"></script>
4+
<script src="/resources/testharnessreport.js"></script>
5+
<script src="/resources/test-only-api.js"></script>
6+
7+
<script type="module">
8+
import * as common from "./resources/common.js";
9+
common.runBfcacheTestForEmbeds({'type': 'text/html'});
10+
</script>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
'use strict';
2+
3+
async function loadBfCacheTestHelperResources() {
4+
await loadScript('/common/utils.js');
5+
await loadScript('/common/dispatcher/dispatcher.js');
6+
await loadScript(
7+
'/html/browsers/browsing-the-web/back-forward-cache/resources/helper.sub.js');
8+
}
9+
await loadBfCacheTestHelperResources();
10+
11+
// Runs BFCache tests for embed elements, specifically <embed> and <object>.
12+
// 1. Attaches the target element to first page.
13+
// 2. Navigates away, then back via bfcache if this case is supported by the
14+
// browser.
15+
// @param {Object} testCase - The target element's attributes to test with.
16+
export function runBfcacheTestForEmbeds(testCase) {
17+
assert_implements(runBfcacheTest, '`runBfcacheTest()` is unavailable.');
18+
assert_implements(originSameOrigin, '`originSameOrigin` is unavailable.');
19+
20+
const tags = [
21+
{'name': 'embed', 'srcAttr': 'src'},
22+
{'name': 'object', 'srcAttr': 'data'},
23+
];
24+
for (const tag of tags) {
25+
runBfcacheTest(
26+
{
27+
targetOrigin: originSameOrigin,
28+
shouldBeCached: true,
29+
funcBeforeNavigation: (tag, attrs) => {
30+
let e = document.createElement(tag.name);
31+
e.type = attrs.type;
32+
e[tag.srcAttr] = attrs.src;
33+
document.body.append(e);
34+
},
35+
argsBeforeNavigation: [tag, testCase]
36+
},
37+
`Page with <${tag.name} ` +
38+
`type=${testCase.type} ${tag.srcAttr}=${testCase.src}>`);
39+
}
40+
}

0 commit comments

Comments
 (0)