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

Side by Side Diff: tests/ppapi_test_example/ppapi_test_example.js

Issue 7292002: Remove plugin connection to PPAPI scriptable objects (var deprecated). Also (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: '' Created 9 years, 5 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
1 // Copyright (c) 2011 The Native Client Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 function setupTests(tester, plugin) { 5 function setupTests(tester, plugin) {
6 // TODO(tester): replace with your tests. 6 // TODO(tester): replace with your tests.
7 7
8 // Below are the before & after versions of sample test cases demonstrating 8 // Below are the before & after versions of sample test cases demonstrating
polina 2011/07/12 08:58:01 forgot this comment
sehr (please use chromium) 2011/07/12 16:44:23 Done.
9 // how to transition from synchronous scripting to postMessage as the test 9 // how to transition from synchronous scripting to postMessage as the test
10 // driving mechanism. 10 // driving mechanism.
11 11
12 // Before.
13 tester.addTest('Example::SimpleSync', function() {
14 assert(plugin.TestSimpleSync());
15 });
16
17 // After. 12 // After.
polina 2011/07/12 08:58:01 forgot this one
sehr (please use chromium) 2011/07/12 16:44:23 Done.
18 tester.addAsyncTest('Example::SimpleAsync', function(status) { 13 tester.addAsyncTest('Example::SimpleAsync', function(status) {
polina 2011/07/12 08:58:01 Please drop Async in this file as well.
sehr (please use chromium) 2011/07/12 16:44:23 Done.
19 var messageListener = status.wrap(function(message) { 14 var messageListener = status.wrap(function(message) {
20 status.log('Received message: ' + message.data); 15 status.log('Received message: ' + message.data);
21 plugin.removeEventListener('message', messageListener, false); 16 plugin.removeEventListener('message', messageListener, false);
22 status.assertEqual(message.data, 'TestSimpleAsync:PASSED'); 17 status.assertEqual(message.data, 'TestSimpleAsync:PASSED');
23 status.pass(); 18 status.pass();
24 }); 19 });
25 20
26 plugin.addEventListener("message", messageListener, false); 21 plugin.addEventListener("message", messageListener, false);
27 plugin.postMessage("TestSimpleAsync"); 22 plugin.postMessage("TestSimpleAsync");
28 }); 23 });
29 24
30 // Before.
31 tester.addTest('Example::CallbackSync', function(status) {
32 status.assert(plugin.TestCallbackSync());
33 status.waitForCallback('CallbackSync', 1);
34 });
35
36 // After. 25 // After.
polina 2011/07/12 08:58:01 and this one
sehr (please use chromium) 2011/07/12 16:44:23 Done.
37 tester.addAsyncTest('Example::CallbackAsync', function(status) { 26 tester.addAsyncTest('Example::CallbackAsync', function(status) {
38 var gotPassed = false; 27 var gotPassed = false;
39 var messageListener = status.wrap(function(message) { 28 var messageListener = status.wrap(function(message) {
40 // <IGNORE> 29 // <IGNORE>
41 // If you are consulting this example while porting or writing 30 // If you are consulting this example while porting or writing
42 // addAsyncTest's, ignore this part. This is a short-term side-effect of 31 // addAsyncTest's, ignore this part. This is a short-term side-effect of
43 // C++ test harness migration and affects only this example 32 // C++ test harness migration and affects only this example
44 // that uses both old-style and new-style tests. 33 // that uses both old-style and new-style tests.
45 // To simplify C++ test harness migration, the callback handler 34 // To simplify C++ test harness migration, the callback handler
46 // notifies JS both via browser scripting and postMessage, 35 // notifies JS both via browser scripting and postMessage,
47 // so we should ignore the message from TestCallbackSync above. 36 // so we should ignore the message from TestCallbackSync above.
48 if (message.data == 'CallbackSync') 37 if (message.data == 'CallbackSync')
49 return; 38 return;
50 // </IGNORE> 39 // </IGNORE>
polina 2011/07/12 08:58:01 this IGNORE section should now go away
sehr (please use chromium) 2011/07/12 16:44:23 Done.
51 status.log('Received message: ' + message.data); 40 status.log('Received message: ' + message.data);
52 plugin.removeEventListener('message', messageListener, false); 41 plugin.removeEventListener('message', messageListener, false);
53 if (!gotPassed) { 42 if (!gotPassed) {
54 status.assertEqual(message.data, 'TestCallbackAsync:PASSED'); 43 status.assertEqual(message.data, 'TestCallbackAsync:PASSED');
55 gotPassed = true; 44 gotPassed = true;
56 plugin.addEventListener("message", messageListener, false); 45 plugin.addEventListener("message", messageListener, false);
57 } else { 46 } else {
58 status.assertEqual(message.data, 'CallbackAsync'); 47 status.assertEqual(message.data, 'CallbackAsync');
59 status.pass(); 48 status.pass();
60 } 49 }
61 }); 50 });
62 51
63 plugin.addEventListener("message", messageListener, false); 52 plugin.addEventListener("message", messageListener, false);
64 plugin.postMessage("TestCallbackAsync"); 53 plugin.postMessage("TestCallbackAsync");
65 }); 54 });
66 } 55 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698