참고소스 수정본
This commit is contained in:
1
참고/playwright-main/tests/assets/worker/import-me.js
Normal file
1
참고/playwright-main/tests/assets/worker/import-me.js
Normal file
@@ -0,0 +1 @@
|
||||
console.log("hello from import-me.js");
|
||||
@@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Remote importScripts Test</title>
|
||||
</head>
|
||||
<html>
|
||||
<div id="status">-</div>
|
||||
<script>
|
||||
new Worker('worker-http-import.js').addEventListener("message", ({ data }) => {
|
||||
document.getElementById("status").innerText = data;
|
||||
});
|
||||
</script>
|
||||
</html>
|
||||
</html>
|
||||
@@ -0,0 +1,4 @@
|
||||
console.log("hello from worker-http-import.js");
|
||||
importScripts("./import-me.js")
|
||||
console.log("successfully imported");
|
||||
self.postMessage("finished");
|
||||
14
참고/playwright-main/tests/assets/worker/worker.html
Normal file
14
참고/playwright-main/tests/assets/worker/worker.html
Normal file
@@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Worker test</title>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
var worker = new Worker('worker.js');
|
||||
worker.onmessage = function(message) {
|
||||
console.log(message.data);
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
16
참고/playwright-main/tests/assets/worker/worker.js
Normal file
16
참고/playwright-main/tests/assets/worker/worker.js
Normal file
@@ -0,0 +1,16 @@
|
||||
console.log('hello from the worker');
|
||||
|
||||
function workerFunction() {
|
||||
return 'worker function result';
|
||||
}
|
||||
|
||||
self.addEventListener('message', event => {
|
||||
console.log('got this data: ' + event.data);
|
||||
});
|
||||
|
||||
(async function() {
|
||||
while (true) {
|
||||
self.postMessage(workerFunction.toString());
|
||||
await new Promise(x => setTimeout(x, 100));
|
||||
}
|
||||
})();
|
||||
Reference in New Issue
Block a user