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

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

Issue 581283002: Add webview testAPIMethodExistence to app_shell_browsertests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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: extensions/test/data/web_view/shim/main.js
diff --git a/extensions/test/data/web_view/shim/main.js b/extensions/test/data/web_view/shim/main.js
new file mode 100644
index 0000000000000000000000000000000000000000..3ac5cc43c709607f1c19ae76f4408ada8e1d8644
--- /dev/null
+++ b/extensions/test/data/web_view/shim/main.js
@@ -0,0 +1,88 @@
+// 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 embedder = {};
+
+window.runTest = function(testName) {
Fady Samuel 2014/09/18 23:22:14 Can we move these utility functions to a common fi
lfg 2014/09/22 17:44:27 I've added a TODO for this.
+ if (!embedder.test.testList[testName]) {
+ window.console.warn('Incorrect testName: ' + testName);
+ embedder.test.fail();
+ return;
+ }
+
+ // Run the test.
+ embedder.test.testList[testName]();
+};
+
+embedder.test = {};
+
+embedder.test.assertEq = function(a, b) {
+ if (a != b) {
+ window.console.warn('assertion failed: ' + a + ' != ' + b);
+ embedder.test.fail();
+ }
+};
+
+embedder.test.assertFalse = function(condition) {
+ if (condition) {
+ window.console.warn('assertion failed: false != ' + condition);
+ embedder.test.fail();
+ }
+};
+
+embedder.test.assertTrue = function(condition) {
+ if (!condition) {
+ window.console.warn('assertion failed: true != ' + condition);
+ embedder.test.fail();
+ }
+};
+
+embedder.test.fail = function() {
+ chrome.test.sendMessage('TEST_FAILED');
+};
+
+embedder.test.succeed = function() {
+ chrome.test.sendMessage('TEST_PASSED');
+};
+
+
+// Tests begin.
+
+function testAPIMethodExistence() {
+ var apiMethodsToCheck = [
+ 'back',
+ 'canGoBack',
+ 'canGoForward',
+ 'forward',
+ 'getProcessId',
+ 'go',
+ 'reload',
+ 'stop',
+ 'terminate'
Fady Samuel 2014/09/18 23:22:14 Can we add more methods to this?
lfg 2014/09/22 17:44:27 Done.
+ ];
+ var webview = document.createElement('webview');
+ webview.setAttribute('partition', arguments.callee.name);
+ webview.addEventListener('loadstop', function(e) {
+ for (var i = 0; i < apiMethodsToCheck.length; ++i) {
+ embedder.test.assertEq('function',
+ typeof webview[apiMethodsToCheck[i]]);
+ }
+
+ // Check contentWindow.
+ embedder.test.assertEq('object', typeof webview.contentWindow);
+ embedder.test.assertEq('function',
+ typeof webview.contentWindow.postMessage);
Fady Samuel 2014/09/18 23:22:14 nit: alignment
lfg 2014/09/22 17:44:27 Done.
+ embedder.test.succeed();
+ });
+ webview.setAttribute('src', 'data:text/html,webview check api');
+ document.body.appendChild(webview);
+}
+
+embedder.test.testList = {
+ 'testAPIMethodExistence': testAPIMethodExistence
+};
+
+onload = function() {
+ chrome.test.sendMessage('LAUNCHED');
+};

Powered by Google App Engine
This is Rietveld 408576698