-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[test] add webview-cdt-ext for #6004
- Loading branch information
Showing
8 changed files
with
160 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
var webview = document.createElement('webview') | ||
var devtools = document.createElement('webview') | ||
|
||
webview.setAttribute('style', 'height:300px;width:100%;position:absolute') | ||
devtools.setAttribute('style', 'height:300px;width:100%;position:absolute;top:300px') | ||
devtools.setAttribute('partition', 'trusted') | ||
|
||
var container = global.contentDocument.getElementById('container') | ||
container.appendChild(webview) | ||
container.appendChild(devtools) | ||
|
||
webview.src = 'https://mp.weixin.qq.com' | ||
|
||
const devtoolsviewCommit = () => { | ||
devtools.removeEventListener('loadcommit', devtoolsviewCommit) | ||
webview.showDevTools(true, devtools) | ||
} | ||
devtools.addEventListener('loadcommit', devtoolsviewCommit) | ||
|
||
devtools.src = 'about:blank' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<html> | ||
<head> | ||
</head> | ||
<body> | ||
custom | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<html> | ||
<head> | ||
</head> | ||
<body> | ||
<script > | ||
"use strict" | ||
|
||
// 添加appdata pannel | ||
chrome.devtools.panels.create("custom", | ||
"", | ||
"custom.html", | ||
function(panel) { | ||
//console.log(panel) | ||
} | ||
) | ||
|
||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "wechat devtools extension", | ||
"version": "1.1", | ||
"description": "Extends the Developer Tools, adding appdata", | ||
"devtools_page": "devtools.html", | ||
"webview": { | ||
"partitions": [ | ||
{ | ||
"name": "trusted", | ||
"accessible_resources": [ | ||
"<all_urls>" | ||
] | ||
} | ||
] | ||
}, | ||
"manifest_version": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html lang="zh-CN"> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
</head> | ||
|
||
<body> | ||
<div id="container" class="container"></div> | ||
<script src="index.js"></script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
global.contentDocument = document | ||
require('./core.js') | ||
|
||
if (nw.App.argv.indexOf('inspect') !== -1) { | ||
nw.Window.open('about:blank', { | ||
"show": false, | ||
"width": 799, | ||
"height": 799, | ||
}, (inspectWin) => { | ||
inspectWin.maximize() | ||
inspectWin.window.location = "chrome://inspect/#devices" | ||
inspectWin.show() | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"main": "index.html", | ||
"name": "canhuang", | ||
"appname": "canhuang", | ||
"version": "1.0.0", | ||
"window": { | ||
"title": "v1.0.0", | ||
"toolbar": true, | ||
"width": 800, | ||
"height": 800, | ||
"frame": true | ||
}, | ||
"chromium-args": "-load-extension=./extensions/ -ignore-certificate-errors", | ||
"webview": { | ||
"partitions": [ | ||
{ | ||
"name": "trusted", | ||
"accessible_resources": [ | ||
"<all_urls>" | ||
] | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import time | ||
import os | ||
import urlparse, urllib | ||
import sys | ||
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | ||
from nw_util import * | ||
|
||
def path2url(path): | ||
return urlparse.urljoin( | ||
'file:', urllib.pathname2url(path)) | ||
|
||
from selenium import webdriver | ||
from selenium.webdriver.chrome.options import Options | ||
|
||
testdir = os.path.dirname(os.path.abspath(__file__)) | ||
os.chdir(testdir) | ||
|
||
chrome_options = Options() | ||
chrome_options.add_argument("nwapp=" + testdir) | ||
chrome_options.add_experimental_option("windowTypes", ["webview"]) | ||
|
||
capabilities = {"pageLoadStrategy": "none"} | ||
|
||
driver = webdriver.Chrome(executable_path=os.environ['CHROMEDRIVER'], chrome_options=chrome_options, desired_capabilities = capabilities, service_log_path="log", service_args=["--verbose"]) | ||
driver.implicitly_wait(5) | ||
time.sleep(1) | ||
try: | ||
print driver.current_url | ||
#driver.find_element_by_id('testbtn').click() | ||
timeout = 10 | ||
found = False | ||
while timeout > 0 and not found: | ||
for handle in driver.window_handles: | ||
driver.switch_to_window(handle) | ||
if driver.current_url.startswith('chrome-devtools://'): | ||
found = True | ||
break | ||
timeout = timeout - 1 | ||
time.sleep(1) | ||
assert(found) | ||
driver.execute_script('UI.inspectorView._tabbedPane.selectTab(UI.inspectorView._tabbedPane._tabs[9]._id)') | ||
title = driver.execute_script('return UI.inspectorView._tabbedPane._tabs[9]._title') | ||
print "title:", title | ||
assert('custom' in title) | ||
finally: | ||
driver.quit() |