summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/navigation-timing/test-timing-attributes-order.html
blob: 5e885ea7ec3f360d6fd6ba060d49773713fef228 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>window.performance.timing attribute ordering on a simple navigation</title>
        <link rel="author" title="Microsoft" href="http://www.microsoft.com/" />
        <link rel="help" href="http://www.w3.org/TR/navigation-timing/#sec-navigation-timing-interface"/>
        <link rel="help" href="http://www.w3.org/TR/navigation-timing/#sec-navigation-info-interface"/>
        <script src="/resources/testharness.js"></script>
        <script src="/resources/testharnessreport.js"></script>
        <script src="/common/performance-timeline-utils.js"></script>
        <script src="resources/webperftestharness.js"></script>
        <script>
            setup({explicit_done: true});

            test_namespace('timing');

            var step = 1;
            function onload_test()
            {
                if (step === 1 && window.performance === undefined)
                {
                    // avoid script errors
                    done();
                    return;
                }

                var navigation_frame = document.getElementById("frameContext").contentWindow;
                performanceNamespace = navigation_frame.performance;
                switch (step)
                {
                    case 1:
                    {
                        navigation_frame.location.href = '/navigation-timing/resources/blank_page_green.html';
                        step++;
                        break;
                    }
                case 2:
                    {
                        test_namespace('navigation', true);

                        //
                        // Tests
                        //
                        test_equals(performanceNamespace.navigation.type,
                                performanceNamespace.navigation.TYPE_NAVIGATE,
                                'window.performance.navigation.type == TYPE_NAVIGATE');

                        // navigiation must be non-0
                        test_timing_greater_than('navigationStart', 0);

                        // must be no redirection for this test case
                        test_timing_equals('redirectStart', 0);
                        test_timing_equals('redirectEnd', 0);

                        // validate attribute ordering
                        test_timing_order('fetchStart', 'navigationStart');
                        test_timing_order('domainLookupStart', 'fetchStart');
                        test_timing_order('domainLookupEnd', 'domainLookupStart');
                        test_timing_order('connectStart', 'domainLookupEnd');
                        test_timing_order('connectEnd', 'connectStart');
                        test_timing_order('requestStart', 'connectEnd');
                        test_timing_order('responseStart', 'requestStart');
                        test_timing_order('responseEnd', 'responseStart');
                        test_timing_order('domLoading', 'fetchStart');
                        test_timing_order('domInteractive', 'responseEnd');
                        test_timing_order('domContentLoadedEventStart', 'domInteractive');
                        test_timing_order('domContentLoadedEventEnd', 'domContentLoadedEventStart');
                        test_timing_order('domComplete', 'domContentLoadedEventEnd');
                        test_timing_order('loadEventStart', 'domContentLoadedEventEnd');
                        test_timing_order('loadEventEnd', 'loadEventStart');

                        // setup requires the frame to have a previous page with an onunload event handler.
                        test_timing_order('unloadEventStart', 'navigationStart');
                        test_timing_order('unloadEventEnd', 'unloadEventStart');

                        step++;
                        done();
                        break;
                    }
                    default:
                        break;
                }
            }
        </script>
    </head>
    <body>
        <h1>Description</h1>
        <p>This test validates the ordering of the window.performance.timing attributes.</p>

        <p>This page should be loaded with a yellow background frame below which contains an unload event
           handler.</p>

        <p>After the page loads, the frame is navigated to a new blank page with a green background.  At this point, the navigation timeline is verified</p>

        <p>This test passes if all of the checks to the frame.window.performance.timing attributes are
           correct throughout the navigation scenario and the frame below ends with a green background.
           Otherwise, this test fails.</p>

        <h1>Setup</h1>

        <div id="log"></div>
        <br />
        <iframe id="frameContext"
                onload="/* Need to make sure we don't examine loadEventEnd
                           until after the load event has finished firing */
                        step_timeout(onload_test, 0);"
                src="resources/blank_page_unload.html"
                style="width: 250px; height: 250px;"></iframe>
    </body>
</html>