mirror of
				https://github.com/LadybirdBrowser/ladybird.git
				synced 2025-10-31 05:10:57 +00:00 
			
		
		
		
	 8286f8b996
			
		
	
	
		8286f8b996
		
	
	
	
	
		
			
			Object.defineProperty() can now change the attributes of a property already on the object. Internally this becomes a shape transition with the TransitionType::Configure. Such transitions don't expand the property storage capacity, but rather simply keep attributes up to date when generating a property table.
		
			
				
	
	
		
			47 lines
		
	
	
	
		
			1.3 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			47 lines
		
	
	
	
		
			1.3 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| function assert(x) { if (!x) throw 1; }
 | |
| 
 | |
| try {
 | |
| 
 | |
|     var o = {};
 | |
|     Object.defineProperty(o, "foo", { value: 1, writable: false, enumerable: false });
 | |
| 
 | |
|     assert(o.foo === 1);
 | |
|     o.foo = 2;
 | |
|     assert(o.foo === 1);
 | |
| 
 | |
|     var d = Object.getOwnPropertyDescriptor(o, "foo");
 | |
|     assert(d.configurable === false);
 | |
|     assert(d.enumerable === false);
 | |
|     assert(d.writable === false);
 | |
|     assert(d.value === 1);
 | |
| 
 | |
|     Object.defineProperty(o, "bar", { value: "hi", writable: true, enumerable: true });
 | |
| 
 | |
|     assert(o.bar === "hi");
 | |
|     o.bar = "ho";
 | |
|     assert(o.bar === "ho");
 | |
| 
 | |
|     d = Object.getOwnPropertyDescriptor(o, "bar");
 | |
|     assert(d.configurable === false);
 | |
|     assert(d.enumerable === true);
 | |
|     assert(d.writable === true);
 | |
|     assert(d.value === "ho");
 | |
| 
 | |
|     try {
 | |
|         Object.defineProperty(o, "bar", { value: "xx", enumerable: false });
 | |
|     } catch (e) {
 | |
|         assert(e.name === "TypeError");
 | |
|     }
 | |
| 
 | |
|     Object.defineProperty(o, "baz", { value: 9, configurable: true, writable: false });
 | |
|     Object.defineProperty(o, "baz", { configurable: true, writable: true });
 | |
| 
 | |
|     d = Object.getOwnPropertyDescriptor(o, "baz");
 | |
|     assert(d.configurable === true);
 | |
|     assert(d.writable === true);
 | |
|     assert(d.value === 9);
 | |
| 
 | |
|     console.log("PASS");
 | |
| } catch (e) {
 | |
|     console.log(e)
 | |
| }
 |