mirror of
				https://github.com/tc39/test262.git
				synced 2025-10-30 19:24:12 +01:00 
			
		
		
		
	* [javascriptcore-test262-automation] changes from git@github.com:WebKit/webkit.git at sha 949e26452cfa153a7f4afe593da97e2fe9e1b706 on Tue Jul 03 2018 14:35:15 GMT-0400 (Eastern Daylight Time)
		
			
				
	
	
		
			41 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			41 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| // Tests that opaque roots behave correctly during young generation collections
 | |
| 
 | |
| var Element = $vm.Element;
 | |
| var Root = $vm.Root;
 | |
| var getElement = $vm.getElement;
 | |
| 
 | |
| try {
 | |
|     // regression test for bug 160773.  This should not crash.
 | |
|     new (Element.bind());
 | |
| } catch(e) {
 | |
| }
 | |
| 
 | |
| // Create the primary Root.
 | |
| var root = new Root();
 | |
| // This secondary root is for allocating a second Element without overriding 
 | |
| // the primary Root's Element.
 | |
| var otherRoot = new Root();
 | |
| 
 | |
| // Run an Eden collection so that the Root will be in the old gen (and won't be rescanned).
 | |
| edenGC();
 | |
| 
 | |
| // Create a new Element and set a custom property on it.
 | |
| var elem = new Element(root);
 | |
| elem.customProperty = "hello";
 | |
| 
 | |
| // Make the Element unreachable except through the ephemeron with the Root.
 | |
| elem = null;
 | |
| 
 | |
| // Create another Element so that we process the weak handles in block of the original Element.
 | |
| var test = new Element(otherRoot);
 | |
| 
 | |
| // Run another Eden collection to process the weak handles in the Element's block. If opaque roots
 | |
| // are cleared then we'll think that the original Element is dead because the Root won't be in the 
 | |
| // set of opaque roots.
 | |
| edenGC();
 | |
| 
 | |
| // Check if the primary Root's Element exists and has our custom property.
 | |
| var elem = getElement(root);
 | |
| if (elem.customProperty != "hello")
 | |
|     throw new Error("bad value of customProperty: " + elem.customProperty);
 |