forked from sanyaade-mobiledev/chromium.src
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding more webview browser tests to app_shell_browsertests.
This CL includes the following tests: - WebViewAPITest.AcceptTouchEvents - WebViewAPITest.EmbedderVisibilityChanged - WebViewAPITest.GuestVisibilityChanged - WebViewAPITest.ReloadEmbedder BUG=352293 Review URL: https://codereview.chromium.org/639693005 Cr-Commit-Position: refs/heads/master@{#299243}
- Loading branch information
hanxi
authored and
Commit bot
committed
Oct 11, 2014
1 parent
67387c7
commit fcd89ae
Showing
12 changed files
with
368 additions
and
4 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
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
15 changes: 15 additions & 0 deletions
15
extensions/test/data/web_view/accept_touch_events/guest.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,15 @@ | ||
<!doctype html> | ||
<!-- | ||
* Copyright 2014 The Chromium Authors. All rights reserved. Use of this | ||
* source code is governed by a BSD-style license that can be found in the | ||
* LICENSE file. | ||
--> | ||
<html> | ||
<head> | ||
<script type="text/javascript" src="guest.js"></script> | ||
</head> | ||
<body> | ||
Test guest. | ||
<div id="touch-div"></div> | ||
</body> | ||
</html> |
51 changes: 51 additions & 0 deletions
51
extensions/test/data/web_view/accept_touch_events/guest.js
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,51 @@ | ||
// Copyright 2014 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
var LOG = function(msg) { | ||
window.console.log(msg); | ||
}; | ||
|
||
var touchDiv; | ||
var embedder; | ||
|
||
function init() { | ||
touchDiv = document.createElement('div'); | ||
touchDiv.innerText = 'With touch'; | ||
document.body.appendChild(touchDiv); | ||
} | ||
|
||
function handler() {} | ||
|
||
function onAppCommand(command) { | ||
LOG('onAppCommand, command = ' + command); | ||
switch (command) { | ||
case 'install-touch-handler': | ||
touchDiv.addEventListener('touchstart', handler); | ||
sendMessageToEmbedder('installed-touch-handler'); | ||
break; | ||
case 'uninstall-touch-handler': | ||
touchDiv.removeEventListener('touchstart', handler); | ||
sendMessageToEmbedder('uninstalled-touch-handler'); | ||
break; | ||
} | ||
}; | ||
|
||
function sendMessageToEmbedder(message) { | ||
if (!embedder) { | ||
LOG('no embedder channel to send postMessage'); | ||
return; | ||
} | ||
|
||
embedder.postMessage(JSON.stringify([message]), '*'); | ||
} | ||
|
||
window.addEventListener('message', function(e) { | ||
embedder = e.source; | ||
var data = JSON.parse(e.data); | ||
if (data[0] == 'connect') { | ||
sendMessageToEmbedder('connected'); | ||
} | ||
}); | ||
|
||
window.onload = init; |
12 changes: 12 additions & 0 deletions
12
extensions/test/data/web_view/accept_touch_events/main.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,12 @@ | ||
<!doctype html> | ||
<!-- | ||
* Copyright 2014 The Chromium Authors. All rights reserved. Use of this | ||
* source code is governed by a BSD-style license that can be found in the | ||
* LICENSE file. | ||
--> | ||
<html> | ||
<body> | ||
<div id="webview-tag-container"></div> | ||
<script src="main.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,43 @@ | ||
// Copyright 2014 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
var LOG = function(msg) { | ||
window.console.log(msg); | ||
}; | ||
|
||
var startTest = function() { | ||
var webview = document.querySelector('webview'); | ||
var onLoadStop = function(e) { | ||
webview.contentWindow.postMessage(JSON.stringify(['connect']),'*'); | ||
}; | ||
|
||
webview.addEventListener('loadstop', onLoadStop); | ||
webview.addEventListener('consolemessage', function(e) { | ||
LOG('g: ' + e.message); | ||
}); | ||
webview.partition = 'partition1'; | ||
webview.src = 'guest.html'; | ||
}; | ||
|
||
window.addEventListener('message', function(e) { | ||
var data = JSON.parse(e.data); | ||
LOG('data: ' + data); | ||
switch (data[0]) { | ||
case 'connected': | ||
chrome.test.sendMessage('LAUNCHED'); | ||
break; | ||
case 'installed-touch-handler': | ||
case 'uninstalled-touch-handler': | ||
chrome.test.sendMessage(data[0]); | ||
break; | ||
} | ||
}); | ||
|
||
chrome.test.getConfig(function(config) { | ||
var guestURL = 'data:text/html,<html><body>foo</body></html>'; | ||
document.querySelector('#webview-tag-container').innerHTML = | ||
'<webview style="width: 10px; height: 10px; margin: 0; padding: 0;"' + | ||
'></webview>'; | ||
startTest(); | ||
}); |
23 changes: 23 additions & 0 deletions
23
extensions/test/data/web_view/accept_touch_events/manifest.json
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,23 @@ | ||
{ | ||
"name": "<webview> touch handler registration test.", | ||
"version": "1", | ||
"permissions": [ | ||
"webview" | ||
], | ||
"app": { | ||
"background": { | ||
"scripts": ["test.js"] | ||
} | ||
}, | ||
"webview": { | ||
"partitions": [ | ||
{ | ||
"name": "partition1", | ||
"accessible_resources": [ | ||
"guest.js", | ||
"guest.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,7 @@ | ||
// Copyright 2014 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
chrome.app.runtime.onLaunched.addListener(function() { | ||
chrome.app.window.create('main.html', {}, function () {}); | ||
}); |
12 changes: 12 additions & 0 deletions
12
extensions/test/data/web_view/visibility_changed/main.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,12 @@ | ||
<!doctype html> | ||
<!-- | ||
* Copyright 2014 The Chromium Authors. All rights reserved. Use of this | ||
* source code is governed by a BSD-style license that can be found in the | ||
* LICENSE file. | ||
--> | ||
<html> | ||
<body> | ||
<div id="webview-tag-container"></div> | ||
<script src="main.js"></script> | ||
</body> | ||
</html> |
Oops, something went wrong.