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

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

Issue 1950613005: Fixes tests that use internals.observeGC to work with Ignition. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes comments and fixes more tests. Created 4 years, 7 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 <script src="../../resources/observeGC.js"></script>
3 <body> 4 <body>
4 <script> 5 <script>
5 description('Tests that the window.internals.observeGC hook works.'); 6 description('Tests that the window.internals.observeGC hook works.');
6 7
7 shouldBe('typeof window.internals.observeGC', '"function"', 8 shouldBe('typeof window.internals.observeGC', '"function"',
8 'this test requires window.internals'); 9 'this test requires window.internals');
9 10
10 // "Generic Kid's Movie III": ... where nobody dies. 11 // "Generic Kid's Movie III": ... where nobody dies.
11 12
12 var valueA = {}; 13 var valueA = {};
13 observationA = internals.observeGC(valueA); 14 observationA = observeGC(() => {return valueA;});
14 gc(); 15 gc();
15 shouldBeFalse('observationA.wasCollected'); 16 shouldBeFalse('observationA.wasCollected');
16 // value ineligible for GC should not be flagged as collected 17 // value ineligible for GC should not be flagged as collected
17 valueA = null; 18 valueA = null;
18 observationA = null; 19 observationA = null;
19 20
20 // "Romeo and GCuliet": Romeo JavaScript finds G.uliet C.apulet and dies. 21 // "Romeo and GCuliet": Romeo JavaScript finds G.uliet C.apulet and dies.
21 22
22 var valueB = {}; 23 var valueB = {};
23 observationB = internals.observeGC(valueB); 24 observationB = observeGC(() => {return valueB;});
24 valueB = null; 25 valueB = null;
25 gc(); 26 gc();
26 shouldBeTrue('observationB.wasCollected'); 27 shouldBeTrue('observationB.wasCollected');
27 // value eligible for GC should be flagged as collected 28 // value eligible for GC should be flagged as collected
28 observationB = null; 29 observationB = null;
29 30
30 // "One DOM Tree Hill": A family struggles with the loss of 31 // "One DOM Tree Hill": A family struggles with the loss of
31 // innocence. And a DOM node. 32 // innocence. And a DOM node.
32 33
33 var valueC = document.createElement('div'); 34 var valueC = document.createElement('div');
34 observationC = internals.observeGC(valueC); 35 observationC = observeGC(() => {return valueC;});
35 valueC = null; 36 valueC = null;
36 gc(); 37 gc();
37 shouldBeTrue('observationC.wasCollected'); 38 shouldBeTrue('observationC.wasCollected');
38 // DOM node eligible for GC should be flagged as collected 39 // DOM node eligible for GC should be flagged as collected
39 observationC = null; 40 observationC = null;
40 41
41 // Now, movies that failed: 42 // Now, movies that failed:
42 43
43 shouldThrow('internals.observeGC(undefined)', '"TypeError: value to observe is n ull or undefined"'); 44 shouldThrow('observeGC(() => {return undefined;})',
44 shouldThrow('internals.observeGC(null)', '"TypeError: value to observe is null o r undefined"'); 45 '"TypeError: value to observe is null or undefined"');
46 shouldThrow('observeGC(() => {return null;})',
47 '"TypeError: value to observe is null or undefined"');
45 48
46 // Try to create objects and observers that will die at once 49 // Try to create objects and observers that will die at once
47 50
48 var valueD = {}; 51 var valueD = {};
49 var observerD = internals.observeGC(valueD); 52 var observerD = observeGC(() => {return valueD;});
50 valueD.observer = observerD; 53 valueD.observer = observerD;
51 observerD.observed = valueD; 54 observerD.observed = valueD;
52 valueD = observerD = null; 55 valueD = observerD = null;
53 gc(); 56 gc();
54 testPassed('did not crash'); 57 testPassed('did not crash');
55 58
56 var successfullyParsed = true; 59 var successfullyParsed = true;
57 </script> 60 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698