iframe-network-error.sub.html (1895B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>Network errors with iframe elements</title> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 7 <body> 8 <script> 9 "use strict"; 10 11 async_test(t => { 12 const iframe = document.createElement("iframe"); 13 iframe.src = "//{{hosts[][nonexistent]}}/"; 14 iframe.onload = () => t.done(); 15 iframe.onerror = t.unreached_func("error event must not fire"); 16 document.body.append(iframe); 17 }, "new iframe: nonexistent host"); 18 19 async_test(t => { 20 const iframe = document.createElement("iframe"); 21 iframe.src = "../resources/not-embeddable.html"; 22 iframe.onload = () => t.done(); 23 iframe.onerror = t.unreached_func("error event must not fire"); 24 document.body.append(iframe); 25 }, "new iframe: X-Frame-Options prevents embedding"); 26 27 async_test(t => { 28 const iframe = document.createElement("iframe"); 29 iframe.src = "/common/blank.html"; 30 iframe.name = "existingIframe1"; 31 iframe.onload = t.step_func(() => { 32 iframe.onload = () => t.done(); 33 iframe.onerror = t.unreached_func("error event must not fire 2"); 34 35 frames.existingIframe1.location.href = "//{{hosts[][nonexistent]}}/"; 36 }); 37 iframe.onerror = t.unreached_func("error event must not fire 1"); 38 document.body.append(iframe); 39 }, "navigating an existing iframe: nonexistent host"); 40 41 async_test(t => { 42 const iframe = document.createElement("iframe"); 43 iframe.src = "/common/blank.html"; 44 iframe.name = "existingIframe2"; 45 iframe.onload = t.step_func(() => { 46 iframe.onload = () => t.done(); 47 iframe.onerror = t.unreached_func("error event must not fire 2"); 48 49 frames.existingIframe2.location.href = "../resources/not-embeddable.html"; 50 }); 51 iframe.onerror = t.unreached_func("error event must not fire 1"); 52 document.body.append(iframe); 53 }, "navigating an existing iframe: X-Frame-Options prevents embedding"); 54 </script>