browser_rules_class_panel_content.js (2794B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 // Test that class panel shows the right content when selecting various nodes. 7 8 // This array contains the list of test cases. Each test case contains these properties: 9 // - {String} inputClassName The className on a node 10 // - {Array} expectedClasses The expected list of classes in the class panel 11 const TEST_ARRAY = [ 12 { 13 inputClassName: "", 14 expectedClasses: [], 15 }, 16 { 17 inputClassName: " a a a a a a a a a", 18 expectedClasses: ["a"], 19 }, 20 { 21 inputClassName: "c1 c2 c3 c4 c5", 22 expectedClasses: ["c1", "c2", "c3", "c4", "c5"], 23 }, 24 { 25 inputClassName: "a a b b c c a a b b c c", 26 expectedClasses: ["a", "b", "c"], 27 }, 28 { 29 inputClassName: 30 "ajdhfkasjhdkjashdkjghaskdgkauhkbdhvliashdlghaslidghasldgliashdglhasli", 31 expectedClasses: [ 32 "ajdhfkasjhdkjashdkjghaskdgkauhkbdhvliashdlghaslidghasldgliashdglhasli", 33 ], 34 }, 35 { 36 inputClassName: 37 "c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 " + 38 "c10 c11 c12 c13 c14 c15 c16 c17 c18 c19 " + 39 "c20 c21 c22 c23 c24 c25 c26 c27 c28 c29 " + 40 "c30 c31 c32 c33 c34 c35 c36 c37 c38 c39 " + 41 "c40 c41 c42 c43 c44 c45 c46 c47 c48 c49", 42 expectedClasses: [ 43 "c0", 44 "c1", 45 "c2", 46 "c3", 47 "c4", 48 "c5", 49 "c6", 50 "c7", 51 "c8", 52 "c9", 53 "c10", 54 "c11", 55 "c12", 56 "c13", 57 "c14", 58 "c15", 59 "c16", 60 "c17", 61 "c18", 62 "c19", 63 "c20", 64 "c21", 65 "c22", 66 "c23", 67 "c24", 68 "c25", 69 "c26", 70 "c27", 71 "c28", 72 "c29", 73 "c30", 74 "c31", 75 "c32", 76 "c33", 77 "c34", 78 "c35", 79 "c36", 80 "c37", 81 "c38", 82 "c39", 83 "c40", 84 "c41", 85 "c42", 86 "c43", 87 "c44", 88 "c45", 89 "c46", 90 "c47", 91 "c48", 92 "c49", 93 ], 94 }, 95 { 96 inputClassName: " \n \n class1 \t class2 \t\tclass3\t", 97 expectedClasses: ["class1", "class2", "class3"], 98 }, 99 ]; 100 101 add_task(async function () { 102 await addTab("data:text/html;charset=utf-8,<div>"); 103 const { inspector, view } = await openRuleView(); 104 105 await selectNode("div", inspector); 106 107 info("Open the class panel"); 108 view.showClassPanel(); 109 110 for (const { inputClassName, expectedClasses } of TEST_ARRAY) { 111 info(`Apply the '${inputClassName}' className to the node`); 112 const onMutation = inspector.once("markupmutation"); 113 await setContentPageElementAttribute("div", "class", inputClassName); 114 await onMutation; 115 116 info("Check the content of the class panel"); 117 checkClassPanelContent( 118 view, 119 expectedClasses.map(name => { 120 return { name, state: true }; 121 }) 122 ); 123 } 124 });