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

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

Issue 226043005: Fix webview.executeScript API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update InsertCss API. Created 6 years, 8 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') | extensions/common/extension_messages.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 647c3b7762a453e71069aa7327a6917c02828a7e..124d26cfb9aa6aa83a2fe431a2f2b030ba5b75a6 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
@@ -601,6 +601,38 @@ function testExecuteScript() {
document.body.appendChild(webview);
}
+// This test verifies that the call of executeScript will fail and return null
+// if the webview has been navigated to another source.
+function testExecuteScriptIsAbortedWhenWebViewSourceIsChanged() {
+ var webview = document.createElement('webview');
+ var initial = true;
+ var navigationOccur = false;
+ var newSrc = 'data:text/html,trigger navigation';
+ webview.addEventListener('loadstart', function() {
+ if (initial) {
+ webview.setAttribute('src', newSrc);
+ navigationOccur = true;
+ }
+ initial = false;
+ });
+ webview.addEventListener('loadstop', function() {
+ webview.executeScript(
+ {code:'document.body.style.backgroundColor = "red";'},
+ function(results) {
+ if (navigationOccur) {
+ // Expect a null results because the executeScript failed;
+ // return "red", otherwise.
+ embedder.test.assertEq(null, results);
+ embedder.test.succeed();
+ }
+ navigationOccur = false;
+ }
+ );
+ });
+ webview.setAttribute('src', "about:blank");
+ document.body.appendChild(webview);
+}
+
// This test calls terminate() on guest after it has already been
// terminated. This makes sure we ignore the call gracefully.
function testTerminateAfterExit() {
@@ -1480,6 +1512,8 @@ embedder.test.testList = {
'testPartitionRaisesException': testPartitionRaisesException,
'testExecuteScriptFail': testExecuteScriptFail,
'testExecuteScript': testExecuteScript,
+ 'testExecuteScriptIsAbortedWhenWebViewSourceIsChanged':
+ testExecuteScriptIsAbortedWhenWebViewSourceIsChanged,
'testTerminateAfterExit': testTerminateAfterExit,
'testAssignSrcAfterCrash': testAssignSrcAfterCrash,
'testNavOnConsecutiveSrcAttributeChanges':
« no previous file with comments | « chrome/renderer/resources/extensions/web_view.js ('k') | extensions/common/extension_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698