Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
.www.
wechaty
提交
461dc840
W
wechaty
项目概览
.www.
/
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,发现更多精彩内容 >>
提交
461dc840
编写于
10月 29, 2016
作者:
Huan (李卓桓)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
code clean
上级
d5271cc6
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
9 addition
and
35 deletion
+9
-35
src/puppet-web/browser.ts
src/puppet-web/browser.ts
+5
-16
src/puppet-web/event.ts
src/puppet-web/event.ts
+0
-1
src/puppet-web/puppet-web.ts
src/puppet-web/puppet-web.ts
+4
-18
未找到文件。
src/puppet-web/browser.ts
浏览文件 @
461dc840
...
...
@@ -85,6 +85,7 @@ export class Browser extends EventEmitter {
}
catch
(
e
)
{
log
.
error
(
'
PuppetWebBrowser
'
,
'
init() exception: %s
'
,
e
.
message
)
this
.
state
.
current
(
'
close
'
)
await
this
.
quit
()
throw
e
...
...
@@ -99,7 +100,6 @@ export class Browser extends EventEmitter {
await
this
.
driver
.
get
(
url
)
}
catch
(
e
)
{
log
.
error
(
'
PuppetWebBrowser
'
,
'
open() exception: %s
'
,
e
.
message
)
this
.
dead
(
e
.
message
)
throw
e
}
}
...
...
@@ -117,7 +117,6 @@ export class Browser extends EventEmitter {
await
this
.
quit
()
// if (this.currentState() === 'opening') {
if
(
this
.
state
.
current
()
===
'
open
'
&&
this
.
state
.
inprocess
())
{
log
.
warn
(
'
PuppetWebBrowser
'
,
'
restart() found state.current() === open and inprocess()
'
)
return
...
...
@@ -129,14 +128,12 @@ export class Browser extends EventEmitter {
public
async
quit
():
Promise
<
void
>
{
log
.
verbose
(
'
PuppetWebBrowser
'
,
'
quit()
'
)
// if (this.currentState() === 'closing') {
if
(
this
.
state
.
current
()
===
'
close
'
&&
this
.
state
.
inprocess
())
{
const
e
=
new
Error
(
'
quit() be called when state.current() is close with inprocess()?
'
)
log
.
warn
(
'
PuppetWebBrowser
'
,
e
.
message
)
throw
e
}
// this.currentState('closing')
this
.
state
.
current
(
'
close
'
,
false
)
try
{
...
...
@@ -327,7 +324,6 @@ export class Browser extends EventEmitter {
if
(
forceReason
)
{
dead
=
true
msg
=
forceReason
// } else if (this.targetState() !== 'open') {
}
else
if
(
this
.
state
.
target
()
!==
'
open
'
)
{
dead
=
true
msg
=
'
state.target() not open
'
...
...
@@ -343,15 +339,7 @@ export class Browser extends EventEmitter {
:
''
,
msg
)
// no need to quit here. dead event listener will do this async job, and do it better than here
// this.quit()
// if (this.targetState() !== 'open' || this.currentState() === 'opening') {
// log.warn('PuppetWebBrowser', 'dead() wil not emit `dead` event because currentState is `opening` or targetState !== open')
// } else {
// log.verbose('PuppetWebBrowser', 'dead() emit a `dead` event because %s', msg)
// this.emit('dead', msg)
// }
if
(
this
.
state
.
target
()
===
'
open
'
&&
this
.
state
.
current
()
===
'
open
'
&&
this
.
state
.
stable
()
...
...
@@ -359,10 +347,11 @@ export class Browser extends EventEmitter {
log
.
verbose
(
'
PuppetWebBrowser
'
,
'
dead() emit a `dead` event because %s
'
,
msg
)
this
.
emit
(
'
dead
'
,
msg
)
}
else
{
log
.
warn
(
'
PuppetWebBrowser
'
,
'
dead() wil not emit `dead` event because
%s
'
,
'
state is not `stable open`
'
log
.
warn
(
'
PuppetWebBrowser
'
,
'
dead() wil not emit `dead` event because
states are: target(%s), current(%s), stable(%s)
'
,
this
.
state
.
target
(),
this
.
state
.
current
(),
this
.
state
.
stable
()
)
}
}
return
dead
}
...
...
src/puppet-web/event.ts
浏览文件 @
461dc840
...
...
@@ -82,7 +82,6 @@ async function onBrowserDead(this: PuppetWeb, e): Promise<void> {
await
this
.
browser
.
quit
()
log
.
verbose
(
'
PuppetWebEvent
'
,
'
onBrowserDead() browser quit-ed
'
)
// if (this.browser.targetState() !== 'open') {
if
(
browser
.
state
.
target
()
!==
'
open
'
)
{
log
.
warn
(
'
PuppetWebEvent
'
,
'
onBrowserDead() will not init browser because browser.state.target(%s) !== open
'
,
browser
.
state
.
target
()
...
...
src/puppet-web/puppet-web.ts
浏览文件 @
461dc840
...
...
@@ -105,28 +105,24 @@ export class PuppetWeb extends Puppet {
public
async
quit
():
Promise
<
void
>
{
log
.
verbose
(
'
PuppetWeb
'
,
'
quit()
'
)
// this.targetState('dead')
// XXX should we set `target` to `dead` in `quit()`?
this
.
state
.
target
(
'
dead
'
)
//
this.state.target('dead')
// if (this.currentState() === 'killing') {
if
(
this
.
state
.
current
()
===
'
dead
'
&&
this
.
state
.
inprocess
())
{
// log.warn('PuppetWeb', 'quit() is called but readyState is `disconnecting`?')
log
.
warn
(
'
PuppetWeb
'
,
'
quit() is called but state.current()) is `dead` and inprocess()?
'
)
throw
new
Error
(
'
do not call quit again when quiting
'
)
}
// POISON must feed before
readyState set to "disconnecting"
// POISON must feed before
state set to `dead` & `inprocess`
this
.
emit
(
'
watchdog
'
,
{
data
:
'
PuppetWeb.quit()
'
,
type
:
'
POISON
'
})
// this.currentState('killing')
this
.
state
.
current
(
'
dead
'
,
false
)
// return co.call(this, function* () {
try
{
if
(
this
.
bridge
)
{
// TODO use StateMonitor
...
...
@@ -153,25 +149,15 @@ export class PuppetWeb extends Puppet {
// this.browser = null
}
else
{
log
.
warn
(
'
PuppetWeb
'
,
'
quit() without a browser
'
)
}
// @deprecated 20161004
// log.verbose('PuppetWeb', 'quit() server.quit() this.initAttach(null)')
// await this.initAttach(null)
// this.currentState('dead')
this
.
state
.
current
(
'
dead
'
)
// }).catch(e => { // Reject
}
catch
(
e
)
{
log
.
error
(
'
PuppetWeb
'
,
'
quit() exception: %s
'
,
e
.
message
)
// this.currentState('dead')
this
.
state
.
current
(
'
dead
'
)
throw
e
}
// .then(() => { // Finally, Fail Safe
log
.
verbose
(
'
PuppetWeb
'
,
'
quit() done
'
)
// this.currentState('dead')
this
.
state
.
current
(
'
dead
'
)
// })
}
public
async
initBrowser
():
Promise
<
void
>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录