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

Side by Side 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 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 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.
8 if (!embedder.test.testList[testName]) {
9 window.console.warn('Incorrect testName: ' + testName);
10 embedder.test.fail();
11 return;
12 }
13
14 // Run the test.
15 embedder.test.testList[testName]();
16 };
17
18 embedder.test = {};
19
20 embedder.test.assertEq = function(a, b) {
21 if (a != b) {
22 window.console.warn('assertion failed: ' + a + ' != ' + b);
23 embedder.test.fail();
24 }
25 };
26
27 embedder.test.assertFalse = function(condition) {
28 if (condition) {
29 window.console.warn('assertion failed: false != ' + condition);
30 embedder.test.fail();
31 }
32 };
33
34 embedder.test.assertTrue = function(condition) {
35 if (!condition) {
36 window.console.warn('assertion failed: true != ' + condition);
37 embedder.test.fail();
38 }
39 };
40
41 embedder.test.fail = function() {
42 chrome.test.sendMessage('TEST_FAILED');
43 };
44
45 embedder.test.succeed = function() {
46 chrome.test.sendMessage('TEST_PASSED');
47 };
48
49
50 // Tests begin.
51
52 function testAPIMethodExistence() {
53 var apiMethodsToCheck = [
54 'back',
55 'canGoBack',
56 'canGoForward',
57 'forward',
58 'getProcessId',
59 'go',
60 'reload',
61 'stop',
62 'terminate'
Fady Samuel 2014/09/18 23:22:14 Can we add more methods to this?
lfg 2014/09/22 17:44:27 Done.
63 ];
64 var webview = document.createElement('webview');
65 webview.setAttribute('partition', arguments.callee.name);
66 webview.addEventListener('loadstop', function(e) {
67 for (var i = 0; i < apiMethodsToCheck.length; ++i) {
68 embedder.test.assertEq('function',
69 typeof webview[apiMethodsToCheck[i]]);
70 }
71
72 // Check contentWindow.
73 embedder.test.assertEq('object', typeof webview.contentWindow);
74 embedder.test.assertEq('function',
75 typeof webview.contentWindow.postMessage);
Fady Samuel 2014/09/18 23:22:14 nit: alignment
lfg 2014/09/22 17:44:27 Done.
76 embedder.test.succeed();
77 });
78 webview.setAttribute('src', 'data:text/html,webview check api');
79 document.body.appendChild(webview);
80 }
81
82 embedder.test.testList = {
83 'testAPIMethodExistence': testAPIMethodExistence
84 };
85
86 onload = function() {
87 chrome.test.sendMessage('LAUNCHED');
88 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698