test_isinheritableproperty.html (2113B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=699592 5 --> 6 <head> 7 <title>Test for InspectorUtils::isInheritedProperty</title> 8 <script src="/tests/SimpleTest/SimpleTest.js"></script> 9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 10 <style> 11 @property --css-registered-inherits { 12 syntax: "*"; 13 inherits: true; 14 } 15 @property --css-registered-no-inherits { 16 syntax: "*"; 17 inherits: false; 18 } 19 </style> 20 <script> 21 CSS.registerProperty({ 22 name: "--js-registered-inherits", 23 syntax: "*", 24 inherits: true, 25 }); 26 CSS.registerProperty({ 27 name: "--js-registered-no-inherits", 28 syntax: "*", 29 inherits: false, 30 }); 31 </script> 32 </head> 33 <body> 34 <pre id="test"> 35 <script type="application/javascript"> 36 37 function do_test() { 38 const isInherited = (name) => 39 SpecialPowers.InspectorUtils.isInheritedProperty(document, name); 40 41 is(isInherited("font-size"), true, "font-size is inherited."); 42 is(isInherited("min-width"), false, "min-width is not inherited."); 43 44 is(isInherited("font"), true, "shorthand font property is inherited."); 45 46 is(isInherited("border"), false, "shorthand border property not inherited."); 47 is(isInherited("garbage"), false, "Unknown property isn't inherited."); 48 49 info("Checking isInheritedProperty result on custom properties"); 50 is(isInherited("--unregistered-var"),true, 51 "Unregistered custom property is inherited." 52 ); 53 is( 54 isInherited("--css-registered-inherits"), 55 true, 56 "Returns true for @property that inherits" 57 ); 58 is( 59 isInherited("--css-registered-no-inherits"), 60 false, 61 "Returns false for @property that does not inherits" 62 ); 63 is( 64 isInherited("--js-registered-inherits"), 65 true, 66 "Returns true for property registered in JS that inherits" 67 ); 68 is( 69 isInherited("--js-registered-no-inherits"), 70 false, 71 "Returns false for property registered in JS that does not inherits" 72 ); 73 74 SimpleTest.finish(); 75 } 76 77 SimpleTest.waitForExplicitFinish(); 78 addLoadEvent(do_test); 79 80 81 </script> 82 </pre> 83 </body> 84 </html>