1<?xml version="1.0" encoding="UTF-8"?> 2<html xmlns="http://www.w3.org/1999/xhtml"> 3<head> 4<style> 5.block { 6 width: 100px; 7 height: 100px; 8 background-color: green; 9} 10</style> 11<script src="resources/print.js"></script> 12<script> 13function test() 14{ 15 if (window.layoutTestController) 16 layoutTestController.dumpAsText(); 17 18 if (document.getElementById('block').offsetWidth == 100) 19 print("PASS", "green"); 20 else 21 print("FAIL", "red"); 22} 23</script> 24</head> 25<body onload="test()"> 26<div id="block" class="block"></div> 27<script> 28function beforeLoadFunc() 29{ 30 event.preventDefault(); 31} 32 33document.addEventListener("beforeload", beforeLoadFunc, true); 34 35var pi = document.createProcessingInstruction("xml-stylesheet", "type=\"text/css\" href=\"resources/fail.css\""); 36document.insertBefore(pi, document.documentElement); 37</script> 38<hr/> 39<div id="console"></div> 40</body> 41</html> 42