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

Unified 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, 4 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: ppapi/native_client/tests/ppapi_browser/ppp_instance/ppapi_ppp_instance.js
===================================================================
--- ppapi/native_client/tests/ppapi_browser/ppp_instance/ppapi_ppp_instance.js (revision 0)
+++ ppapi/native_client/tests/ppapi_browser/ppp_instance/ppapi_ppp_instance.js (revision 0)
@@ -0,0 +1,69 @@
+// Copyright (c) 2011 The Native Client Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+function startsWith(str, prefix) {
+ return (str.indexOf(prefix) === 0);
+}
+
+function setupTests(tester, plugin) {
+ //////////////////////////////////////////////////////////////////////////////
+ // Test Helpers
+ //////////////////////////////////////////////////////////////////////////////
+ var numMessages = 0;
+ function addTestListeners(numListeners, test, testFunction, runCheck) {
+ var messageListener = test.wrap(function(message) {
+ if (!startsWith(message.data, testFunction)) return;
+ test.log(message.data);
+ numMessages++;
+ plugin.removeEventListener('message', messageListener, false);
+ test.assertEqual(message.data, testFunction + ':PASSED');
+ if (runCheck) test.assert(runCheck());
+ if (numMessages < numListeners) {
+ plugin.addEventListener('message', messageListener, false);
+ } else {
+ numMessages = 0;
+ test.pass();
+ }
+ });
+ plugin.addEventListener('message', messageListener, false);
+ }
+
+ function addTestListener(test, testFunction, runCheck) {
+ return addTestListeners(1, test, testFunction, runCheck);
+ }
+
+ //////////////////////////////////////////////////////////////////////////////
+ // Tests
+ //////////////////////////////////////////////////////////////////////////////
+
+ tester.addTest('PPP_Instance::DidCreate', function() {
+ assertEqual(plugin.lastError, '');
+ });
+
+ tester.addAsyncTest('PPP_Instance::DidChangeView', function(test) {
+ addTestListeners(3, test, 'DidChangeView');
+ });
+
+ tester.addAsyncTest('PPP_Instance::DidChangeFocus', function(test) {
+ // TODO(polina): How can I simulate focusing on Windows?
+ // For now just pass explicitely.
+ if (startsWith(navigator.platform, 'Win')) {
+ test.log('skipping test on ' + navigator.platform);
+ test.pass();
+ return;
+ }
+ addTestListeners(2, test, 'DidChangeFocus');
+ plugin.tabIndex = 0;
+ plugin.focus();
+ plugin.blur();
+ });
+
+ // PPP_Instance::HandleDocumentLoad is only used with full-frame plugins.
+ // This is tested in tests/ppapi_browser/extension_mime_handler/
+
+ // PPP_Instance::DidDestroy is never invoked in the untrusted code.
+ // We could wait for a crash event from it, but CallOnMainThread semantics
+ // on shutdown are still buggy, so it might never come even if the function
+ // triggered. Plus waiting for something not to happen makes the test flaky.
+}

Powered by Google App Engine
This is Rietveld 408576698