diff options
Diffstat (limited to 'testing/web-platform/tests/html/semantics/embedded-content/bfcache')
7 files changed, 107 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/semantics/embedded-content/bfcache/embedded-html.html b/testing/web-platform/tests/html/semantics/embedded-content/bfcache/embedded-html.html new file mode 100644 index 0000000000..0808538337 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/bfcache/embedded-html.html @@ -0,0 +1,10 @@ +<!doctype html> +<link rel="help" href="http://crbug.com/1325192"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/resources/test-only-api.js"></script> + +<script type="module"> +import * as common from "./resources/common.js"; +common.runBfcacheTestForEmbeds({"type": "text/html", "src": "/resources/blank.html"}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/bfcache/embedded-img.html b/testing/web-platform/tests/html/semantics/embedded-content/bfcache/embedded-img.html new file mode 100644 index 0000000000..7e9d713c0a --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/bfcache/embedded-img.html @@ -0,0 +1,10 @@ +<!doctype html> +<link rel="help" href="http://crbug.com/1325192"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/resources/test-only-api.js"></script> + +<script type="module"> +import * as common from "./resources/common.js"; +common.runBfcacheTestForEmbeds({'type': 'image/png', 'src': '/images/blue.png'}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/bfcache/embedded-js.html b/testing/web-platform/tests/html/semantics/embedded-content/bfcache/embedded-js.html new file mode 100644 index 0000000000..c3b027563d --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/bfcache/embedded-js.html @@ -0,0 +1,11 @@ +<!doctype html> +<link rel="help" href="http://crbug.com/1325192"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/resources/test-only-api.js"></script> + +<script type="module"> +import * as common from "./resources/common.js"; +common.runBfcacheTestForEmbeds( + {'type': 'application/javascript', 'src': '/resources/test-only-api.js'}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/bfcache/embedded-mp4.html b/testing/web-platform/tests/html/semantics/embedded-content/bfcache/embedded-mp4.html new file mode 100644 index 0000000000..fde560e5be --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/bfcache/embedded-mp4.html @@ -0,0 +1,10 @@ +<!doctype html> +<link rel="help" href="http://crbug.com/1325192"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/resources/test-only-api.js"></script> + +<script type="module"> +import * as common from "./resources/common.js"; +common.runBfcacheTestForEmbeds({'src': '/media/white.mp4'}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/bfcache/embedded-not-found.html b/testing/web-platform/tests/html/semantics/embedded-content/bfcache/embedded-not-found.html new file mode 100644 index 0000000000..0b56b5eadc --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/bfcache/embedded-not-found.html @@ -0,0 +1,10 @@ +<!doctype html> +<link rel="help" href="http://crbug.com/1325192"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/resources/test-only-api.js"></script> + +<script type="module"> +import * as common from "./resources/common.js"; +common.runBfcacheTestForEmbeds({'type': 'image/png', 'src': '/404.png'}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/bfcache/embedded-type-only.html b/testing/web-platform/tests/html/semantics/embedded-content/bfcache/embedded-type-only.html new file mode 100644 index 0000000000..90c9d3311c --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/bfcache/embedded-type-only.html @@ -0,0 +1,10 @@ +<!doctype html> +<link rel="help" href="http://crbug.com/1325192"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/resources/test-only-api.js"></script> + +<script type="module"> +import * as common from "./resources/common.js"; +common.runBfcacheTestForEmbeds({'type': 'text/html'}); +</script> diff --git a/testing/web-platform/tests/html/semantics/embedded-content/bfcache/resources/common.js b/testing/web-platform/tests/html/semantics/embedded-content/bfcache/resources/common.js new file mode 100644 index 0000000000..5bb9642a83 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/embedded-content/bfcache/resources/common.js @@ -0,0 +1,46 @@ +'use strict'; + +async function loadBfCacheTestHelperResources() { + await loadScript('/common/utils.js'); + await loadScript('/common/dispatcher/dispatcher.js'); + await loadScript( + '/html/browsers/browsing-the-web/back-forward-cache/resources/helper.sub.js'); +} +await loadBfCacheTestHelperResources(); + +// Runs BFCache tests for embed elements, specifically <embed> and <object>. +// 1. Attaches the target element to first page. +// 2. Navigates away, then back via bfcache if this case is supported by the +// browser. +// @param {Object} testCase - The target element's attributes to test with. +export function runBfcacheTestForEmbeds(testCase) { + assert_implements(runBfcacheTest, '`runBfcacheTest()` is unavailable.'); + assert_implements(originSameOrigin, '`originSameOrigin` is unavailable.'); + + const tags = [ + {'name': 'embed', 'srcAttr': 'src'}, + {'name': 'object', 'srcAttr': 'data'}, + ]; + for (const tag of tags) { + runBfcacheTest( + { + targetOrigin: originSameOrigin, + shouldBeCached: true, + funcBeforeNavigation: (tag, attrs) => { + let e = document.createElement(tag.name); + // Only sets defined attributes to match the intended test behavior + // like embedded-type-only.html test. + if ('type' in attrs) { + e.type = attrs.type; + } + if ('src' in attrs) { + e[tag.srcAttr] = attrs.src; + } + document.body.append(e); + }, + argsBeforeNavigation: [tag, testCase] + }, + `Page with <${tag.name} ` + + `type=${testCase.type} ${tag.srcAttr}=${testCase.src}>`); + } +} |