|
| 1 | +// Copyright 2025 The Chromium Authors. All rights reserved. |
| 2 | +// Use of this source code is governed by a BSD-style license that can be |
| 3 | +// found in the LICENSE file. |
| 4 | + |
| 5 | +import * as SDK from '../../core/sdk/sdk.js'; |
| 6 | +import * as Protocol from '../../generated/protocol.js'; |
| 7 | +import {createTarget} from '../../testing/EnvironmentHelpers.js'; |
| 8 | +import { |
| 9 | + describeWithMockConnection, |
| 10 | +} from '../../testing/MockConnection.js'; |
| 11 | + |
| 12 | +import * as Elements from './elements.js'; |
| 13 | + |
| 14 | +describeWithMockConnection('ElementsTreeOutline', () => { |
| 15 | + let target: SDK.Target.Target; |
| 16 | + let model: SDK.DOMModel.DOMModel; |
| 17 | + let treeOutline: Elements.ElementsTreeOutline.ElementsTreeOutline; |
| 18 | + |
| 19 | + beforeEach(() => { |
| 20 | + target = createTarget(); |
| 21 | + |
| 22 | + treeOutline = new Elements.ElementsTreeOutline.ElementsTreeOutline(/* omitRootDOMNode */ true); |
| 23 | + treeOutline.wireToDOMModel(target.model(SDK.DOMModel.DOMModel) as SDK.DOMModel.DOMModel); |
| 24 | + |
| 25 | + const modelBeforeAssertion = target.model(SDK.DOMModel.DOMModel); |
| 26 | + assert.exists(modelBeforeAssertion); |
| 27 | + model = modelBeforeAssertion; |
| 28 | + }); |
| 29 | + |
| 30 | + afterEach(() => { |
| 31 | + target.dispose('NO_REASON'); |
| 32 | + }); |
| 33 | + |
| 34 | + it('should include the ::checkmark pseudo element', () => { |
| 35 | + const optionNode = SDK.DOMModel.DOMNode.create(model, null, false, { |
| 36 | + nodeId: 1 as Protocol.DOM.NodeId, |
| 37 | + backendNodeId: 1 as Protocol.DOM.BackendNodeId, |
| 38 | + nodeType: Node.ELEMENT_NODE, |
| 39 | + nodeName: 'option', |
| 40 | + localName: 'option', |
| 41 | + nodeValue: 'An Option', |
| 42 | + childNodeCount: 1, |
| 43 | + pseudoElements: [{ |
| 44 | + parentId: 1 as Protocol.DOM.NodeId, |
| 45 | + nodeId: 2 as Protocol.DOM.NodeId, |
| 46 | + backendNodeId: 2 as Protocol.DOM.BackendNodeId, |
| 47 | + nodeType: Node.ELEMENT_NODE, |
| 48 | + pseudoType: Protocol.DOM.PseudoType.Checkmark, |
| 49 | + pseudoIdentifier: '::checkmark', |
| 50 | + nodeName: '::checkmark', |
| 51 | + localName: '::checkmark', |
| 52 | + nodeValue: '*', |
| 53 | + }], |
| 54 | + }); |
| 55 | + assert.isNotNull(optionNode); |
| 56 | + |
| 57 | + const checkmarkNode = optionNode.checkmarkPseudoElement(); |
| 58 | + assert.isNotNull(checkmarkNode); |
| 59 | + |
| 60 | + treeOutline.rootDOMNode = optionNode; |
| 61 | + assert.isNotNull(treeOutline.findTreeElement(checkmarkNode!)); |
| 62 | + }); |
| 63 | +}); |
0 commit comments