delegation-sender-checks.tentative.html (2099B)
1 !DOCTYPE html> 2 <!-- 3 Tentative due to: 4 https://github.com/WICG/capability-delegation 5 --> 6 <title>Capability Delegation sender checks</title> 7 <script src="/resources/testharness.js"></script> 8 <script src="/resources/testharnessreport.js"></script> 9 <script src="/resources/testdriver.js"></script> 10 <script src="/resources/testdriver-actions.js"></script> 11 <script src="/resources/testdriver-vendor.js"></script> 12 <script src="resources/utils.js"></script> 13 14 <div> 15 Verifies that capability delegation related error checks in <a 16 href="https://wicg.github.io/capability-delegation/spec.html#monkey-patch-to-html-initiating-delegation">HTML 17 postMessage algorithm</a> are enforced correctly. 18 </div> 19 20 <iframe width="300px" height="50px"></iframe> 21 22 <script> 23 const frame = frames[0]; 24 const message = "any_message"; 25 const activate = false; 26 27 let capability_to_delegate; 28 29 promise_setup(async () => { 30 capability_to_delegate = await findOneCapabilitySupportingDelegation(); 31 assert_true(!!capability_to_delegate, "The user agent supports delegating at least one capability"); 32 }); 33 34 promise_test(async () => { 35 try { 36 await postCapabilityDelegationMessage(frame, message, "/", "blah", activate); 37 assert_unreached(); 38 } catch (exception) { 39 assert_equals(exception.name, "NotSupportedError"); 40 } 41 }, "Delegating an unsupported capability throws an exception"); 42 43 promise_test(async () => { 44 try { 45 await postCapabilityDelegationMessage(frame, message, "*", capability_to_delegate, activate); 46 assert_unreached(); 47 } catch (exception) { 48 assert_equals(exception.name, "NotAllowedError"); 49 } 50 }, "Delegating to targetOrigin='*' throws an exception"); 51 52 promise_test(async () => { 53 try { 54 await postCapabilityDelegationMessage(frame, message, "/", capability_to_delegate, activate); 55 assert_unreached(); 56 } catch (exception) { 57 assert_equals(exception.name, "NotAllowedError"); 58 } 59 }, "Delegating without user activation throws an exception"); 60 </script>