tor-browser

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

event-source-timing.html (1109B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4 <meta charset="utf-8" />
      5 <meta name="timeout" content="long">
      6 <title>Resource Timing: EventSource timing behavior</title>
      7 <script src="/resources/testharness.js"></script>
      8 <script src="/resources/testharnessreport.js"></script>
      9 <script src="/resource-timing/resources/observe-entry.js"></script>
     10 </head>
     11 </script>
     12 <script>
     13    async_test(t => {
     14        const repetitions = 2;
     15        const url = new URL(`/eventsource/resources/message.py`, location.href);
     16        const eventSource = new EventSource(url);
     17        let messages = 0;
     18        t.add_cleanup(() => eventSource.close());
     19        eventSource.addEventListener('message', () => {
     20            ++messages;
     21        })
     22 
     23        new PerformanceObserver(() => {
     24            const entries = performance.getEntriesByName(url);
     25            assert_greater_than_equal(entries.length, messages - 1);
     26            if (entries.length === repetitions)
     27                t.done();
     28        }).observe({type: 'resource'});
     29    }, "ResourceTiming for EventSource should reflect number of re-connections to source");
     30 </script>
     31 </body>
     32 </html>