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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 var embedder = {};
6
7 // TODO(lfg) Move these functions to a common js.
8 window.runTest = function(testName) {
9 if (!embedder.test.testList[testName]) {
10 window.console.warn('Incorrect testName: ' + testName);
11 embedder.test.fail();
12 return;
13 }
14
15 // Run the test.
16 embedder.test.testList[testName]();
17 };
18
19 embedder.test = {};
20
21 embedder.test.assertEq = function(a, b) {
22 if (a != b) {
23 window.console.warn('assertion failed: ' + a + ' != ' + b);
24 embedder.test.fail();
25 }
26 };
27
28 embedder.test.assertFalse = function(condition) {
29 if (condition) {
30 window.console.warn('assertion failed: false != ' + condition);
31 embedder.test.fail();
32 }
33 };
34
35 embedder.test.assertTrue = function(condition) {
36 if (!condition) {
37 window.console.warn('assertion failed: true != ' + condition);
38 embedder.test.fail();
39 }
40 };
41
42 embedder.test.fail = function() {
43 chrome.test.sendMessage('TEST_FAILED');
44 };
45
46 embedder.test.succeed = function() {
47 chrome.test.sendMessage('TEST_PASSED');
48 };
49
50
51 // Tests begin.
52
53 function testAPIMethodExistence() {
54 var apiMethodsToCheck = [
55 'back',
56 'find',
57 'forward',
58 'canGoBack',
59 'canGoForward',
60 'clearData',
61 'getProcessId',
62 'getZoom',
63 'go',
64 'print',
65 'reload',
66 'setZoom',
67 'stop',
68 'stopFinding',
69 'terminate',
70 'executeScript',
71 'insertCSS',
72 'getUserAgent',
73 'isUserAgentOverridden',
74 'setUserAgentOverride'
75 ];
76 var webview = document.createElement('webview');
77 webview.setAttribute('partition', arguments.callee.name);
78 webview.addEventListener('loadstop', function(e) {
79 for (var i = 0; i < apiMethodsToCheck.length; ++i) {
80 embedder.test.assertEq('function',
81 typeof webview[apiMethodsToCheck[i]]);
82 }
83
84 // Check contentWindow.
85 embedder.test.assertEq('object', typeof webview.contentWindow);
86 embedder.test.assertEq('function',
87 typeof webview.contentWindow.postMessage);
88 embedder.test.succeed();
89 });
90 webview.setAttribute('src', 'data:text/html,webview check api');
91 document.body.appendChild(webview);
92 }
93
94 embedder.test.testList = {
95 'testAPIMethodExistence': testAPIMethodExistence
96 };
97
98 onload = function() {
99 chrome.test.sendMessage('LAUNCHED');
100 };
OLDNEW
« 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