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

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: 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
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..0709078ef9f3ddc3751013bdef2ef72124850163 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
@@ -79,7 +79,9 @@ onload = function() {
chrome.test.assertEq('object', typeof webview.contentWindow);
chrome.test.assertEq('function',
typeof webview.contentWindow.postMessage);
-
+ // Remove the <webview> from the document so that its listeners
+ // don't interfere with subsequent tests.
+ webview.parentNode.removeChild(webview);
lazyboy 2013/02/11 18:23:18 Instead of doing this on every test can we set dif
Fady Samuel 2013/02/12 20:44:41 It works! It uncovered a subtle infinite navigatio
chrome.test.succeed();
});
webview.setAttribute('src', 'data:text/html,webview check api');
@@ -88,8 +90,6 @@ onload = function() {
function webViewEventName() {
var webview = document.createElement('webview');
- webview.setAttribute('src', 'data:text/html,webview check api');
- document.body.appendChild(webview);
webview.addEventListener('loadstart', function(evt) {
chrome.test.assertEq('loadstart', evt.type);
@@ -102,10 +102,14 @@ onload = function() {
webview.addEventListener('exit', function(evt) {
chrome.test.assertEq('exit', evt.type);
+ // Remove the <webview> from the document so that its listeners
+ // don't interfere with subsequent tests.
+ webview.parentNode.removeChild(webview);
chrome.test.succeed();
});
webview.setAttribute('src', 'data:text/html,trigger navigation');
+ document.body.appendChild(webview);
},
// This test registers two listeners on an event (loadcommit) and removes
@@ -123,8 +127,9 @@ onload = function() {
return;
++loadCommitCount;
if (loadCommitCount == 1) {
+ // Remove the <webview> from the document so that its listeners
+ // don't interfere with subsequent tests.
webview.parentNode.removeChild(webview);
- webview = null;
setTimeout(function() {
chrome.test.succeed();
}, 0);
@@ -156,6 +161,9 @@ onload = function() {
var maybeFinishTest = function(e) {
if (loadCommitACalled && loadCommitBCalled) {
chrome.test.assertEq('loadcommit', e.type);
+ // Remove the <webview> from the document so that its listeners
+ // don't interfere with subsequent tests.
+ webview.parentNode.removeChild(webview);
chrome.test.succeed();
}
};
@@ -215,6 +223,9 @@ onload = function() {
function(results) {
chrome.test.assertEq(1, results.length);
chrome.test.assertEq('red', results[0]);
+ // Remove the <webview> from the document so that its listeners
+ // don't interfere with subsequent tests.
+ webview.parentNode.removeChild(webview);
chrome.test.succeed();
});
});
@@ -225,15 +236,14 @@ 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');
var loadstopSucceedsTest = false;
webview.addEventListener('loadstop', function(evt) {
chrome.test.assertEq('loadstop', evt.type);
if (loadstopSucceedsTest) {
+ // Remove the <webview> from the document so that its listeners
+ // don't interfere with subsequent tests.
+ webview.parentNode.removeChild(webview);
chrome.test.succeed();
return;
}
@@ -255,6 +265,51 @@ 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');
+ var terminated = false;
+ webview.addEventListener('loadstop', function(evt) {
+ if (!terminated) {
+ webview.terminate();
+ return;
+ }
+ // Remove the <webview> from the document so that its listeners
+ // don't interfere with subsequent tests.
+ webview.parentNode.removeChild(webview);
+ // 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');
+ var terminated = false;
+ webview.addEventListener('loadstop', function(evt) {
+ webview.removeAttribute('src');
+ setTimeout(function() {
+ chrome.test.assertEq(dataUrl, webview.getAttribute('src'));
+ // Remove the <webview> from the document so that its listeners
+ // don't interfere with subsequent tests.
+ webview.parentNode.removeChild(webview);
+ chrome.test.succeed();
+ }, 0);
+ });
+ webview.setAttribute('src', dataUrl);
+ document.body.appendChild(webview);
}
]);
};

Powered by Google App Engine
This is Rietveld 408576698