From 99b22ae0aa088b01902ff7601d4f6fac03b580b8 Mon Sep 17 00:00:00 2001 From: Huan LI Date: Sun, 12 Nov 2017 21:56:59 +0800 Subject: [PATCH] log innerHTML when onLogin not ready --- src/puppet-web/bridge.ts | 11 ++++++++--- src/puppet-web/event.ts | 4 +++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/puppet-web/bridge.ts b/src/puppet-web/bridge.ts index 2710b046..f72859d0 100644 --- a/src/puppet-web/bridge.ts +++ b/src/puppet-web/bridge.ts @@ -681,14 +681,19 @@ export class Bridge extends EventEmitter { return Misc.unescapeHtml(matches[1]) } + public async innerHTML(): Promise { + const html = await this.evaluate(() => { + return document.body.innerHTML + }) + return html + } + /** * Throw if there's a blocked message */ public async testBlockedMessage(text?: string): Promise { if (!text) { - text = await this.evaluate(() => { - return document.body.innerHTML - }) + text = await this.innerHTML() } if (!text) { throw new Error('testBlockedMessage() no text found!') diff --git a/src/puppet-web/event.ts b/src/puppet-web/event.ts index 2ce01508..542320db 100644 --- a/src/puppet-web/event.ts +++ b/src/puppet-web/event.ts @@ -126,7 +126,9 @@ async function onLogin(this: PuppetWeb, memo: string, ttl = 30): Promise { this.userId = await this.bridge.getUserName() if (!this.userId) { - log.verbose('PuppetWebEvent', 'onLogin: browser not fully loaded(ttl=%d), retry later', ttl) + log.verbose('PuppetWebEvent', 'onLogin() browser not fully loaded(ttl=%d), retry later', ttl) + const html = this.bridge.innerHTML() + log.silly('PuppetWebEvent', 'onLogin() innerHTML: %s', html) setTimeout(onLogin.bind(this, memo, ttl - 1), TTL_WAIT_MILLISECONDS) return } -- GitLab