browser_rules_variables_04-valid-chars.js (1262B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 // Test for variables in rule view. 7 8 const TEST_URI = URL_ROOT + "doc_variables_4.html"; 9 10 add_task(async function () { 11 await addTab(TEST_URI); 12 const { inspector, view } = await openRuleView(); 13 14 await testNumber(inspector, view); 15 await testDash(inspector, view); 16 }); 17 18 async function testNumber(inspector, view) { 19 info( 20 "Test support for allowing vars that begin with a number" + 21 "Format: --10: 10px;" 22 ); 23 24 await selectNode("#a", inspector); 25 26 const upperCaseVarEl = getRuleViewProperty( 27 view, 28 "#a", 29 "font-size" 30 ).valueSpan.querySelector(".inspector-variable"); 31 32 is( 33 upperCaseVarEl.dataset.variable, 34 "10px", 35 "variable that starts with a number is valid" 36 ); 37 } 38 39 async function testDash(inspector, view) { 40 info( 41 "Test support for allowing vars that begin with a dash" + 42 "Format: ---blue: blue;" 43 ); 44 45 await selectNode("#b", inspector); 46 47 const upperCaseVarEl = getRuleViewProperty( 48 view, 49 "#b", 50 "color" 51 ).valueSpan.querySelector(".inspector-variable"); 52 53 is( 54 upperCaseVarEl.dataset.variable, 55 "blue", 56 "variable that starts with a dash is valid" 57 ); 58 }