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

Unified Diff: extensions/test/data/web_view/apitest/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/apitest/main.js
diff --git a/extensions/test/data/web_view/apitest/main.js b/extensions/test/data/web_view/apitest/main.js
new file mode 100644
index 0000000000000000000000000000000000000000..14e7e97b339dd5cd24a346af61dabc5abfd5c813
--- /dev/null
+++ b/extensions/test/data/web_view/apitest/main.js
@@ -0,0 +1,100 @@
+// 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 = {};
+
+// TODO(lfg) Move these functions to a common js.
+window.runTest = function(testName) {
+ 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',
+ 'find',
+ 'forward',
+ 'canGoBack',
+ 'canGoForward',
+ 'clearData',
+ 'getProcessId',
+ 'getZoom',
+ 'go',
+ 'print',
+ 'reload',
+ 'setZoom',
+ 'stop',
+ 'stopFinding',
+ 'terminate',
+ 'executeScript',
+ 'insertCSS',
+ 'getUserAgent',
+ 'isUserAgentOverridden',
+ 'setUserAgentOverride'
+ ];
+ 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);
+ 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');
+};
« no previous file with comments | « extensions/test/data/web_view/apitest/main.html ('k') | extensions/test/data/web_view/apitest/manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698