Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(354)

Unified Diff: chrome/test/data/extensions/platform_apps/web_view/shim/main.js

Issue 12224094: Browser Plugin: Navigating to the same URL after crash should load a new guest (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed nits + Merged with ToT Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/renderer/resources/extensions/web_view.js ('k') | content/renderer/browser_plugin/browser_plugin.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/extensions/platform_apps/web_view/shim/main.js
diff --git a/chrome/test/data/extensions/platform_apps/web_view/shim/main.js b/chrome/test/data/extensions/platform_apps/web_view/shim/main.js
index 24a82bf337e9cf2bf993368fbb457385e9197cbd..02fc6f893ad3777093f091bba99d69dc8bd31631 100644
--- a/chrome/test/data/extensions/platform_apps/web_view/shim/main.js
+++ b/chrome/test/data/extensions/platform_apps/web_view/shim/main.js
@@ -9,13 +9,14 @@ var util = {};
// sure that the <object> shim is created (asynchronously at this point) for the
// <webview> tag. This makes the <webview> tag ready for add/removeEventListener
// calls.
-util.createWebViewTagInDOM = function() {
+util.createWebViewTagInDOM = function(partitionName) {
var webview = document.createElement('webview');
webview.style.width = '300px';
webview.style.height = '200px';
- document.body.appendChild(webview);
var urlDummy = 'data:text/html,<body>Initial dummy guest</body>';
webview.setAttribute('src', urlDummy);
+ webview.setAttribute('partition', partitionName);
+ document.body.appendChild(webview);
return webview;
};
@@ -69,6 +70,7 @@ onload = function() {
'terminate'
];
var webview = document.createElement('webview');
+ webview.setAttribute('partition', arguments.callee.name);
webview.addEventListener('loadstop', function(e) {
for (var i = 0; i < apiMethodsToCheck.length; ++i) {
chrome.test.assertEq('function',
@@ -79,7 +81,6 @@ onload = function() {
chrome.test.assertEq('object', typeof webview.contentWindow);
chrome.test.assertEq('function',
typeof webview.contentWindow.postMessage);
-
chrome.test.succeed();
});
webview.setAttribute('src', 'data:text/html,webview check api');
@@ -88,8 +89,7 @@ onload = function() {
function webViewEventName() {
var webview = document.createElement('webview');
- webview.setAttribute('src', 'data:text/html,webview check api');
- document.body.appendChild(webview);
+ webview.setAttribute('partition', arguments.callee.name);
webview.addEventListener('loadstart', function(evt) {
chrome.test.assertEq('loadstart', evt.type);
@@ -106,6 +106,7 @@ onload = function() {
});
webview.setAttribute('src', 'data:text/html,trigger navigation');
+ document.body.appendChild(webview);
},
// This test registers two listeners on an event (loadcommit) and removes
@@ -113,7 +114,7 @@ onload = function() {
// Current expected behavior is that the second event listener will still
// fire without crashing.
function webviewDestroyOnEventListener() {
- var webview = util.createWebViewTagInDOM();
+ var webview = util.createWebViewTagInDOM(arguments.callee.name);
var url = 'data:text/html,<body>Destroy test</body>';
var loadCommitCount = 0;
@@ -123,8 +124,6 @@ onload = function() {
return;
++loadCommitCount;
if (loadCommitCount == 1) {
- webview.parentNode.removeChild(webview);
- webview = null;
setTimeout(function() {
chrome.test.succeed();
}, 0);
@@ -135,6 +134,7 @@ onload = function() {
// The test starts from here, by setting the src to |url|.
webview.addEventListener('loadcommit', function(e) {
+ webview.parentNode.removeChild(webview);
loadCommitCommon(e);
});
webview.addEventListener('loadcommit', function(e) {
@@ -147,7 +147,7 @@ onload = function() {
// Each of the listener tries to change some properties on the event param,
// which should not be possible.
function cannotMutateEventName() {
- var webview = util.createWebViewTagInDOM();
+ var webview = util.createWebViewTagInDOM(arguments.callee.name);
var url = 'data:text/html,<body>Two</body>';
var loadCommitACalled = false;
@@ -195,6 +195,7 @@ onload = function() {
// been set raises an exception.
function partitionRaisesException() {
var webview = document.createElement('webview');
+ webview.setAttribute('partition', arguments.callee.name);
webview.setAttribute('src', 'data:text/html,trigger navigation');
document.body.appendChild(webview);
setTimeout(function() {
@@ -209,6 +210,7 @@ onload = function() {
function webViewExecuteScript() {
var webview = document.createElement('webview');
+ webview.setAttribute('partition', arguments.callee.name);
webview.addEventListener('loadstop', function() {
webview.executeScript(
{code:'document.body.style.backgroundColor = "red";'},
@@ -225,11 +227,8 @@ onload = function() {
// This test calls terminate() on guest after it has already been
// terminated. This makes sure we ignore the call gracefully.
function webViewTerminateAfterExitDoesntCrash() {
- var webview = document.querySelector('webview');
- webview.addEventListener('loadstart', function(evt) {
- chrome.test.assertEq('loadstart', evt.type);
- });
-
+ var webview = document.createElement('webview');
+ webview.setAttribute('partition', arguments.callee.name);
var loadstopSucceedsTest = false;
webview.addEventListener('loadstop', function(evt) {
chrome.test.assertEq('loadstop', evt.type);
@@ -255,6 +254,47 @@ onload = function() {
});
webview.setAttribute('src', 'data:text/html,test terminate() crash.');
+ document.body.appendChild(webview);
+ },
+
+ // This test verifies that assigning the src attribute the same value it had
+ // prior to a crash spawns off a new guest process.
+ function webViewAssignSrcAfterCrash() {
+ var webview = document.createElement('webview');
+ webview.setAttribute('partition', arguments.callee.name);
+ var terminated = false;
+ webview.addEventListener('loadstop', function(evt) {
+ if (!terminated) {
+ webview.terminate();
+ return;
+ }
+ // The guest has recovered after being terminated.
+ chrome.test.succeed();
+ });
+ webview.addEventListener('exit', function(evt) {
+ terminated = true;
+ webview.setAttribute('src', 'data:text/html,test page');
+ });
+ webview.setAttribute('src', 'data:text/html,test page');
+ document.body.appendChild(webview);
+ },
+
+ // This test verifies that <webview> restores the src attribute if it is
+ // removed after navigation.
+ function webViewRemoveSrcAttribute() {
+ var dataUrl = 'data:text/html,test page';
+ var webview = document.createElement('webview');
+ webview.setAttribute('partition', arguments.callee.name);
+ var terminated = false;
+ webview.addEventListener('loadstop', function(evt) {
+ webview.removeAttribute('src');
+ setTimeout(function() {
+ chrome.test.assertEq(dataUrl, webview.getAttribute('src'));
+ chrome.test.succeed();
+ }, 0);
+ });
+ webview.setAttribute('src', dataUrl);
+ document.body.appendChild(webview);
}
]);
};
« no previous file with comments | « chrome/renderer/resources/extensions/web_view.js ('k') | content/renderer/browser_plugin/browser_plugin.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698