<!doctype html>
<iframe></iframe>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
var fetchTest = async_test("fetch() on discarded window");
var iframe = document.querySelector('iframe');
var w = iframe.contentWindow;
iframe.remove();
assert_not_equals(w.fetch, undefined,
'A discarded window should have |fetch| function.');
// NOTE: This is not explicitly specified as far as I know. This behavior
// may be Blink specific.
w.fetch('/fetch/resources/doctype.html').then(
function () {
assert_true(false, "This Promise must always be rejected.");
},
fetchTest.step_func(function (e) {
assert_true(e instanceof w.TypeError);
assert_equals(e.message, "Failed to execute 'fetch' on 'Window': The global scope is shutting down.");
fetchTest.done();
}));
</script>