browser_inspector_infobar_01.js (2980B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 "use strict"; 6 7 // Check the position and text content of the highlighter nodeinfo bar. 8 9 const TEST_URI = URL_ROOT + "doc_inspector_infobar_01.html"; 10 11 add_task(async function () { 12 const { inspector, highlighterTestFront } = 13 await openInspectorForURL(TEST_URI); 14 15 const testData = [ 16 { 17 selector: "#top", 18 position: "bottom", 19 tag: "div", 20 id: "top", 21 classes: ".class1.class2", 22 dims: "500" + " \u00D7 " + "100", 23 arrowed: true, 24 }, 25 { 26 selector: "#vertical", 27 position: "top", 28 tag: "div", 29 id: "vertical", 30 classes: "", 31 arrowed: false, 32 // No dims as they will vary between computers 33 }, 34 { 35 selector: "#bottom", 36 position: "top", 37 tag: "div", 38 id: "bottom", 39 classes: "", 40 dims: "500" + " \u00D7 " + "100", 41 arrowed: true, 42 }, 43 { 44 selector: "body", 45 position: "bottom", 46 tag: "body", 47 classes: "", 48 arrowed: true, 49 // No dims as they will vary between computers 50 }, 51 { 52 selector: "clipPath", 53 position: "bottom", 54 tag: "clipPath", 55 id: "clip", 56 classes: "", 57 arrowed: false, 58 // No dims as element is not displayed and we just want to test tag name 59 }, 60 ]; 61 62 for (const currTest of testData) { 63 await testPosition(currTest, inspector, highlighterTestFront); 64 } 65 }); 66 67 async function testPosition(test, inspector, highlighterTestFront) { 68 info("Testing " + test.selector); 69 70 await selectAndHighlightNode(test.selector, inspector); 71 72 const position = await highlighterTestFront.getHighlighterNodeAttribute( 73 "box-model-infobar-container", 74 "position" 75 ); 76 is(position, test.position, "Node " + test.selector + ": position matches"); 77 78 const tag = await highlighterTestFront.getHighlighterNodeTextContent( 79 "box-model-infobar-tagname" 80 ); 81 is(tag, test.tag, "node " + test.selector + ": tagName matches."); 82 83 if (test.id) { 84 const id = await highlighterTestFront.getHighlighterNodeTextContent( 85 "box-model-infobar-id" 86 ); 87 is(id, "#" + test.id, "node " + test.selector + ": id matches."); 88 } 89 90 const classes = await highlighterTestFront.getHighlighterNodeTextContent( 91 "box-model-infobar-classes" 92 ); 93 is(classes, test.classes, "node " + test.selector + ": classes match."); 94 95 const arrowed = !(await highlighterTestFront.getHighlighterNodeAttribute( 96 "box-model-infobar-container", 97 "hide-arrow" 98 )); 99 100 is( 101 arrowed, 102 test.arrowed, 103 "node " + test.selector + ": arrow visibility match." 104 ); 105 106 if (test.dims) { 107 const dims = await highlighterTestFront.getHighlighterNodeTextContent( 108 "box-model-infobar-dimensions" 109 ); 110 is(dims, test.dims, "node " + test.selector + ": dims match."); 111 } 112 }