Skip to content

Commit b711f36

Browse files
committed
test: electron platfrom tests
1 parent 31c6708 commit b711f36

File tree

3 files changed

+495
-0
lines changed

3 files changed

+495
-0
lines changed

test/UnitTestSuite.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ define(function (require, exports, module) {
2323

2424
require("spec/Phoenix-platform-test");
2525
require("spec/Tauri-platform-test");
26+
require("spec/Electron-platform-test");
2627
require("spec/trust-ring-test");
2728
require("spec/utframework-suite-test");
2829
require("spec/Async-test");
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Test electron apis accessible</title>
6+
<script>
7+
const ELECTRON_TEST_SIGNAL_KEY = 'ELECTRON_PLATFORM_TEST_SIGNAL';
8+
9+
async function init() {
10+
if (window.electronAPI) {
11+
// Get our window label
12+
const myLabel = await window.electronAPI.getCurrentWindowLabel();
13+
14+
// Signal to parent that we're ready
15+
await window.electronAPI.putItem(ELECTRON_TEST_SIGNAL_KEY, myLabel);
16+
17+
// Poll for close signal from parent
18+
const pollInterval = setInterval(async () => {
19+
try {
20+
const items = await window.electronAPI.getAllItems();
21+
if (items && items[`${ELECTRON_TEST_SIGNAL_KEY}_CLOSE_${myLabel}`]) {
22+
clearInterval(pollInterval);
23+
// Clear the close signal
24+
await window.electronAPI.putItem(`${ELECTRON_TEST_SIGNAL_KEY}_CLOSE_${myLabel}`, null);
25+
// Close ourselves
26+
await window.electronAPI.closeWindow();
27+
}
28+
} catch (e) {
29+
// Ignore errors
30+
}
31+
}, 100);
32+
}
33+
}
34+
35+
// Initialize when DOM is ready
36+
if (document.readyState === 'loading') {
37+
document.addEventListener('DOMContentLoaded', init);
38+
} else {
39+
init();
40+
}
41+
</script>
42+
</head>
43+
<body>
44+
sending event with electron api...
45+
</body>
46+
</html>

0 commit comments

Comments
 (0)