未验证 提交 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 () { ...@@ -1686,26 +1686,34 @@ describe('threadWorkerTest', function () {
a message that cannot be serialized. The event handler is executed in the host thread a message that cannot be serialized. The event handler is executed in the host thread
*/ */
it('threadWorker_onmessageerror_test_002', 0, async function (done) { it('threadWorker_onmessageerror_test_002', 0, async function (done) {
var ss = new worker.ThreadWorker("entry/ets/workers/newworker_008.js") try {
var res = 0 var ss = new worker.ThreadWorker("entry/ets/workers/newworker_008.js")
var flag = false var res = 0
var flag = false
ss.onexit = function() { ss.onexit = function() {
flag = true flag = true
res++ res++
} }
ss.onmessageerror = function (e) {
ss.onmessageerror = function (e) { flag = true
flag = true res++
} }
function foo() { var message = Symbol(42)
} ss.postMessage(message)
ss.postMessage(foo) } catch (error) {
while (!flag) { while (!flag) {
await promiseCase() 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 // check new second worker is ok
......
...@@ -1025,15 +1025,20 @@ describe('WorkerTest', function () { ...@@ -1025,15 +1025,20 @@ describe('WorkerTest', function () {
ss.onmessageerror = function (e) { ss.onmessageerror = function (e) {
flag = true 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) { while (!flag) {
await promiseCase() await promiseCase()
} }
expect(res).assertEqual(1) expect(res).assertEqual(2)
done() done()
}) })
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册