Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(621)

Side by Side Diff: LayoutTests/fast/dom/navigator-detached-no-crash.html

Issue 301193006: Update navigator-detached-no-crash.html test to use testharness.js. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@navigator.languages
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | LayoutTests/fast/dom/navigator-detached-no-crash-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html>
1 <html> 2 <html>
3 <head>
4 <script src="../../resources/testharness.js"></script>
5 <script src="../../resources/testharnessreport.js"></script>
6 </head>
7 <body>
8 <iframe id="subframe" src="about:blank"></iframe>
2 <script> 9 <script>
3 if (window.testRunner) {
4 testRunner.dumpAsText();
5 testRunner.waitUntilDone();
6 }
7 10
8 function log(strings) { 11 var testNavigatorOnLoad = async_test("Accessing a navigator object that just got removed does not crash.")
9 var node = document.getElementById('result'); 12 var testNavigatorLater = async_test("Accessing a navigator object that got remov ed some time before does not crash.")
10 for (var i in strings) { 13
11 node.innerHTML += strings[i] + '<br>'; 14 // Reference to the removed navigator object.
15 var oldNav = null;
16
17 function gc() {
18 if (window.GCController) {
19 GCController.collect();
20 } else {
21 for (var i = 0; i < 10000; i++) {
22 var s = new String("abc");
23 }
12 } 24 }
13 } 25 }
14 26
15 function gc() 27 function test() {
16 { 28 // Keep a reference of the navigator and remove the frame.
17 if (window.GCController) { 29 oldNav = window.frames[0].navigator;
18 GCController.collect(); 30 var frame = document.getElementById("subframe");
19 } else { 31 frame.parentNode.removeChild(frame);
20 for (var i = 0; i < 10000; i++) {
21 var s = new String("abc");
22 }
23 }
24 }
25 32
26 var old_nav;
27
28 function test() {
29 // remember the old navigator
30 old_nav = window.frames[0].navigator;
31 // detach the old navigator
32 var p = document.getElementById("subframe");
33 p.parentNode.removeChild(p);
34 if (window.GCController) 33 if (window.GCController)
35 window.GCController.collect(); 34 window.GCController.collect();
36 35
37 // Check once immediately 36 // Check once immediately.
38 check_navigator(); 37 testNavigatorOnLoad.step(function() {
38 check_navigator();
39 });
40 testNavigatorOnLoad.done();
39 41
40 gc(); 42 gc();
41 43
42 // Check one more time later, when the frame is likely to be destroyed. 44 // Check one more time later, when the frame is likely to be destroyed.
43 setTimeout(check_navigator_and_done, 200); 45 setTimeout(function() {
44 } 46 testNavigatorLater.step(function() {
45 47 check_navigator();
46 function check_navigator_and_done() { 48 });
47 check_navigator(); 49 testNavigatorLater.done();
48 if (window.testRunner) 50 }, 200);
eseidel 2014/06/02 18:23:16 Bleh! setTimeout tests = flaky tests. :(
mlamouri (slow - plz ping) 2014/06/02 18:36:09 I entirely agree but I prefer to not change the be
49 testRunner.notifyDone();
50 } 51 }
51 52
52 function check_navigator() { 53 function check_navigator() {
53 var strings = [ ]; 54 for (p in oldNav) {
54 for (p in old_nav) { 55 if (typeof oldNav[p] == 'function') {
55 if (p == 'geolocation' || p == 'webkitGetUserMedia') // Don't include Geoloc ation or the Media Stream API functions until most platforms have support.
56 continue;
57
58 if (typeof old_nav[p] == 'function') {
59 try { 56 try {
60 var v = old_nav[p](); 57 var v = oldNav[p]();
61 // no crash, it is ok 58 assert_true(true, "navigator."+p+"() is OK");
62 strings.push("navigator."+p+"() is OK");
63 } catch(err) { 59 } catch(err) {
64 // navigator.registerXXX will throw on invalid input. 60 // Some function call will asserts, the assert shouldn't make the test f ail.
65 strings.push("navigator."+p+"() threw err "+err); 61 assert_true(true, "navigator."+p+"() threw err "+err);
66 } 62 }
67 } else { 63 } else {
68 var v = old_nav[p]; 64 var v = oldNav[p];
69 // no crash, it is ok. 65 assert_true(true, "navigator."+p+" is OK");
70 strings.push("navigator."+p+" is OK");
71 } 66 }
72 } 67 }
73 strings.sort();
74 log(strings);
75 } 68 }
76 69
70 window.addEventListener('load', test);
71
77 </script> 72 </script>
78 <body onload="test()"> 73
79 This tests that the navigator object of a deleted frame is disconnected
80 properly. Accessing fields or methods shouldn't crash the browser.
81 <br>
82 <iframe id="subframe" src="about:blank"></iframe>
83 <button onclick="check_navigator()">Check Navigator</button><br>
84 <div id="result"></div>
85 </body> 74 </body>
86 </html> 75 </html>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/fast/dom/navigator-detached-no-crash-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698