mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 16:42:44 +00:00 
			
		
		
		
	 5949e3c3e8
			
		
	
	
		5949e3c3e8
		
	
	
	
	
		
			
			These allow accessing embeds, forms, images and objects with a given name attribute, and any element with a given id attribute, as top level properties on the global object. It also allows accessing NavigableContainers by target name as top level properties on the global object. The current implementation feels very expensive. It's likely that these values will need smarter caching in the future.
		
			
				
	
	
		
			46 lines
		
	
	
	
		
			1.6 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			46 lines
		
	
	
	
		
			1.6 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
| <script src="../include.js"></script>
 | |
| <embed name="m_bed" src="" type="">
 | |
| <img name="im_adge" src="">
 | |
| <form name="farm"></form>
 | |
| <object name="abject"></object>
 | |
| <div id="fred"></div>
 | |
| <div id="fred"></div>
 | |
| <div id="fred"></div>
 | |
| <div id="george"></div>
 | |
| <script>
 | |
|     test(() => {
 | |
|         let embeds = document.getElementsByTagName("embed");
 | |
|         let images = document.getElementsByTagName("img");
 | |
|         let forms = document.getElementsByTagName("form");
 | |
|         let objects = document.getElementsByTagName("object");
 | |
| 
 | |
|         // NOTE: The whitespace at the beginning of the results is for the empty elements before the test
 | |
|         println(embeds[0] === m_bed);
 | |
|         println(images[0] === im_adge);
 | |
|         println(forms[0] === farm);
 | |
|         println(objects[0] === abject);
 | |
| 
 | |
|         let freds = fred;
 | |
|         println(freds.length === 3)
 | |
|         let divs = document.getElementsByTagName("div");
 | |
|         for (let i = 0; i < 3; ++i) {
 | |
|             if (divs[i] !== freds[i])
 | |
|                 println("FAIL: div " + i);
 | |
|         }
 | |
|         george.innerHTML = "george"
 | |
| 
 | |
|         let also_fred = document.createElement("div");
 | |
|         also_fred.setAttribute("id", "fred");
 | |
|         document.body.appendChild(also_fred);
 | |
|         println(freds.length === 4);
 | |
| 
 | |
|         // divs[3] is george
 | |
|         if (divs[4] !== freds[3])
 | |
|             println("FAILED: dynamic insertion");
 | |
| 
 | |
|         // FIXME: Test the child navigable cases when window.open is less TODO
 | |
|         // let wandow = window.open("about:blank", "the_target");
 | |
|         // println(wandow === the_target);
 | |
|         // FIXME: Test that a child navigable is preferred over an element
 | |
|     });
 | |
| </script>
 |