未验证 提交 8856bcf1 编写于 作者: O openharmony_ci 提交者: Gitee

!7242 Modify the problem of Worker XTS.

Merge pull request !7242 from hwx1130639/master
......@@ -1686,26 +1686,34 @@ describe('threadWorkerTest', function () {
a message that cannot be serialized. The event handler is executed in the host thread
*/
it('threadWorker_onmessageerror_test_002', 0, async function (done) {
var ss = new worker.ThreadWorker("entry/ets/workers/newworker_008.js")
var res = 0
var flag = false
ss.onexit = function() {
flag = true
res++
}
ss.onmessageerror = function (e) {
flag = true
}
function foo() {
}
ss.postMessage(foo)
while (!flag) {
await promiseCase()
try {
var ss = new worker.ThreadWorker("entry/ets/workers/newworker_008.js")
var res = 0
var flag = false
ss.onexit = function() {
flag = true
res++
}
ss.onmessageerror = function (e) {
flag = true
res++
}
var message = Symbol(42)
ss.postMessage(message)
} catch (error) {
while (!flag) {
await promiseCase()
}
expect(error.name).assertEqual("BusinessError")
expect(error.message).assertEqual("Serializing an uncaught exception failed, failed to serialize message.")
flag = false
ss.terminate()
while (!flag) {
await promiseCase()
}
expect(res).assertEqual(2)
done()
}
expect(res).assertEqual(1)
done()
})
// check new second worker is ok
......
......@@ -1025,15 +1025,20 @@ describe('WorkerTest', function () {
ss.onmessageerror = function (e) {
flag = true
res++
}
function foo() {
var message = Symbol(42)
ss.postMessage(message)
while (!flag) {
await promiseCase()
}
ss.postMessage(foo)
flag = false
ss.terminate()
while (!flag) {
await promiseCase()
}
expect(res).assertEqual(1)
expect(res).assertEqual(2)
done()
})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册