<html>
<head>
<script src="resources/sw-test-pre.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
var frame;
promise_test(async (test) => {
    frame = await interceptedFrame("resources/service-worker-cache-api-worker.js", "/workers/service/resources/");
    var fetch = frame.contentWindow.fetch;

    var response = await fetch("/resources/square100.png.fromserviceworker");
    var buffer =  await response.arrayBuffer();
    assert_equals(buffer.byteLength, 12940);
}, "Testing cache API in service worker");

promise_test(async (test) => {
    if (!self.internals)
        return Promise.reject("internals required for this test");

    var response = await frame.contentWindow.fetch("opaqueWithBlob");
    assert_equals(await response.text(), "PASS");
}, "Testing cache API with opaque response + blob");
</script>
</body>
</html>
