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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/harness/internals-observe-gc.html

Issue 1999013002: Modify some gc related layout tests to work with Ignition. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed more comments. Created 4 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
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <script src="../../resources/js-test.js"></script> 2 <script src="../../resources/js-test.js"></script>
3 <body> 3 <body>
4 <script> 4 <script>
5 description('Tests that the window.internals.observeGC hook works.'); 5 description('Tests that the window.internals.observeGC hook works.');
6 6
7 shouldBe('typeof window.internals.observeGC', '"function"', 7 shouldBe('typeof window.internals.observeGC', '"function"',
8 'this test requires window.internals'); 8 'this test requires window.internals');
9 9
10 // "Generic Kid's Movie III": ... where nobody dies. 10 // "Generic Kid's Movie III": ... where nobody dies.
11 11
12 var valueA = {}; 12 // Do initialization work in an inner function to avoid references to
13 // Do not pass the object directly to observeGC function. This may 13 // objects remaining live on this function's stack frame.
14 // remain live on this function's stack preventing GC from collecting 14 // (http://crbug.com/595672/).
15 // it. Accessing the object inside an inner function will prevent any 15 var valueA, observationA;
16 // unneeded references on this function's stack. 16 (function () {
17 observationA = internals.observeGC((() => {return valueA;})()); 17 valueA = {};
18 observationA = internals.observeGC(valueA);
19 })();
20
18 gc(); 21 gc();
19 shouldBeFalse('observationA.wasCollected'); 22 shouldBeFalse('observationA.wasCollected');
20 // value ineligible for GC should not be flagged as collected 23 // value ineligible for GC should not be flagged as collected
21 valueA = null; 24 valueA = null;
22 observationA = null; 25 observationA = null;
23 26
24 // "Romeo and GCuliet": Romeo JavaScript finds G.uliet C.apulet and dies. 27 // "Romeo and GCuliet": Romeo JavaScript finds G.uliet C.apulet and dies.
25 28
26 var valueB = {}; 29 // Do initialization work in an inner function to avoid references to
27 // Do not pass the object directly to observeGC function. This may 30 // objects remaining live on this function's stack frame.
28 // remain live on this function's stack preventing GC from collecting 31 // (http://crbug.com/595672/).
29 // it. Accessing the object inside an inner function will prevent any 32 var observationB;
30 // unneeded references on this function's stack. 33 (function() {
31 observationB = internals.observeGC((() => {return valueB;})()); 34 var valueB = {};
32 valueB = null; 35 observationB = internals.observeGC(valueB);
36 })();
37
33 gc(); 38 gc();
34 shouldBeTrue('observationB.wasCollected'); 39 shouldBeTrue('observationB.wasCollected');
35 // value eligible for GC should be flagged as collected 40 // value eligible for GC should be flagged as collected
36 observationB = null; 41 observationB = null;
37 42
38 // "One DOM Tree Hill": A family struggles with the loss of 43 // "One DOM Tree Hill": A family struggles with the loss of
39 // innocence. And a DOM node. 44 // innocence. And a DOM node.
40 45
41 var valueC = document.createElement('div'); 46 // Do initialization work in an inner function to avoid references to
42 // Do not pass the object directly to observeGC function. This may 47 // objects remaining live on this function's stack frame.
43 // remain live on this function's stack preventing GC from collecting 48 // (http://crbug.com/595672/).
44 // it. Accessing the object inside an inner function will prevent any 49 var observationC;
45 // unneeded references on this function's stack. 50 (function() {
46 observationC = internals.observeGC((() => {return valueC;})()); 51 var valueC = document.createElement('div');
47 valueC = null; 52 observationC = internals.observeGC(valueC);
53 })();
54
48 gc(); 55 gc();
49 shouldBeTrue('observationC.wasCollected'); 56 shouldBeTrue('observationC.wasCollected');
50 // DOM node eligible for GC should be flagged as collected 57 // DOM node eligible for GC should be flagged as collected
51 observationC = null; 58 observationC = null;
52 59
53 // Now, movies that failed: 60 // Now, movies that failed:
54 61
55 shouldThrow('internals.observeGC(undefined)', 62 shouldThrow('internals.observeGC(undefined)',
56 '"TypeError: value to observe is null or undefined"'); 63 '"TypeError: value to observe is null or undefined"');
57 shouldThrow('internals.observeGC(null)', 64 shouldThrow('internals.observeGC(null)',
58 '"TypeError: value to observe is null or undefined"'); 65 '"TypeError: value to observe is null or undefined"');
59 66
60 // Try to create objects and observers that will die at once 67 // Try to create objects and observers that will die at once
61 68
62 var valueD = {}; 69 // Do initialization work in an inner function to avoid references to
63 // Do not pass the object directly to observeGC function. This may 70 // objects remaining live on this function's stack frame.
64 // remain live on this function's stack preventing GC from collecting 71 // (http://crbug.com/595672/).
65 // it. Accessing the object inside an inner function will prevent any 72 (function() {
66 // unneeded references on this function's stack. 73 var valueD = {};
67 var observerD = internals.observeGC((() => {return valueD;})()); 74 var observerD = internals.observeGC(valueD);
68 valueD.observer = observerD; 75 valueD.observer = observerD;
69 observerD.observed = valueD; 76 observerD.observed = valueD;
70 valueD = observerD = null; 77 })();
78
71 gc(); 79 gc();
72 testPassed('did not crash'); 80 testPassed('did not crash');
73 81
74 var successfullyParsed = true; 82 var successfullyParsed = true;
75 </script> 83 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698