Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / http / tests / w3c / webperf / submission / Intel / resource-timing / test_resource_timing_store_and_clear_during_callback.html
1 <!DOCTYPE HTML>
2 <html>
3     <head>
4         <meta charset="utf-8" />
5         <title>read and clear resource timing entry in onresourcetimingbufferfull callback</title>
6         <script src="/w3c/webperf/resources/webperftestharnessextension.js"></script>
7         <script>
8             var context = new PerformanceContext(performance);
9             var resource_timing_buffer_size = 1;
10             var global_buffer = [];
11             function store_and_clear()
12             {
13                 var entry_list = context.getEntriesByType('resource');
14                 for (var i = 0; i < entry_list.length; ++i)
15                     global_buffer.push(entry_list[i]);
16                 context.clearResourceTimings();
17             }
18             context.registerResourceTimingBufferFullCallback(store_and_clear);
19             context.setResourceTimingBufferSize(resource_timing_buffer_size);
20         </script>
21         <link rel="author" title="Intel" href="http://www.intel.com/" />
22         <link rel="help" href="http://www.w3.org/TR/resource-timing/#performanceresourcetiming"/>
23         <script src="/w3c/resources/testharness.js"></script>
24         <script src="/w3c/resources/testharnessreport.js"></script>
25         <script src="/w3c/webperf/resources/webperftestharness.js"></script>
26         <script>
27             setup({ explicit_done: true });                
28             function onload_test()
29             {
30                 test_equals(context.getEntriesByType('resource').length, 0, "No entry should be stored in resource timing buffer since it's cleared once an item arrived!");
31                 test_equals(global_buffer.length, 4, "4 resource timing entries should be moved to global buffer!");
32                 done();
33             }
34         </script>
35     </head>
36     <body onload=onload_test()>
37         <h1>Description</h1>
38         <p>This test validates the behavior of read and clear operation in onresourcetimingbufferfull callback of resource timing.</p>
39     </body>
40 </html>