browser_rules_css-compatibility-add-rename-rule.js (3028B)
1 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */ 2 /* Any copyright is dedicated to the Public Domain. 3 http://creativecommons.org/publicdomain/zero/1.0/ */ 4 5 "use strict"; 6 7 // Test - Add and rename rules 8 // Test the correctness of the compatibility 9 // status when the incompatible rules are added 10 // or renamed to another universally compatible 11 // rule 12 13 const TEST_URI = ` 14 <style> 15 body { 16 user-select: none; 17 text-decoration-skip: none; 18 clip: auto; 19 } 20 </style> 21 <body> 22 </body>`; 23 24 const TEST_DATA_INITIAL = [ 25 { 26 selector: "body", 27 rules: [ 28 {}, 29 { 30 "user-select": { 31 value: "none", 32 expected: COMPATIBILITY_TOOLTIP_MESSAGE.default, 33 }, 34 "text-decoration-skip": { 35 value: "none", 36 expected: COMPATIBILITY_TOOLTIP_MESSAGE.experimental, 37 }, 38 clip: { 39 value: "auto", 40 expected: COMPATIBILITY_TOOLTIP_MESSAGE["deprecated-supported"], 41 }, 42 }, 43 ], 44 }, 45 ]; 46 47 const TEST_DATA_ADD_RULE = [ 48 { 49 selector: "body", 50 rules: [ 51 { 52 "-moz-float-edge": { 53 value: "content-box", 54 expected: COMPATIBILITY_TOOLTIP_MESSAGE.deprecated, 55 }, 56 }, 57 { 58 "user-select": { 59 value: "none", 60 expected: COMPATIBILITY_TOOLTIP_MESSAGE.default, 61 }, 62 "text-decoration-skip": { 63 value: "none", 64 expected: COMPATIBILITY_TOOLTIP_MESSAGE.experimental, 65 }, 66 clip: { 67 value: "auto", 68 expected: COMPATIBILITY_TOOLTIP_MESSAGE["deprecated-supported"], 69 }, 70 }, 71 ], 72 }, 73 ]; 74 75 const TEST_DATA_RENAME_RULE = [ 76 { 77 selector: "body", 78 rules: [ 79 { 80 "-moz-float-edge": { 81 value: "content-box", 82 expected: COMPATIBILITY_TOOLTIP_MESSAGE.deprecated, 83 }, 84 }, 85 { 86 "background-color": { 87 value: "green", 88 }, 89 "text-decoration-skip": { 90 value: "none", 91 expected: COMPATIBILITY_TOOLTIP_MESSAGE.experimental, 92 }, 93 clip: { 94 value: "auto", 95 expected: COMPATIBILITY_TOOLTIP_MESSAGE["deprecated-supported"], 96 }, 97 }, 98 ], 99 }, 100 ]; 101 102 add_task(async function () { 103 await addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); 104 const { inspector, view } = await openRuleView(); 105 106 const userSelect = { "user-select": "none" }; 107 const backgroundColor = { "background-color": "green" }; 108 109 info("Check initial compatibility issues"); 110 await runCSSCompatibilityTests(view, inspector, TEST_DATA_INITIAL); 111 112 info( 113 "Add an inheritable incompatible rule and check the compatibility status" 114 ); 115 await addProperty(view, 0, "-moz-float-edge", "content-box"); 116 await runCSSCompatibilityTests(view, inspector, TEST_DATA_ADD_RULE); 117 118 info("Rename user-select to color and check the compatibility status"); 119 await updateDeclaration(view, 1, userSelect, backgroundColor); 120 await runCSSCompatibilityTests(view, inspector, TEST_DATA_RENAME_RULE); 121 });