summaryrefslogtreecommitdiffstats
path: root/ppapi/native_client
diff options
context:
space:
mode:
authorncbray@chromium.org <ncbray@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-15 19:14:35 +0000
committerncbray@chromium.org <ncbray@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-15 19:14:35 +0000
commitfa3416f9fbff598a69bd91f457a36471dfb9de57 (patch)
treeaf062ba302d8d1702daccacdeb45194ee38615b3 /ppapi/native_client
parent2a1d7024a9e3dfae6d7528795c7b1d708deb8a30 (diff)
downloadchromium_src-fa3416f9fbff598a69bd91f457a36471dfb9de57.zip
chromium_src-fa3416f9fbff598a69bd91f457a36471dfb9de57.tar.gz
chromium_src-fa3416f9fbff598a69bd91f457a36471dfb9de57.tar.bz2
Port NaCl mime handling test from nacl_integration to browser_tests.
BUG=154400 Review URL: https://codereview.chromium.org/135013002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@244957 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/native_client')
-rw-r--r--ppapi/native_client/chrome_main.scons1
-rw-r--r--ppapi/native_client/tests/ppapi_browser/extension_mime_handler/manifest.json18
-rw-r--r--ppapi/native_client/tests/ppapi_browser/extension_mime_handler/mime_test_data.dat1
-rw-r--r--ppapi/native_client/tests/ppapi_browser/extension_mime_handler/nacl.scons55
-rw-r--r--ppapi/native_client/tests/ppapi_browser/extension_mime_handler/ppapi_extension_mime_handler.cc144
-rw-r--r--ppapi/native_client/tests/ppapi_browser/extension_mime_handler/ppapi_extension_mime_handler.html45
-rw-r--r--ppapi/native_client/tests/ppapi_browser/extension_mime_handler/ppapi_extension_mime_handler.nmf7
7 files changed, 0 insertions, 271 deletions
diff --git a/ppapi/native_client/chrome_main.scons b/ppapi/native_client/chrome_main.scons
index 28bca73..a8e7bec 100644
--- a/ppapi/native_client/chrome_main.scons
+++ b/ppapi/native_client/chrome_main.scons
@@ -37,7 +37,6 @@ ppapi_scons_files['untrusted_irt_scons_files'] = []
ppapi_scons_files['nonvariant_test_scons_files'] = [
'tests/breakpad_crash_test/nacl.scons',
'tests/nacl_browser/browser_dynamic_library/nacl.scons',
- 'tests/ppapi_browser/extension_mime_handler/nacl.scons',
'tests/ppapi_browser/manifest/nacl.scons',
'tests/ppapi_test_lib/nacl.scons',
]
diff --git a/ppapi/native_client/tests/ppapi_browser/extension_mime_handler/manifest.json b/ppapi/native_client/tests/ppapi_browser/extension_mime_handler/manifest.json
deleted file mode 100644
index e3952eb..0000000
--- a/ppapi/native_client/tests/ppapi_browser/extension_mime_handler/manifest.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "name": "NaCl_MIMETest",
- "version": "0.1",
- "manifest_version": 2,
- "description": "Tests NaCl MIME type handling capabilities.",
- "permissions": [
- "experimental",
- "nativeclient"
- ],
- "web_accessible_resources": [ "ppapi_extension_mime_handler.nmf",
- "ppapi_extension_mime_handler_x86-32.nexe",
- "ppapi_extension_mime_handler_x86-64.nexe",
- "ppapi_extension_mime_handler_arm.nexe" ],
- "nacl_modules": [{
- "path": "ppapi_extension_mime_handler.nmf",
- "mime_type": "foo/bar"
- }]
-}
diff --git a/ppapi/native_client/tests/ppapi_browser/extension_mime_handler/mime_test_data.dat b/ppapi/native_client/tests/ppapi_browser/extension_mime_handler/mime_test_data.dat
deleted file mode 100644
index 10d283c..0000000
--- a/ppapi/native_client/tests/ppapi_browser/extension_mime_handler/mime_test_data.dat
+++ /dev/null
@@ -1 +0,0 @@
-This is just a test file so we can verify HandleDocumentLoad. \ No newline at end of file
diff --git a/ppapi/native_client/tests/ppapi_browser/extension_mime_handler/nacl.scons b/ppapi/native_client/tests/ppapi_browser/extension_mime_handler/nacl.scons
deleted file mode 100644
index 7fca293..0000000
--- a/ppapi/native_client/tests/ppapi_browser/extension_mime_handler/nacl.scons
+++ /dev/null
@@ -1,55 +0,0 @@
-# -*- python -*-
-# Copyright (c) 2012 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.
-
-# Test loading a NaCl-enabled Chrome Extension. This also covers parts
-# of {ppb,ppp}_instance interfaces that are not testable any other way.
-
-# The extension registers the nacl module as a content handler for foo/bar.
-
-Import('env')
-
-env.Prepend(CPPDEFINES=['XP_UNIX'])
-env.Replace(TEST_DIR='${SOURCE_ROOT}/ppapi/native_client/tests/ppapi_browser/' +
- 'extension_mime_handler')
-
-nexe = env.ProgramNameForNmf('ppapi_extension_mime_handler')
-
-env.ComponentProgram(
- nexe,
- ['ppapi_extension_mime_handler.cc'],
- EXTRA_LIBS=['ppapi',
- 'ppapi_test_lib',
- 'pthread',
- 'platform',
- 'gio'])
-
-# Copy the extension into place (as a subdir in the staging dir).
-dest_copy = env.Replicate('$STAGING_DIR/ppapi_extension_mime_handler',
- ['manifest.json',
- env.File('$STAGING_DIR/' + nexe + '$PROGSUFFIX')])
-dest_copy.append(env.CopyLibsForExtension(
- '$STAGING_DIR/ppapi_extension_mime_handler',
- '$STAGING_DIR/ppapi_extension_mime_handler.nmf'))
-
-env.Depends(env.Alias(nexe), dest_copy)
-
-# Publish the html and dat.
-env.Publish(nexe, 'run',
- ['ppapi_extension_mime_handler.html',
- 'mime_test_data.dat'])
-
-node = env.PPAPIBrowserTester('ppapi_extension_mime_handler.out',
- url='ppapi_extension_mime_handler.html',
- nmfs=['${TEST_DIR}/ppapi_extension_mime_handler.nmf'],
- extensions=[env.Dir('$STAGING_DIR/ppapi_extension_mime_handler')],
- mime_types=[('dat', 'foo/bar')],
- files=env.ExtractPublishedFiles(nexe))
-
-env.Depends(node, dest_copy)
-
-env.AddNodeToTestSuite(node,
- ['chrome_browser_tests'],
- 'run_ppapi_extension_mime_handler_browser_test',
- is_broken=env.PPAPIBrowserTesterIsBroken())
diff --git a/ppapi/native_client/tests/ppapi_browser/extension_mime_handler/ppapi_extension_mime_handler.cc b/ppapi/native_client/tests/ppapi_browser/extension_mime_handler/ppapi_extension_mime_handler.cc
deleted file mode 100644
index 51ea210..0000000
--- a/ppapi/native_client/tests/ppapi_browser/extension_mime_handler/ppapi_extension_mime_handler.cc
+++ /dev/null
@@ -1,144 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <string.h>
-
-#include "native_client/src/include/nacl_macros.h"
-#include "native_client/src/shared/platform/nacl_check.h"
-
-#include "ppapi/c/pp_bool.h"
-#include "ppapi/c/pp_errors.h"
-#include "ppapi/c/pp_input_event.h"
-#include "ppapi/c/ppb_instance.h"
-#include "ppapi/c/ppb_url_loader.h"
-#include "ppapi/c/ppp_instance.h"
-
-#include "ppapi/native_client/tests/ppapi_test_lib/get_browser_interface.h"
-#include "ppapi/native_client/tests/ppapi_test_lib/test_interface.h"
-
-namespace {
-
-
-// PostMessage is complicated in this test. We're setting up an iframe with
-// src=foo where foo is handled by an extension as a content handler. Webkit
-// generates the html page with the plugin embed, so we have no way to place
-// an event handler on the plugin or body of that page that's guaranteed to
-// execute before the plugin initializes. Instead, we're just caching the
-// first error (if any) we encounter during load and responding to a normal
-// test message to return the results.
-const int kDocLoadErrorNone = 0;
-const int kDocLoadErrorInit = -1;
-int error_in_doc_load_line = kDocLoadErrorInit;
-
-#define EXPECT_ON_LOAD(condition) \
- do { \
- if (!(condition)) { \
- if (kDocLoadErrorInit == error_in_doc_load_line) { \
- error_in_doc_load_line = __LINE__; \
- } \
- } \
- } while (0);
-
-#define ON_LOAD_PASSED \
- do { \
- if (kDocLoadErrorInit == error_in_doc_load_line) \
- error_in_doc_load_line = kDocLoadErrorNone; \
- } while (0);
-
-// Simple 1K buffer to hold the document passed through HandleDocumentLoad.
-const uint32_t kMaxFileSize = 1024;
-char buffer[kMaxFileSize];
-uint32_t buffer_pos = 0;
-
-const char kKnownFileContents[] =
- "This is just a test file so we can verify HandleDocumentLoad.";
-
-void ReadCallback(void* user_data, int32_t pp_error_or_bytes) {
- PP_Resource url_loader = reinterpret_cast<PP_Resource>(user_data);
-
- EXPECT_ON_LOAD(pp_error_or_bytes >= PP_OK);
- if (pp_error_or_bytes < PP_OK) {
- PPBCore()->ReleaseResource(url_loader);
- return;
- }
-
- if (PP_OK == pp_error_or_bytes) {
- // Check the contents of the file against the known contents.
- int diff = strncmp(buffer,
- kKnownFileContents,
- strlen(kKnownFileContents));
- EXPECT_ON_LOAD(diff == 0);
- PPBURLLoader()->Close(url_loader);
- PPBCore()->ReleaseResource(url_loader);
- ON_LOAD_PASSED;
- } else {
- buffer_pos += pp_error_or_bytes;
- PP_CompletionCallback callback =
- PP_MakeCompletionCallback(ReadCallback, user_data);
- pp_error_or_bytes =
- PPBURLLoader()->ReadResponseBody(url_loader,
- buffer + buffer_pos,
- kMaxFileSize - buffer_pos,
- callback);
- EXPECT(pp_error_or_bytes == PP_OK_COMPLETIONPENDING);
- }
-}
-
-PP_Bool HandleDocumentLoad(PP_Instance instance,
- PP_Resource url_loader) {
- // The browser will release url_loader after this method returns. We need to
- // keep it around until we have read all bytes or get an error.
- PPBCore()->AddRefResource(url_loader);
- void* user_data = reinterpret_cast<void*>(url_loader);
- PP_CompletionCallback callback =
- PP_MakeCompletionCallback(ReadCallback, user_data);
- int32_t pp_error_or_bytes = PPBURLLoader()->ReadResponseBody(url_loader,
- buffer,
- kMaxFileSize,
- callback);
- EXPECT(pp_error_or_bytes == PP_OK_COMPLETIONPENDING);
- return PP_TRUE;
-}
-
-const PPP_Instance ppp_instance_interface = {
- DidCreateDefault,
- DidDestroyDefault,
- DidChangeViewDefault,
- DidChangeFocusDefault,
- HandleDocumentLoad
-};
-
-// This tests PPP_Instance::HandleDocumentLoad.
-void TestHandleDocumentLoad() {
- if (error_in_doc_load_line != kDocLoadErrorNone) {
- char error[1024];
- snprintf(error, sizeof(error),
- "ERROR at %s:%d: Document Load Failed\n",
- __FILE__, error_in_doc_load_line);
- fprintf(stderr, "%s", error);
- PostTestMessage(__FUNCTION__, error);
- }
- TEST_PASSED;
-}
-
-// This tests PPB_Instance::IsFullFrame when the plugin is full frame.
-// Other conditions for IsFullFrame are tested by ppb_instance tests.
-void TestIsFullFrame() {
- PP_Bool full_frame = PPBInstance()->IsFullFrame(pp_instance());
- EXPECT(full_frame == PP_TRUE);
- TEST_PASSED;
-}
-
-
-} // namespace
-
-
-void SetupTests() {
- RegisterTest("TestHandleDocumentLoad", TestHandleDocumentLoad);
- RegisterTest("TestIsFullFrame", TestIsFullFrame);
-}
-
-void SetupPluginInterfaces() {
- RegisterPluginInterface(PPP_INSTANCE_INTERFACE, &ppp_instance_interface);
-}
diff --git a/ppapi/native_client/tests/ppapi_browser/extension_mime_handler/ppapi_extension_mime_handler.html b/ppapi/native_client/tests/ppapi_browser/extension_mime_handler/ppapi_extension_mime_handler.html
deleted file mode 100644
index 5470f82..0000000
--- a/ppapi/native_client/tests/ppapi_browser/extension_mime_handler/ppapi_extension_mime_handler.html
+++ /dev/null
@@ -1,45 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html>
- <!-- Copyright 2011 Google Inc. All rights reserved. -->
- <head>
- <script type="text/javascript" src="nacltest.js"></script>
- <script type="application/x-javascript">
- //<![CDATA[
- function iframe_loaded() {
- var iframe_doc = window.frames['iframe_id'].document;
- var iframe_body = iframe_doc.body;
- var tester = new Tester();
- // 'plugin' is the name given to the embed by webkit
- var plugin = iframe_doc.getElementsByName('plugin')[0];
-
- function addTest(test_name, responses) {
- if (responses === undefined) {
- responses = [];
- }
- var expected_messages = [test_name + ':PASSED'].concat(responses);
- tester.addAsyncTest(test_name, function(test) {
- test.expectMessageSequence(plugin, expected_messages);
- plugin.postMessage(test_name)
- });
- }
-
- addTest('TestHandleDocumentLoad');
- addTest('TestIsFullFrame');
- tester.waitFor(plugin);
- tester.run();
- }
- //]]>
- </script>
- <title>PPAPI Extension MIME Type Test</title>
- </head>
- <body>
- <h1>PPAPI Extension MIME Type Test</h1>
- <iframe src='mime_test_data.dat'
- id='iframe_id'
- width='100'
- height='100'
- onload='iframe_loaded()'>
- </iframe>
- </body>
-</html>
diff --git a/ppapi/native_client/tests/ppapi_browser/extension_mime_handler/ppapi_extension_mime_handler.nmf b/ppapi/native_client/tests/ppapi_browser/extension_mime_handler/ppapi_extension_mime_handler.nmf
deleted file mode 100644
index 9fd22d4..0000000
--- a/ppapi/native_client/tests/ppapi_browser/extension_mime_handler/ppapi_extension_mime_handler.nmf
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "program": {
- "x86-32": {"url": "ppapi_extension_mime_handler_x86-32.nexe"},
- "x86-64": {"url": "ppapi_extension_mime_handler_x86-64.nexe"},
- "arm": {"url": "ppapi_extension_mime_handler_arm.nexe"}
- }
-}