tools/scripts/cdb/cdb.py
aozhiwei 9a03838b78 1
2019-10-12 17:56:23 +08:00

38 lines
1022 B
Python

import os
import time
import pychrome
import cmd
import scriptmgr
#os.environ['DEBUG'] = '1'
def initTab(tab):
tab.call_method("Network.enable", maxPostDataSize=65536)
tab.call_method("Page.enable")
tab.call_method("Page.getResourceTree")
tab.call_method("Profiler.enable")
tab.call_method("Runtime.enable")
tab.call_method("Debugger.enable", maxScriptsCacheSzie=1000000)
tab.call_method("DOM.enable")
tab.call_method("CSS.enable")
tab.call_method("Overlay.enable")
tab.call_method("Log.enable")
browser = pychrome.Browser(url="http://192.168.100.137:9223")
tab = browser.new_tab()
scriptmgr = scriptmgr.ScriptMgr(tab)
tab.start()
initTab(tab)
tab.call_method("Page.navigate", url="http://localhost:7456/", _timeout=5)
time.sleep(3)
cmd.processCmd(browser, tab, scriptmgr, 'b jcmatchvs.js:102')
while True:
cmdline= input('(cdb)').strip()
try:
cmd.processCmd(browser, tab, scriptmgr, cmdline)
time.sleep(0.1)
except Exception as e:
print(e)