pageswap-ctor.html (2467B)
1 <!doctype html> 2 <title> PageSwapEvent constructor</title> 3 <link rel="help" href="https://html.spec.whatwg.org/multipage/nav-history-apis.html#the-pageswapevent-interface"> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <div id="log"></div> 7 <script> 8 test(function() { 9 var e = new PageSwapEvent("something"); 10 assert_true(e instanceof PageSwapEvent); 11 assert_equals(e.type, "something"); 12 assert_equals(e.viewTransition, null); 13 assert_equals(e.activation, null); 14 }, "Constructing pageswap event"); 15 16 test(function() { 17 var e = new PageSwapEvent("pageswap"); 18 assert_true(e instanceof PageSwapEvent); 19 assert_equals(e.type, "pageswap"); 20 assert_equals(e.viewTransition, null); 21 assert_equals(e.activation, null); 22 }, "Constructing pageswap event with a custom name"); 23 24 test(function() { 25 var e = new PageSwapEvent("pageswap", {}); 26 assert_true(e instanceof PageSwapEvent); 27 assert_equals(e.type, "pageswap"); 28 assert_equals(e.viewTransition, null); 29 assert_equals(e.activation, null); 30 }, "Constructing pageswap event with empty dictionary"); 31 32 test(function() { 33 var e = new PageSwapEvent("pageswap", {viewTransition: null}); 34 assert_true(e instanceof PageSwapEvent); 35 assert_equals(e.type, "pageswap"); 36 assert_equals(e.viewTransition, null); 37 assert_equals(e.activation, null); 38 }, "Constructing pageswap event with a null viewTransition"); 39 promise_test(async t => { 40 const viewTransition = document.startViewTransition(); 41 var e = new PageSwapEvent("pageswap", {viewTransition}); 42 assert_true(e instanceof PageSwapEvent); 43 assert_equals(e.type, "pageswap"); 44 assert_equals(e.viewTransition, viewTransition); 45 viewTransition.skipTransition(); 46 await promise_rejects_dom(t, "AbortError", viewTransition.ready); 47 }, "Constructing pageswap event with a viewTransition"); 48 promise_test(async t => { 49 const viewTransition = document.startViewTransition(); 50 var e = new PageSwapEvent("pageswap", {viewTransition, activation: navigation.activation}); 51 assert_true(e instanceof PageSwapEvent); 52 assert_equals(e.type, "pageswap"); 53 assert_equals(e.viewTransition, viewTransition); 54 assert_equals(e.activation, navigation.activation); 55 viewTransition.skipTransition(); 56 await promise_rejects_dom(t, "AbortError", viewTransition.ready); 57 }, "Constructing pageswap event with a viewTransition and activation"); 58 </script>