test_computed_style_in_created_document.html (1348B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>Test for bug 1398619</title> 5 <script src="/tests/SimpleTest/SimpleTest.js"></script> 6 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"> 7 </head> 8 <body> 9 <script> 10 SimpleTest.waitForExplicitFinish(); 11 let referenceFontSize = getComputedStyle(document.body).fontSize; 12 13 function checkComputedStyle(desc, doc) { 14 try { 15 let fontSize = getComputedStyle(doc.body).fontSize; 16 is(fontSize, referenceFontSize, `${desc}: get computed font-size`); 17 } catch (e) { 18 ok(false, `${desc}: fail to get computed font-size, ${e}`); 19 } 20 } 21 22 async function runTest() { 23 // DOMParser 24 { 25 let parser = new DOMParser(); 26 let doc = parser.parseFromString("<body>", "text/html"); 27 checkComputedStyle("DOMParser", doc); 28 } 29 // DOMImplementation 30 { 31 let doc = document.implementation.createHTMLDocument(""); 32 checkComputedStyle("DOMImplementation", doc); 33 } 34 // XMLHttpRequest 35 { 36 let xhr = new XMLHttpRequest(); 37 xhr.open("GET", "empty.html"); 38 xhr.responseType = "document"; 39 let promise = new Promise(resolve => { 40 xhr.onload = resolve; 41 }); 42 xhr.send(); 43 await promise; 44 checkComputedStyle("XMLHttpRequest", xhr.responseXML); 45 } 46 } 47 runTest() 48 .catch(e => ok(false, `Exception: ${e}`)) 49 .then(() => SimpleTest.finish()); 50 </script> 51 </body> 52 </html>