Manual tests using Selenium for browser automation were not properly updated when we introduced changes to our DOM structure. Update the testing framework so elements in shadow root may be properly accessed. Change-Id: I45f7d63a833bc48a3b68016ef937e56425bdff87 Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
81 lines
3.0 KiB
HTML
81 lines
3.0 KiB
HTML
<!doctype html>
|
|
|
|
<head>
|
|
<script type="text/javascript" src="qwasmwindow_harness.js"></script>
|
|
<script>
|
|
(async () => {
|
|
const instance = await qwasmwindow_harness_entry({});
|
|
window.instance = instance;
|
|
|
|
const testSandbox = document.createElement('div');
|
|
testSandbox.id = 'test-sandbox';
|
|
let nextScreenId = 1;
|
|
document.body.appendChild(testSandbox);
|
|
|
|
const eventList = [];
|
|
|
|
const makeSizedDiv = (left, top, width, height) => {
|
|
const screenDiv = document.createElement('div');
|
|
|
|
screenDiv.style.left = `${left}px`;
|
|
screenDiv.style.top = `${top}px`;
|
|
screenDiv.style.width = `${width}px`;
|
|
screenDiv.style.height = `${height}px`;
|
|
screenDiv.style.backgroundColor = 'lightblue';
|
|
screenDiv.id = `test-screen-${nextScreenId++}`;
|
|
|
|
return screenDiv;
|
|
};
|
|
|
|
window.testSupport = {
|
|
initializeScreenWithFixedPosition: (left, top, width, height) => {
|
|
const screenDiv = makeSizedDiv(left, top, width, height);
|
|
testSandbox.appendChild(screenDiv);
|
|
|
|
screenDiv.style.position = 'fixed';
|
|
instance.qtAddContainerElement(screenDiv);
|
|
|
|
return screenDiv;
|
|
},
|
|
initializeScreenWithRelativePosition: (left, top, width, height) => {
|
|
const screenDiv = makeSizedDiv(left, top, width, height);
|
|
testSandbox.appendChild(screenDiv);
|
|
|
|
screenDiv.style.position = 'relative';
|
|
instance.qtAddContainerElement(screenDiv);
|
|
|
|
return screenDiv;
|
|
},
|
|
initializeScreenInScrollContainer:
|
|
(scrollWidth, scrollHeight, left, top, width, height) => {
|
|
const scrollContainer = document.createElement('div');
|
|
scrollContainer.style.height = `${scrollHeight}px`;
|
|
scrollContainer.style.width = `${scrollWidth}px`;
|
|
testSandbox.appendChild(scrollContainer);
|
|
|
|
const screenDiv = makeSizedDiv(left, top, width, height);
|
|
scrollContainer.appendChild(screenDiv);
|
|
screenDiv.style.position = 'relative';
|
|
|
|
instance.qtAddContainerElement(screenDiv);
|
|
|
|
return [scrollContainer, screenDiv];
|
|
},
|
|
reportEvent: event => {
|
|
eventList.push(event);
|
|
},
|
|
events: () => eventList,
|
|
hitTestPoint: (x, y, screenId) => {
|
|
return document
|
|
.querySelector(`#${screenId}`)
|
|
.querySelector('#qt-shadow-container')
|
|
.shadowRoot.elementsFromPoint(x, y);
|
|
}
|
|
};
|
|
})();
|
|
</script>
|
|
</head>
|
|
|
|
<body>
|
|
</body>
|