qt5base-lts/tests/manual/wasm/qwasmwindow/qwasmwindow_harness.html
Mikolaj Boc a1704ee6aa Correctly focus WASM windows on show
Since first requestActivate may happen before the window div is
actually displayed on-screen, we need to sync Qt's activation state
with DOM as soon as DOM element becomes visible. Focusing an
invisible element is impossible.

Fixes: QTBUG-79934
Change-Id: I04cf9b4ead006c9b8b135b3b6967d7938c581833
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2023-06-09 14:05:06 +02:00

73 lines
2.7 KiB
HTML

<!doctype html>
<head>
<script type="text/javascript" src="qwasmwindow_harness.js"></script>
<script>
(async () => {
const instance = await createQtAppInstance({});
window.instance = instance;
const testSandbox = document.createElement('div');
testSandbox.id = 'test-sandbox';
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';
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
};
})();
</script>
</head>
<body>
</body>