core: remove some dead code in driver.js (#10491)

This commit is contained in:
Michael Blasingame 2020-03-23 12:36:52 -07:00 коммит произвёл GitHub
Родитель c8b71635d2
Коммит 2b500fc81e
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 0 добавлений и 56 удалений

Просмотреть файл

@ -1191,43 +1191,6 @@ class Driver {
return new LHElement(targetNode, this);
}
/**
* @param {string} selector Selector to find in the DOM
* @return {Promise<Array<LHElement>>} The found elements, or [], resolved in a promise
*/
async querySelectorAll(selector) {
const documentResponse = await this.sendCommand('DOM.getDocument');
const rootNodeId = documentResponse.root.nodeId;
const targetNodeList = await this.sendCommand('DOM.querySelectorAll', {
nodeId: rootNodeId,
selector,
});
/** @type {Array<LHElement>} */
const elementList = [];
targetNodeList.nodeIds.forEach(nodeId => {
if (nodeId !== 0) {
elementList.push(new LHElement({nodeId}, this));
}
});
return elementList;
}
/**
* Returns the flattened list of all DOM elements within the document.
* @param {boolean=} pierce Whether to pierce through shadow trees and iframes.
* True by default.
* @return {Promise<Array<LHElement>>} The found elements, or [], resolved in a promise
*/
getElementsInDocument(pierce = true) {
return this.getNodesInDocument(pierce)
.then(nodes => nodes
.filter(node => node.nodeType === 1)
.map(node => new LHElement({nodeId: node.nodeId}, this))
);
}
/**
* Returns the flattened list of all DOM nodes within the document.
* @param {boolean=} pierce Whether to pierce through shadow trees and iframes.

Просмотреть файл

@ -169,25 +169,6 @@ describe('.querySelector(All)', () => {
const result = await driver.querySelector('meta head');
expect(result).toBeInstanceOf(LHElement);
});
it('returns [] when DOM.querySelectorAll finds no node', async () => {
connectionStub.sendCommand = createMockSendCommandFn()
.mockResponse('DOM.getDocument', {root: {nodeId: 249}})
.mockResponse('DOM.querySelectorAll', {nodeIds: []});
const result = await driver.querySelectorAll('#no.matches');
expect(result).toEqual([]);
});
it('returns element when DOM.querySelectorAll finds node', async () => {
connectionStub.sendCommand = createMockSendCommandFn()
.mockResponse('DOM.getDocument', {root: {nodeId: 249}})
.mockResponse('DOM.querySelectorAll', {nodeIds: [231]});
const result = await driver.querySelectorAll('#no.matches');
expect(result).toHaveLength(1);
expect(result[0]).toBeInstanceOf(LHElement);
});
});
describe('.getObjectProperty', () => {