Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
.Veneno.
wechaty
提交
b71deefc
W
wechaty
项目概览
.Veneno.
/
wechaty
与 Fork 源项目一致
Fork自
wechaty / wechaty
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
W
wechaty
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b71deefc
编写于
11月 13, 2016
作者:
Huan (李卓桓)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix watchdog unit test error
上级
2a886f2a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
18 addition
and
22 deletion
+18
-22
src/puppet-web/event.ts
src/puppet-web/event.ts
+14
-20
src/puppet-web/watchdog.ts
src/puppet-web/watchdog.ts
+3
-2
test/puppet-web/watchdog.spec.ts
test/puppet-web/watchdog.spec.ts
+1
-0
未找到文件。
src/puppet-web/event.ts
浏览文件 @
b71deefc
...
...
@@ -48,26 +48,21 @@ export const Event = {
,
onServerMessage
}
async
function
onBrowserDead
(
this
:
PuppetWeb
,
e
):
Promise
<
void
>
{
async
function
onBrowserDead
(
this
:
PuppetWeb
,
e
:
Error
):
Promise
<
void
>
{
log
.
verbose
(
'
PuppetWebEvent
'
,
'
onBrowserDead(%s)
'
,
e
&&
e
.
message
||
e
)
if
(
!
this
.
browser
||
!
this
.
bridge
)
{
throw
new
Error
(
'
browser or bridge instance not exist in PuppetWeb instance
'
)
throw
new
Error
(
'
onBrowserDead()
browser or bridge instance not exist in PuppetWeb instance
'
)
}
const
browser
=
this
.
browser
// because this function is async, so maybe entry more than one times.
// guard by variable: isBrowserBirthing to prevent the 2nd time entrance.
// if (this.browser.targetState() !== 'open'
// || this.browser.currentState() === 'opening') {
log
.
verbose
(
'
PuppetWebEvent
'
,
'
onBrowserDead() Browser:state target(%s) current(%s) stable(%s)
'
,
this
.
browser
.
state
.
target
()
,
this
.
browser
.
state
.
current
()
,
this
.
browser
.
state
.
stable
()
)
// if ( (browser.state.current() === 'open' && browser.state.inprocess())
// || browser.state.target() !== 'open'
if
(
browser
.
state
.
target
()
===
'
close
'
||
browser
.
state
.
inprocess
())
{
if
(
this
.
browser
.
state
.
target
()
===
'
close
'
||
this
.
browser
.
state
.
inprocess
())
{
log
.
verbose
(
'
PuppetWebEvent
'
,
'
onBrowserDead() will do nothing because %s, or %s
'
// , 'browser.state.target() !== open'
// , 'browser.state.current() === open & inprocess'
,
'
browser.state.target() === close
'
,
'
browser.state.inprocess()
'
)
...
...
@@ -85,15 +80,14 @@ async function onBrowserDead(this: PuppetWeb, e): Promise<void> {
try
{
await
this
.
browser
.
quit
()
.
catch
(
e
=>
{
log
.
warn
(
'
PuppetWebEvent
'
,
'
onBrowserDead() onBrowserDead.quit() exception: %s
'
,
e
.
message
)
})
log
.
verbose
(
'
PuppetWebEvent
'
,
'
onBrowserDead() browser.quit() done
'
)
// if (browser.state.target() !== 'open') {
// log.warn('PuppetWebEvent', 'onBrowserDead() will not init browser because browser.state.target(%s) !== open'
// , browser.state.target()
// )
if
(
browser
.
state
.
target
()
===
'
close
'
)
{
log
.
warn
(
'
PuppetWebEvent
'
,
'
onBrowserDead() will not init browser because browser.state.target(%s) is `close`
'
,
browser
.
state
.
target
()
if
(
this
.
browser
.
state
.
target
()
===
'
close
'
)
{
log
.
warn
(
'
PuppetWebEvent
'
,
'
onBrowserDead() will not init browser because browser.state.target(%s)
'
,
this
.
browser
.
state
.
target
()
)
return
}
...
...
src/puppet-web/watchdog.ts
浏览文件 @
b71deefc
...
...
@@ -113,12 +113,13 @@ function setWatchDogTimer(this: PuppetWeb, timeout, feed) {
}
function
watchDogReset
(
timeout
,
lastFeed
)
{
log
.
verbose
(
'
PuppetWebWatchdog
'
,
'
watchDogReset(
) timeout %d
'
,
timeout
)
const
e
=
new
Error
(
'
watchdog reset after
'
log
.
verbose
(
'
PuppetWebWatchdog
'
,
'
watchDogReset(
%d, %s)
'
,
timeout
,
lastFeed
)
const
e
=
new
Error
(
'
watch
DogReset() watch
dog reset after
'
+
Math
.
floor
(
timeout
/
1000
)
+
'
seconds, last feed:
'
+
'
[
'
+
lastFeed
+
'
]
'
)
log
.
verbose
(
'
PuppetWebWatchdog
'
,
e
.
message
)
this
.
emit
(
'
error
'
,
e
)
return
Event
.
onBrowserDead
.
call
(
this
,
e
)
}
...
...
test/puppet-web/watchdog.spec.ts
浏览文件 @
b71deefc
...
...
@@ -33,6 +33,7 @@ test('timer', async t => {
await
pw
.
quit
()
pw
.
state
.
target
(
'
live
'
)
pw
.
browser
.
state
.
target
(
'
open
'
)
const
savedLevel
=
log
.
level
()
if
(
log
.
level
()
===
'
info
'
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录