tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

zero-named-elements.html (2062B)


      1 <!DOCTYPE html>
      2 <title>View transitions: pageswap navigationactivation for replace navigations</title>
      3 <link rel="help" href="https://drafts.csswg.org/css-view-transitions-2/">
      4 <link rel="author" href="mailto:khushalsagar@chromium.org">
      5 <script src="/resources/testharness.js"></script>
      6 <script src="/resources/testharnessreport.js"></script>
      7 <style>
      8 @view-transition {
      9  navigation: auto;
     10 }
     11 
     12 html {
     13  view-transition-name: none;
     14 }
     15 </style>
     16 <script>
     17 const expectedUrl = location.href + '?new';
     18 
     19 const params = new URLSearchParams(location.search);
     20 // The page the popup navigates to.
     21 const is_new_page = params.has('new');
     22 // The initial page in the popup.
     23 const is_popup_page = params.has('popup');
     24 // The test page itself.
     25 const is_test_page = !is_popup_page && !is_new_page;
     26 
     27 const channel = new BroadcastChannel("testchannel");
     28 
     29 if (is_test_page) {
     30  const expectedEvents = ["pageswap", "pagehide", "pagereveal", "finished"];
     31 
     32  promise_test(async t => {
     33    let popup;
     34    onload = () => {
     35      window.events = [];
     36      popup = window.open("?popup");
     37      t.add_cleanup(() => popup.close());
     38    };
     39 
     40    await new Promise(resolve => {
     41      channel.addEventListener(
     42        "message", t.step_func(async (e) => {
     43          if (e.data === "nav") {
     44            assert_array_equals(window.events, expectedEvents, 'incorrect event order');
     45            popup.close();
     46            resolve();
     47          }
     48      }));
     49    });
     50  }, `transition finishes with no named elements`);
     51 } else if (is_popup_page) {
     52  onload = () => {
     53    requestAnimationFrame(() => requestAnimationFrame(() => {
     54      location.replace(location.href.split('?')[0] + '?new');
     55    }));
     56 
     57    onpageswap = (e) => {
     58      window.opener.events.push("pageswap");
     59    };
     60 
     61    onpagehide = () => {
     62      window.opener.events.push("pagehide");
     63    };
     64  };
     65 } else if (is_new_page) {
     66  onpagereveal = (e) => {
     67    window.opener.events.push("pagereveal");
     68    e.viewTransition.finished.then(() => {
     69      window.opener.events.push("finished");
     70      channel.postMessage("nav");
     71    });
     72  }
     73 }
     74 </script>