OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <meta charset="utf-8" /> | 4 <meta charset="utf-8" /> |
5 <title>window.performance.memory in dedicated workers</title> | 5 <title>window.performance.memory in dedicated workers</title> |
6 <script src="/w3c/resources/testharness.js"></script> | 6 <script src="/w3c/resources/testharness.js"></script> |
7 <script src="/w3c/resources/testharnessreport.js"></script> | 7 <script src="/w3c/resources/testharnessreport.js"></script> |
8 <link rel="stylesheet" href="/w3c/resources/testharness.css" /> | 8 <link rel="stylesheet" href="/w3c/resources/testharness.css" /> |
9 <script> | 9 <script> |
10 | 10 |
11 var tests = [ | 11 var tests = [ |
12 '"performance" in self;', | 12 '"performance" in self;', |
13 '"memory" in self.performance;', | 13 '"memory" in self.performance;', |
14 'JSON.stringify(self.performance.memory);', | 14 ('JSON.stringify(' + |
| 15 '{jsHeapSizeLimit: self.performance.memory.jsHeapSizeLimit,' + |
| 16 ' totalJSHeapSize: self.performance.memory.totalJSHeapSize,' + |
| 17 ' usedJSHeapSize: self.performance.memory.usedJSHeapSize});') |
15 ]; | 18 ]; |
16 | 19 |
17 var t = async_test('window.performance.memory in dedicated workers'); | 20 var t = async_test('window.performance.memory in dedicated workers'); |
18 t.step(function() { | 21 t.step(function() { |
19 var worker = new Worker("/w3c/webperf/resources/worker.js"); | 22 var worker = new Worker("/w3c/webperf/resources/worker.js"); |
20 worker.postMessage(tests); | 23 worker.postMessage(tests); |
21 | 24 |
22 worker.onmessage = t.step_func(function(event) { | 25 worker.onmessage = t.step_func(function(event) { |
23 var results = event.data; | 26 var results = event.data; |
24 assert_equals(results.length, 3); | 27 assert_equals(results.length, 3); |
25 assert_true(results[0], "self.performance is defined"); | 28 assert_true(results[0], "self.performance is defined"); |
26 assert_true(results[1], "self.performance.memory is defined"); | 29 assert_true(results[1], "self.performance.memory is defined"); |
27 var jsHeap = JSON.parse(results[2]); | 30 var jsHeap = JSON.parse(results[2]); |
28 assert_greater_than_equal(jsHeap.jsHeapSizeLimit, jsHeap.totalJSHeapSize
, "jsHeapSizeLimit should be no less than totalJSHeapSize", {}); | 31 assert_greater_than_equal(jsHeap.jsHeapSizeLimit, jsHeap.totalJSHeapSize
, "jsHeapSizeLimit should be no less than totalJSHeapSize", {}); |
29 assert_greater_than_equal(jsHeap.totalJSHeapSize, jsHeap.usedJSHeapSize,
"totalJSHeapSize should be no less than usedJSHeapSize", {}); | 32 assert_greater_than_equal(jsHeap.totalJSHeapSize, jsHeap.usedJSHeapSize,
"totalJSHeapSize should be no less than usedJSHeapSize", {}); |
30 t.done(); | 33 t.done(); |
31 }); | 34 }); |
32 }); | 35 }); |
33 | 36 |
34 </script> | 37 </script> |
35 </head> | 38 </head> |
36 <body> | 39 <body> |
37 <h1>Description</h1> | 40 <h1>Description</h1> |
38 <p>This test validates that performance.memory exists in dedicated workers </p> | 41 <p>This test validates that performance.memory exists in dedicated workers </p> |
39 | 42 |
40 <div id="log"></div> | 43 <div id="log"></div> |
41 | 44 |
42 </body> | 45 </body> |
43 </html> | 46 </html> |
OLD | NEW |