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

Side by Side Diff: ppapi/native_client/tests/ppapi_browser/ppp_instance/ppapi_ppp_instance.js

Issue 7740013: Cloning a bunch of stuff from the native_client repository at r6528 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Native Client 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 function startsWith(str, prefix) {
6 return (str.indexOf(prefix) === 0);
7 }
8
9 function setupTests(tester, plugin) {
10 //////////////////////////////////////////////////////////////////////////////
11 // Test Helpers
12 //////////////////////////////////////////////////////////////////////////////
13 var numMessages = 0;
14 function addTestListeners(numListeners, test, testFunction, runCheck) {
15 var messageListener = test.wrap(function(message) {
16 if (!startsWith(message.data, testFunction)) return;
17 test.log(message.data);
18 numMessages++;
19 plugin.removeEventListener('message', messageListener, false);
20 test.assertEqual(message.data, testFunction + ':PASSED');
21 if (runCheck) test.assert(runCheck());
22 if (numMessages < numListeners) {
23 plugin.addEventListener('message', messageListener, false);
24 } else {
25 numMessages = 0;
26 test.pass();
27 }
28 });
29 plugin.addEventListener('message', messageListener, false);
30 }
31
32 function addTestListener(test, testFunction, runCheck) {
33 return addTestListeners(1, test, testFunction, runCheck);
34 }
35
36 //////////////////////////////////////////////////////////////////////////////
37 // Tests
38 //////////////////////////////////////////////////////////////////////////////
39
40 tester.addTest('PPP_Instance::DidCreate', function() {
41 assertEqual(plugin.lastError, '');
42 });
43
44 tester.addAsyncTest('PPP_Instance::DidChangeView', function(test) {
45 addTestListeners(3, test, 'DidChangeView');
46 });
47
48 tester.addAsyncTest('PPP_Instance::DidChangeFocus', function(test) {
49 // TODO(polina): How can I simulate focusing on Windows?
50 // For now just pass explicitely.
51 if (startsWith(navigator.platform, 'Win')) {
52 test.log('skipping test on ' + navigator.platform);
53 test.pass();
54 return;
55 }
56 addTestListeners(2, test, 'DidChangeFocus');
57 plugin.tabIndex = 0;
58 plugin.focus();
59 plugin.blur();
60 });
61
62 // PPP_Instance::HandleDocumentLoad is only used with full-frame plugins.
63 // This is tested in tests/ppapi_browser/extension_mime_handler/
64
65 // PPP_Instance::DidDestroy is never invoked in the untrusted code.
66 // We could wait for a crash event from it, but CallOnMainThread semantics
67 // on shutdown are still buggy, so it might never come even if the function
68 // triggered. Plus waiting for something not to happen makes the test flaky.
69 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698