|
| 1 | +<!doctype html> |
| 2 | +<script src="/resources/testharness.js"></script> |
| 3 | +<script src="/resources/testharnessreport.js"></script> |
| 4 | +<script src="resources/helpers.js"></script> |
| 5 | +<script src="/common/utils.js"></script> |
| 6 | + |
| 7 | +<body> |
| 8 | +<script> |
| 9 | +promise_test(async t => { |
| 10 | + const id = token(); |
| 11 | + |
| 12 | + const i = document.createElement("iframe"); |
| 13 | + i.src = `resources/204-205-download-on-second-visit.py?id=${id}`; |
| 14 | + document.body.append(i); |
| 15 | + await new Promise(r => i.onload = r); |
| 16 | + |
| 17 | + // Configure it to return a 204 on the next visit |
| 18 | + await fetch(i.src + "&action=204", { method: "POST" }); |
| 19 | + |
| 20 | + // Now navigate elsewhere |
| 21 | + i.contentWindow.location.href = "/common/blank.html"; |
| 22 | + await new Promise(r => i.onload = r); |
| 23 | + |
| 24 | + // Now try going back. It should do nothing (and not tell us about the result). |
| 25 | + |
| 26 | + const indexBefore = i.contentWindow.navigation.currentEntry.index; |
| 27 | + |
| 28 | + const result = i.contentWindow.navigation.back(); |
| 29 | + |
| 30 | + assertNeverSettles(t, result, i.contentWindow); |
| 31 | + i.contentWindow.navigation.onnavigate = t.unreached_func("onnavigate should not be called"); |
| 32 | + i.contentWindow.navigation.onnavigatesuccess = t.unreached_func("onnavigatesuccess should not be called"); |
| 33 | + i.contentWindow.navigation.onnavigateerror = t.unreached_func("onnavigateerror should not be called"); |
| 34 | + |
| 35 | + await new Promise(resolve => t.step_timeout(resolve, 30)); |
| 36 | + assert_equals(i.contentWindow.navigation.currentEntry.index, indexBefore); |
| 37 | +}, "back() promises to 204s never settle"); |
| 38 | + |
| 39 | +promise_test(async t => { |
| 40 | + const id = token(); |
| 41 | + |
| 42 | + const i = document.createElement("iframe"); |
| 43 | + i.src = `resources/204-205-download-on-second-visit.py?id=${id}`; |
| 44 | + document.body.append(i); |
| 45 | + await new Promise(r => i.onload = r); |
| 46 | + |
| 47 | + // Configure it to return a 205 on the next visit |
| 48 | + await fetch(i.src + "&action=205", { method: "POST" }); |
| 49 | + |
| 50 | + // Now navigate elsewhere |
| 51 | + i.contentWindow.location.href = "/common/blank.html"; |
| 52 | + await new Promise(r => i.onload = r); |
| 53 | + |
| 54 | + // Now try going back. It should do nothing (and not tell us about the result). |
| 55 | + |
| 56 | + const indexBefore = i.contentWindow.navigation.currentEntry.index; |
| 57 | + |
| 58 | + const result = i.contentWindow.navigation.back(); |
| 59 | + |
| 60 | + assertNeverSettles(t, result, i.contentWindow); |
| 61 | + i.contentWindow.navigation.onnavigate = t.unreached_func("onnavigate should not be called"); |
| 62 | + i.contentWindow.navigation.onnavigatesuccess = t.unreached_func("onnavigatesuccess should not be called"); |
| 63 | + i.contentWindow.navigation.onnavigateerror = t.unreached_func("onnavigateerror should not be called"); |
| 64 | + |
| 65 | + await new Promise(resolve => t.step_timeout(resolve, 30)); |
| 66 | + assert_equals(i.contentWindow.navigation.currentEntry.index, indexBefore); |
| 67 | +}, "back() promises to 205s never settle"); |
| 68 | + |
| 69 | +promise_test(async t => { |
| 70 | + const id = token(); |
| 71 | + |
| 72 | + const i = document.createElement("iframe"); |
| 73 | + i.src = `resources/204-205-download-on-second-visit.py?id=${id}`; |
| 74 | + document.body.append(i); |
| 75 | + await new Promise(r => i.onload = r); |
| 76 | + |
| 77 | + // Configure it to return a download on the next visit |
| 78 | + await fetch(i.src + "&action=download", { method: "POST" }); |
| 79 | + |
| 80 | + // Now navigate elsewhere |
| 81 | + i.contentWindow.location.href = "/common/blank.html"; |
| 82 | + await new Promise(r => i.onload = r); |
| 83 | + |
| 84 | + // Now try going back. It should do nothing (and not tell us about the result). |
| 85 | + |
| 86 | + const indexBefore = i.contentWindow.navigation.currentEntry.index; |
| 87 | + |
| 88 | + const result = i.contentWindow.navigation.back(); |
| 89 | + |
| 90 | + assertNeverSettles(t, result, i.contentWindow); |
| 91 | + i.contentWindow.navigation.onnavigate = t.unreached_func("onnavigate should not be called"); |
| 92 | + i.contentWindow.navigation.onnavigatesuccess = t.unreached_func("onnavigatesuccess should not be called"); |
| 93 | + i.contentWindow.navigation.onnavigateerror = t.unreached_func("onnavigateerror should not be called"); |
| 94 | + |
| 95 | + await new Promise(resolve => t.step_timeout(resolve, 30)); |
| 96 | + assert_equals(i.contentWindow.navigation.currentEntry.index, indexBefore); |
| 97 | +}, "back() promises to Content-Disposition: attachment responses never settle"); |
| 98 | +</script> |
0 commit comments