diff --git a/chrome/browser/chrome_plugin_interactive_test.cc b/chrome/browser/chrome_plugin_interactive_test.cc deleted file mode 100644 index 57347309c46047..00000000000000 --- a/chrome/browser/chrome_plugin_interactive_test.cc +++ /dev/null @@ -1,234 +0,0 @@ -// Copyright 2014 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 "base/files/file_util.h" -#include "base/memory/ref_counted.h" -#include "base/prefs/pref_service.h" -#include "base/strings/utf_string_conversions.h" -#include "chrome/app/chrome_command_ids.h" -#include "chrome/browser/plugins/plugin_prefs.h" -#include "chrome/browser/profiles/profile.h" -#include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/browser_commands.h" -#include "chrome/browser/ui/find_bar/find_bar.h" -#include "chrome/browser/ui/find_bar/find_bar_controller.h" -#include "chrome/browser/ui/find_bar/find_bar_host_unittest_util.h" -#include "chrome/browser/ui/tabs/tab_strip_model.h" -#include "chrome/common/pref_names.h" -#include "chrome/test/base/in_process_browser_test.h" -#include "chrome/test/base/ui_test_utils.h" -#include "content/public/browser/browser_thread.h" -#include "content/public/browser/child_process_data.h" -#include "content/public/browser/plugin_service.h" -#include "content/public/browser/web_contents.h" -#include "content/public/common/content_constants.h" -#include "content/public/common/content_paths.h" -#include "content/public/common/process_type.h" -#include "content/public/common/webplugininfo.h" -#include "content/public/test/browser_test_utils.h" -#include "content/public/test/test_navigation_observer.h" -#include "content/public/test/test_utils.h" - -#if defined(OS_WIN) -#include "ui/aura/window.h" -#include "ui/aura/window_tree_host.h" -#endif - -#if defined(OS_WIN) - -namespace { - -BOOL CALLBACK EnumerateChildren(HWND hwnd, LPARAM l_param) { - HWND* child = reinterpret_cast(l_param); - *child = hwnd; - // The first child window is the plugin, then its children. So stop - // enumerating after the first callback. - return FALSE; -} - -} // namespace - -typedef InProcessBrowserTest ChromePluginTest; - -// Test that if a background tab loads an NPAPI plugin, they are displayed after -// switching to that page. http://crbug.com/335900 -// flaky: http://crbug.com/406631 -IN_PROC_BROWSER_TEST_F(ChromePluginTest, DISABLED_WindowedNPAPIPluginHidden) { - browser()->profile()->GetPrefs()->SetBoolean(prefs::kPluginsAlwaysAuthorize, - true); - - // First load the page in the background and wait for the NPAPI plugin's - // window to be created. - GURL url = ui_test_utils::GetTestUrl( - base::FilePath(), - base::FilePath().AppendASCII("windowed_npapi_plugin.html")); - - ui_test_utils::NavigateToURLWithDisposition( - browser(), url, NEW_BACKGROUND_TAB, - ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); - - // We create a third window just to trigger the second one to update its - // constrained window list. Normally this would be triggered by the status bar - // animation closing after the user middle clicked a link. - ui_test_utils::NavigateToURLWithDisposition( - browser(), GURL("about:blank"), NEW_BACKGROUND_TAB, - ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); - - base::string16 expected_title(base::ASCIIToUTF16("created")); - content::WebContents* tab = - browser()->tab_strip_model()->GetWebContentsAt(1); - if (tab->GetTitle() != expected_title) { - content::TitleWatcher title_watcher(tab, expected_title); - EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); - } - - // Now activate the tab and verify that the plugin painted. - browser()->tab_strip_model()->ActivateTabAt(1, true); - - base::string16 expected_title2(base::ASCIIToUTF16("shown")); - content::TitleWatcher title_watcher2(tab, expected_title2); - EXPECT_EQ(expected_title2, title_watcher2.WaitAndGetTitle()); - - HWND child = NULL; - HWND hwnd = tab->GetNativeView()->GetHost()->GetAcceleratedWidget(); - EnumChildWindows(hwnd, EnumerateChildren,reinterpret_cast(&child)); - - RECT region; - int result = GetWindowRgnBox(child, ®ion); - ASSERT_NE(result, NULLREGION); -} - -typedef InProcessBrowserTest PrintPreviewTest; - -// This test verifies that constrained windows aren't covered by windowed NPAPI -// plugins. The code which fixes this is in WebContentsViewAura::WindowObserver. -// flaky: http://crbug.com/406631 -IN_PROC_BROWSER_TEST_F(PrintPreviewTest, DISABLED_WindowedNPAPIPluginHidden) { - browser()->profile()->GetPrefs()->SetBoolean(prefs::kPluginsAlwaysAuthorize, - true); - - // First load the page and wait for the NPAPI plugin's window to display. - base::string16 expected_title(base::ASCIIToUTF16("ready")); - content::WebContents* tab = - browser()->tab_strip_model()->GetActiveWebContents(); - content::TitleWatcher title_watcher(tab, expected_title); - - GURL url = ui_test_utils::GetTestUrl( - base::FilePath().AppendASCII("printing"), - base::FilePath().AppendASCII("npapi_plugin.html")); - ui_test_utils::NavigateToURL(browser(), url); - - EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); - - // Now get the region of the plugin before and after the print preview is - // shown. They should be different. - HWND hwnd = tab->GetNativeView()->GetHost()->GetAcceleratedWidget(); - HWND child = NULL; - EnumChildWindows(hwnd, EnumerateChildren,reinterpret_cast(&child)); - - RECT region_before, region_after; - int result = GetWindowRgnBox(child, ®ion_before); - ASSERT_EQ(result, SIMPLEREGION); - - // Now print preview. - content::TestNavigationObserver nav_observer(NULL); - nav_observer.StartWatchingNewWebContents(); - chrome::ExecuteCommand(browser(), IDC_PRINT); - nav_observer.Wait(); - nav_observer.StopWatchingNewWebContents(); - - result = GetWindowRgnBox(child, ®ion_after); - if (result == NULLREGION) { - // Depending on the browser window size, the plugin could be full covered. - return; - } - - if (result == COMPLEXREGION) { - // Complex region, by definition not equal to the initial region. - return; - } - - ASSERT_EQ(result, SIMPLEREGION); - bool rects_equal = - region_before.left == region_after.left && - region_before.top == region_after.top && - region_before.right == region_after.right && - region_before.bottom == region_after.bottom; - ASSERT_FALSE(rects_equal); -} - -typedef InProcessBrowserTest FindInPageControllerTest; - -void EnsureFindBoxOpen(Browser* browser) { - chrome::ShowFindBar(browser); - gfx::Point position; - bool fully_visible = false; - FindBarTesting* find_bar = - browser->GetFindBarController()->find_bar()->GetFindBarTesting(); - EXPECT_TRUE(find_bar->GetFindBarWindowInfo(&position, &fully_visible)); - EXPECT_TRUE(fully_visible); -} - -// Ensure that the find bar is always over a windowed NPAPI plugin. -// flaky: http://crbug.com/406631 -IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, - DISABLED_WindowedNPAPIPluginHidden) { - chrome::DisableFindBarAnimationsDuringTesting(true); - browser()->profile()->GetPrefs()->SetBoolean(prefs::kPluginsAlwaysAuthorize, - true); - - // First load the page and wait for the NPAPI plugin's window to display. - base::string16 expected_title(base::ASCIIToUTF16("ready")); - content::WebContents* tab = - browser()->tab_strip_model()->GetActiveWebContents(); - content::TitleWatcher title_watcher(tab, expected_title); - - GURL url = ui_test_utils::GetTestUrl( - base::FilePath().AppendASCII("printing"), - base::FilePath().AppendASCII("npapi_plugin.html")); - ui_test_utils::NavigateToURL(browser(), url); - - EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); - - // Now get the region of the plugin before the find bar is shown. - HWND hwnd = tab->GetNativeView()->GetHost()->GetAcceleratedWidget(); - HWND child = NULL; - EnumChildWindows(hwnd, EnumerateChildren, reinterpret_cast(&child)); - - RECT region_before, region_after; - int result = GetWindowRgnBox(child, ®ion_before); - ASSERT_EQ(result, SIMPLEREGION); - - // Create a new tab and open the find bar there. - chrome::NewTab(browser()); - browser()->tab_strip_model()->ActivateTabAt(1, true); - ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL)); - - EnsureFindBoxOpen(browser()); - - // Now switch back to the original tab with the plugin and show the find bar. - browser()->tab_strip_model()->ActivateTabAt(0, true); - EnsureFindBoxOpen(browser()); - - result = GetWindowRgnBox(child, ®ion_after); - if (result == NULLREGION) { - // Depending on the browser window size, the plugin could be full covered. - return; - } - - if (result == COMPLEXREGION) { - // Complex region, by definition not equal to the initial region. - return; - } - - ASSERT_EQ(result, SIMPLEREGION); - bool rects_equal = - region_before.left == region_after.left && - region_before.top == region_after.top && - region_before.right == region_after.right && - region_before.bottom == region_after.bottom; - ASSERT_FALSE(rects_equal); -} - -#endif diff --git a/chrome/browser/content_settings/content_settings_browsertest.cc b/chrome/browser/content_settings/content_settings_browsertest.cc index 81155278b2e37a..6f15f49dd40b62 100644 --- a/chrome/browser/content_settings/content_settings_browsertest.cc +++ b/chrome/browser/content_settings/content_settings_browsertest.cc @@ -291,243 +291,6 @@ IN_PROC_BROWSER_TEST_F(ContentSettingsTest, RedirectCrossOrigin) { IsContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES)); } -// On Aura NPAPI only works on Windows. -#if !defined(USE_AURA) || defined(OS_WIN) - -class LoadPluginTest : public ContentSettingsTest { - protected: - void PerformTest(bool expect_loaded) { - GURL url = ui_test_utils::GetTestUrl( - base::FilePath(), - base::FilePath().AppendASCII("load_npapi_plugin.html")); - ui_test_utils::NavigateToURL(browser(), url); - - const char* expected_result = expect_loaded ? "Loaded" : "Not Loaded"; - const char* unexpected_result = expect_loaded ? "Not Loaded" : "Loaded"; - - base::string16 expected_title(base::ASCIIToUTF16(expected_result)); - base::string16 unexpected_title(base::ASCIIToUTF16(unexpected_result)); - - content::TitleWatcher title_watcher( - browser()->tab_strip_model()->GetActiveWebContents(), expected_title); - title_watcher.AlsoWaitForTitle(unexpected_title); - - EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); - } - - void SetUpCommandLineInternal(base::CommandLine* command_line, - bool expect_loaded) { -#if defined(OS_MACOSX) - base::FilePath plugin_dir; - PathService::Get(base::DIR_MODULE, &plugin_dir); - plugin_dir = plugin_dir.AppendASCII("plugins"); - // The plugins directory isn't read by default on the Mac, so it needs to be - // explicitly registered. - command_line->AppendSwitchPath(switches::kExtraPluginDir, plugin_dir); -#endif - command_line->AppendSwitch(switches::kAlwaysAuthorizePlugins); - if (expect_loaded) - command_line->AppendSwitch(switches::kEnableNpapiForTesting); - } -}; - -class DisabledPluginTest : public LoadPluginTest { - public: - DisabledPluginTest() {} - - void SetUpCommandLine(base::CommandLine* command_line) override { - SetUpCommandLineInternal(command_line, false); - } -}; - -IN_PROC_BROWSER_TEST_F(DisabledPluginTest, Load) { - PerformTest(false); -} - -class EnabledPluginTest : public LoadPluginTest { - public: - EnabledPluginTest() {} - - void SetUpCommandLine(base::CommandLine* command_line) override { - SetUpCommandLineInternal(command_line, true); - } -}; - -IN_PROC_BROWSER_TEST_F(EnabledPluginTest, Load) { - PerformTest(true); -} - -class ClickToPlayPluginTest : public ContentSettingsTest { - public: - ClickToPlayPluginTest() {} - - void SetUpCommandLine(base::CommandLine* command_line) override { -#if defined(OS_MACOSX) - base::FilePath plugin_dir; - PathService::Get(base::DIR_MODULE, &plugin_dir); - plugin_dir = plugin_dir.AppendASCII("plugins"); - // The plugins directory isn't read by default on the Mac, so it needs to be - // explicitly registered. - command_line->AppendSwitchPath(switches::kExtraPluginDir, plugin_dir); -#endif - command_line->AppendSwitch(switches::kEnableNpapiForTesting); - } -}; - -IN_PROC_BROWSER_TEST_F(ClickToPlayPluginTest, Basic) { - browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting( - CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_BLOCK); - - GURL url = ui_test_utils::GetTestUrl( - base::FilePath(), base::FilePath().AppendASCII("clicktoplay.html")); - ui_test_utils::NavigateToURL(browser(), url); - - base::string16 expected_title(base::ASCIIToUTF16("OK")); - content::TitleWatcher title_watcher( - browser()->tab_strip_model()->GetActiveWebContents(), expected_title); - - content::WebContents* web_contents = - browser()->tab_strip_model()->GetActiveWebContents(); - ChromePluginServiceFilter* filter = ChromePluginServiceFilter::GetInstance(); - int process_id = web_contents->GetMainFrame()->GetProcess()->GetID(); - base::FilePath path(FILE_PATH_LITERAL("blah")); - EXPECT_FALSE(filter->CanLoadPlugin(process_id, path)); - filter->AuthorizeAllPlugins(web_contents, true, std::string()); - EXPECT_TRUE(filter->CanLoadPlugin(process_id, path)); - - EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); -} - -// Verify that plugins can be allowed on a domain by adding an exception -IN_PROC_BROWSER_TEST_F(ClickToPlayPluginTest, AllowException) { - GURL url = ui_test_utils::GetTestUrl( - base::FilePath(), base::FilePath().AppendASCII("clicktoplay.html")); - - browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting( - CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_BLOCK); - browser()->profile()->GetHostContentSettingsMap() - ->SetContentSetting(ContentSettingsPattern::FromURL(url), - ContentSettingsPattern::Wildcard(), - CONTENT_SETTINGS_TYPE_PLUGINS, - std::string(), - CONTENT_SETTING_ALLOW); - - base::string16 expected_title(base::ASCIIToUTF16("OK")); - content::TitleWatcher title_watcher( - browser()->tab_strip_model()->GetActiveWebContents(), expected_title); - ui_test_utils::NavigateToURL(browser(), url); - EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); -} - -// Verify that plugins can be blocked on a domain by adding an exception. -IN_PROC_BROWSER_TEST_F(ClickToPlayPluginTest, BlockException) { - GURL url = ui_test_utils::GetTestUrl( - base::FilePath(), base::FilePath().AppendASCII("clicktoplay.html")); - - browser()->profile()->GetHostContentSettingsMap() - ->SetContentSetting(ContentSettingsPattern::FromURL(url), - ContentSettingsPattern::Wildcard(), - CONTENT_SETTINGS_TYPE_PLUGINS, - std::string(), - CONTENT_SETTING_BLOCK); - - base::string16 expected_title(base::ASCIIToUTF16("Click To Play")); - content::TitleWatcher title_watcher( - browser()->tab_strip_model()->GetActiveWebContents(), expected_title); - ui_test_utils::NavigateToURL(browser(), url); - EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); -} - -// Crashes on Mac Asan. http://crbug.com/239169 -#if defined(OS_MACOSX) -#define MAYBE_LoadAllBlockedPlugins DISABLED_LoadAllBlockedPlugins -// TODO(jschuh): Flaky plugin tests. crbug.com/244653 -#elif defined(OS_WIN) && defined(ARCH_CPU_X86_64) -#define MAYBE_LoadAllBlockedPlugins DISABLED_LoadAllBlockedPlugins -#else -#define MAYBE_LoadAllBlockedPlugins LoadAllBlockedPlugins -#endif -IN_PROC_BROWSER_TEST_F(ClickToPlayPluginTest, MAYBE_LoadAllBlockedPlugins) { - browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting( - CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_BLOCK); - - GURL url = ui_test_utils::GetTestUrl( - base::FilePath(), - base::FilePath().AppendASCII("load_all_blocked_plugins.html")); - ui_test_utils::NavigateToURL(browser(), url); - - base::string16 expected_title1(base::ASCIIToUTF16("1")); - content::TitleWatcher title_watcher1( - browser()->tab_strip_model()->GetActiveWebContents(), expected_title1); - - ChromePluginServiceFilter::GetInstance()->AuthorizeAllPlugins( - browser()->tab_strip_model()->GetActiveWebContents(), true, - std::string()); - EXPECT_EQ(expected_title1, title_watcher1.WaitAndGetTitle()); - - base::string16 expected_title2(base::ASCIIToUTF16("2")); - content::TitleWatcher title_watcher2( - browser()->tab_strip_model()->GetActiveWebContents(), expected_title2); - - ASSERT_TRUE(content::ExecuteScript( - browser()->tab_strip_model()->GetActiveWebContents(), "window.inject()")); - - EXPECT_EQ(expected_title2, title_watcher2.WaitAndGetTitle()); -} - -// If this flakes, use http://crbug.com/113057. -// TODO(jschuh): Hanging plugin tests. crbug.com/244653 -#if !defined(OS_WIN) && !defined(ARCH_CPU_X86_64) -IN_PROC_BROWSER_TEST_F(ClickToPlayPluginTest, NoCallbackAtLoad) { - browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting( - CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_BLOCK); - - GURL url("data:application/vnd.npapi-test,CallOnStartup();"); - ui_test_utils::NavigateToURL(browser(), url); - - std::string script("CallOnStartup = function() { "); - script.append("document.documentElement.appendChild"); - script.append("(document.createElement(\"head\")); "); - script.append("document.title = \"OK\"; }"); - - // Inject the callback function into the HTML page generated by the browser. - ASSERT_TRUE(content::ExecuteScript( - browser()->tab_strip_model()->GetActiveWebContents(), script)); - - base::string16 expected_title(base::ASCIIToUTF16("OK")); - content::TitleWatcher title_watcher( - browser()->tab_strip_model()->GetActiveWebContents(), expected_title); - - ChromePluginServiceFilter::GetInstance()->AuthorizeAllPlugins( - browser()->tab_strip_model()->GetActiveWebContents(), true, - std::string()); - - EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); -} -#endif - -IN_PROC_BROWSER_TEST_F(ClickToPlayPluginTest, DeleteSelfAtLoad) { - browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting( - CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_BLOCK); - - GURL url = ui_test_utils::GetTestUrl( - base::FilePath(), - base::FilePath().AppendASCII("plugin_delete_self_at_load.html")); - ui_test_utils::NavigateToURL(browser(), url); - - base::string16 expected_title(base::ASCIIToUTF16("OK")); - content::TitleWatcher title_watcher( - browser()->tab_strip_model()->GetActiveWebContents(), expected_title); - - ChromePluginServiceFilter::GetInstance()->AuthorizeAllPlugins( - browser()->tab_strip_model()->GetActiveWebContents(), true, - std::string()); - - EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); -} - -#endif // !defined(USE_AURA) || defined(OS_WIN) - #if defined(ENABLE_PLUGINS) class PepperContentSettingsSpecialCasesTest : public ContentSettingsTest { protected: diff --git a/chrome/browser/ui/views/location_bar/star_view_browsertest.cc b/chrome/browser/ui/views/location_bar/star_view_browsertest.cc index c0b7b21b05d5a7..b7f6fc58d85fe0 100644 --- a/chrome/browser/ui/views/location_bar/star_view_browsertest.cc +++ b/chrome/browser/ui/views/location_bar/star_view_browsertest.cc @@ -67,99 +67,4 @@ IN_PROC_BROWSER_TEST_F(StarViewTest, MAYBE_HideOnSecondClick) { EXPECT_FALSE(BookmarkBubbleView::bookmark_bubble()); } -#if defined(OS_WIN) - -class StarViewTestNoDWM : public InProcessBrowserTest { - public: - StarViewTestNoDWM() {} - - void SetUpCommandLine(base::CommandLine* command_line) override { - command_line->AppendSwitch(switches::kDisableDwmComposition); - } -}; - -BOOL CALLBACK EnumerateChildren(HWND hwnd, LPARAM l_param) { - HWND* child = reinterpret_cast(l_param); - *child = hwnd; - // The first child window is the plugin, then its children. So stop - // enumerating after the first callback. - return FALSE; -} - -// Ensure that UIs like the star window, user profiler picker, omnibox -// popup and bookmark editor are always over a windowed NPAPI plugin even if -// kDisableDwmComposition is used. -// flaky: http://crbug.com/406631 -IN_PROC_BROWSER_TEST_F(StarViewTestNoDWM, DISABLED_WindowedNPAPIPluginHidden) { - browser()->profile()->GetPrefs()->SetBoolean(prefs::kPluginsAlwaysAuthorize, - true); - - // First switch to a new tab and back, to also test a scenario where we - // stopped watching the root window. - ui_test_utils::NavigateToURLWithDisposition( - browser(), GURL("about:blank"), NEW_FOREGROUND_TAB, - ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); - browser()->tab_strip_model()->ActivateTabAt(0, true); - - // First load the page and wait for the NPAPI plugin's window to display. - base::string16 expected_title(base::ASCIIToUTF16("ready")); - content::WebContents* tab = - browser()->tab_strip_model()->GetActiveWebContents(); - content::TitleWatcher title_watcher(tab, expected_title); - - GURL url = ui_test_utils::GetTestUrl( - base::FilePath().AppendASCII("printing"), - base::FilePath().AppendASCII("npapi_plugin.html")); - ui_test_utils::NavigateToURL(browser(), url); - EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); - - // Now get the region of the plugin before the star view is shown. - HWND hwnd = tab->GetNativeView()->GetHost()->GetAcceleratedWidget(); - HWND child = NULL; - EnumChildWindows(hwnd, EnumerateChildren,reinterpret_cast(&child)); - - RECT region_before, region_after; - int result = GetWindowRgnBox(child, ®ion_before); - ASSERT_EQ(result, SIMPLEREGION); - - // Now show the star view - BrowserView* browser_view = reinterpret_cast( - browser()->window()); - views::ImageView* star_view = - browser_view->GetToolbarView()->location_bar()->star_view(); - - scoped_refptr runner = - new content::MessageLoopRunner; - // Verify that clicking once shows the bookmark bubble. - ui_test_utils::MoveMouseToCenterAndPress( - star_view, - ui_controls::LEFT, - ui_controls::DOWN | ui_controls::UP, - runner->QuitClosure()); - runner->Run(); - - EXPECT_TRUE(BookmarkBubbleView::bookmark_bubble()); - - result = GetWindowRgnBox(child, ®ion_after); - if (result == NULLREGION) { - // Depending on the browser window size, the plugin could be full covered. - return; - } - - if (result == COMPLEXREGION) { - // Complex region, by definition not equal to the initial region. - return; - } - - ASSERT_EQ(result, SIMPLEREGION); - bool rects_equal = - region_before.left == region_after.left && - region_before.top == region_after.top && - region_before.right == region_after.right && - region_before.bottom == region_after.bottom; - ASSERT_FALSE(rects_equal); -} - -#endif - } // namespace diff --git a/chrome/browser_tests.isolate b/chrome/browser_tests.isolate index 081cf1bf51b14e..0cff82a8219e92 100644 --- a/chrome/browser_tests.isolate +++ b/chrome/browser_tests.isolate @@ -183,7 +183,6 @@ '<(PRODUCT_DIR)/content_shell.pak', '<(PRODUCT_DIR)/libclearkeycdm.dylib', '<(PRODUCT_DIR)/osmesa.so', - '<(PRODUCT_DIR)/plugins/npapi_test_plugin.plugin/', '<(PRODUCT_DIR)/plugins/test_netscape_plugin.plugin/', '<(PRODUCT_DIR)/power_saver_test_plugin.plugin/Contents/MacOS/power_saver_test_plugin', '<(PRODUCT_DIR)/ppapi_tests.plugin/Contents/MacOS/ppapi_tests', diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 13fd3b1567bef4..77de6871b675a3 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -941,7 +941,6 @@ 'browser/autofill/autofill_interactive_uitest.cc', 'browser/autofill/autofill_uitest_util.cc', 'browser/browser_keyevents_browsertest.cc', - 'browser/chrome_plugin_interactive_test.cc', 'browser/extensions/api/extension_action/browser_action_interactive_test.cc', 'browser/extensions/api/omnibox/omnibox_api_interactive_test.cc', 'browser/extensions/browsertest_util.cc', @@ -2411,13 +2410,6 @@ '../v8/src/d8.gyp:d8#host', ], }], - ['OS!="android" and OS!="ios" and OS!="linux"', { - # npapi test plugin doesn't build on android or ios - 'dependencies': [ - # build time dependency. - '../content/content_shell_and_tests.gyp:copy_npapi_test_plugin', - ], - }], ['enable_app_list==1', { 'sources': [ '<@(chrome_browser_tests_app_list_sources)' ], }, { diff --git a/chrome/interactive_ui_tests.isolate b/chrome/interactive_ui_tests.isolate index f013ef66575bbf..1a5c74bf0e13f1 100644 --- a/chrome/interactive_ui_tests.isolate +++ b/chrome/interactive_ui_tests.isolate @@ -100,7 +100,6 @@ '<(PRODUCT_DIR)/libEGL.dll', '<(PRODUCT_DIR)/libGLESv2.dll', '<(PRODUCT_DIR)/osmesa.dll', - '<(PRODUCT_DIR)/plugins/npapi_test_plugin.dll', '<(PRODUCT_DIR)/ppapi_tests.dll', ], }, diff --git a/chrome/test/BUILD.gn b/chrome/test/BUILD.gn index 675e14c528bdd2..9276818424c545 100644 --- a/chrome/test/BUILD.gn +++ b/chrome/test/BUILD.gn @@ -970,12 +970,6 @@ if (!is_android) { [ "../browser/copresence/chrome_whispernet_client_browsertest.cc" ] deps += [ "//components/copresence" ] } - if (!is_android && !is_ios && !is_linux) { - # NPAPI test plugin only works on some platforms. - data_deps += [ - #'../content/content_shell_and_tests.gyp:copy_npapi_test_plugin', TODO(GYP) - ] - } if (enable_app_list) { sources += rebase_path( chrome_tests_gypi_values.chrome_browser_tests_app_list_sources, diff --git a/chrome/test/data/load_all_blocked_plugins.html b/chrome/test/data/load_all_blocked_plugins.html deleted file mode 100644 index 8ae05db69cb81b..00000000000000 --- a/chrome/test/data/load_all_blocked_plugins.html +++ /dev/null @@ -1,24 +0,0 @@ - - - - - -
- - diff --git a/chrome/test/data/load_npapi_plugin.html b/chrome/test/data/load_npapi_plugin.html deleted file mode 100644 index 2b91f5fb6b6743..00000000000000 --- a/chrome/test/data/load_npapi_plugin.html +++ /dev/null @@ -1,31 +0,0 @@ - - -Initial Title - - - -
- - - diff --git a/chrome/test/data/plugin_delete_self_at_load.html b/chrome/test/data/plugin_delete_self_at_load.html deleted file mode 100644 index 50805a25e4c869..00000000000000 --- a/chrome/test/data/plugin_delete_self_at_load.html +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - diff --git a/chrome/test/data/printing/npapi_plugin.html b/chrome/test/data/printing/npapi_plugin.html deleted file mode 100644 index afbb9aad60b072..00000000000000 --- a/chrome/test/data/printing/npapi_plugin.html +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - diff --git a/chrome/test/data/windowed_npapi_plugin.html b/chrome/test/data/windowed_npapi_plugin.html deleted file mode 100644 index 1a0cc4b58406f9..00000000000000 --- a/chrome/test/data/windowed_npapi_plugin.html +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - diff --git a/content/browser/plugin_data_remover_impl_browsertest.cc b/content/browser/plugin_data_remover_impl_browsertest.cc deleted file mode 100644 index da502672b8d4c5..00000000000000 --- a/content/browser/plugin_data_remover_impl_browsertest.cc +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (c) 2012 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 "base/base_paths.h" -#include "base/callback.h" -#include "base/command_line.h" -#include "base/path_service.h" -#include "base/synchronization/waitable_event_watcher.h" -#include "content/browser/plugin_data_remover_impl.h" -#include "content/public/browser/web_contents.h" -#include "content/public/common/content_switches.h" -#include "content/public/test/content_browser_test.h" -#include "content/public/test/test_utils.h" -#include "content/shell/browser/shell.h" - -namespace content { - -namespace { -const char* kNPAPITestPluginMimeType = "application/vnd.npapi-test"; -} - -class PluginDataRemoverTest : public ContentBrowserTest { - public: - PluginDataRemoverTest() {} - - void OnWaitableEventSignaled(base::WaitableEvent* waitable_event) { - base::MessageLoop::current()->Quit(); - } - - void SetUpCommandLine(base::CommandLine* command_line) override { -#if defined(OS_MACOSX) - base::FilePath browser_directory; - PathService::Get(base::DIR_MODULE, &browser_directory); - command_line->AppendSwitchPath(switches::kExtraPluginDir, - browser_directory.AppendASCII("plugins")); -#endif - // TODO(jam): since these plugin tests are running under Chrome, we need to - // tell it to disable its security features for old plugins. Once this is - // running under content_browsertests, these flags won't be needed. - // http://crbug.com/90448 - // switches::kAlwaysAuthorizePlugins - command_line->AppendSwitch("always-authorize-plugins"); - } -}; - -IN_PROC_BROWSER_TEST_F(PluginDataRemoverTest, RemoveData) { - PluginDataRemoverImpl plugin_data_remover( - shell()->web_contents()->GetBrowserContext()); - plugin_data_remover.set_mime_type(kNPAPITestPluginMimeType); - base::WaitableEventWatcher watcher; - base::WaitableEvent* event = - plugin_data_remover.StartRemoving(base::Time()); - watcher.StartWatching( - event, - base::Bind(&PluginDataRemoverTest::OnWaitableEventSignaled, this)); - RunMessageLoop(); -} - -} // namespace content diff --git a/content/browser/plugin_service_impl_browsertest.cc b/content/browser/plugin_service_impl_browsertest.cc deleted file mode 100644 index 9c1e9f172fdb4d..00000000000000 --- a/content/browser/plugin_service_impl_browsertest.cc +++ /dev/null @@ -1,370 +0,0 @@ -// Copyright (c) 2012 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 "content/browser/plugin_service_impl.h" - -#include "base/bind.h" -#include "base/bind_helpers.h" -#include "base/command_line.h" -#include "base/location.h" -#include "base/path_service.h" -#include "base/single_thread_task_runner.h" -#include "base/thread_task_runner_handle.h" -#include "content/public/browser/browser_context.h" -#include "content/public/browser/plugin_service_filter.h" -#include "content/public/browser/resource_context.h" -#include "content/public/browser/web_contents.h" -#include "content/public/common/content_switches.h" -#include "content/public/test/content_browser_test.h" -#include "content/public/test/test_browser_thread.h" -#include "content/public/test/test_utils.h" -#include "content/shell/browser/shell.h" -#include "testing/gmock/include/gmock/gmock.h" - -namespace content { - -const char kNPAPITestPluginMimeType[] = "application/vnd.npapi-test"; - -void OpenChannel(PluginProcessHost::Client* client) { - DCHECK_CURRENTLY_ON(BrowserThread::IO); - // Start opening the channel - PluginServiceImpl::GetInstance()->OpenChannelToNpapiPlugin( - 0, 0, GURL(), GURL(), kNPAPITestPluginMimeType, client); -} - -// Mock up of the Client and the Listener classes that would supply the -// communication channel with the plugin. -class MockPluginProcessHostClient : public PluginProcessHost::Client, - public IPC::Listener { - public: - MockPluginProcessHostClient(ResourceContext* context, bool expect_fail) - : context_(context), - channel_(NULL), - set_plugin_info_called_(false), - expect_fail_(expect_fail) { - } - - ~MockPluginProcessHostClient() override { - if (channel_) - BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, channel_); - } - - // PluginProcessHost::Client implementation. - int ID() override { return 42; } - bool OffTheRecord() override { return false; } - ResourceContext* GetResourceContext() override { return context_; } - void OnFoundPluginProcessHost(PluginProcessHost* host) override {} - void OnSentPluginChannelRequest() override {} - - void OnChannelOpened(const IPC::ChannelHandle& handle) override { - ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); - ASSERT_TRUE(set_plugin_info_called_); - ASSERT_TRUE(!channel_); - channel_ = IPC::Channel::CreateClient(handle, this).release(); - ASSERT_TRUE(channel_->Connect()); - } - - void SetPluginInfo(const WebPluginInfo& info) override { - ASSERT_TRUE(info.mime_types.size()); - ASSERT_EQ(kNPAPITestPluginMimeType, info.mime_types[0].mime_type); - set_plugin_info_called_ = true; - } - - void OnError() override { Fail(); } - - // IPC::Listener implementation. - bool OnMessageReceived(const IPC::Message& message) override { - Fail(); - return false; - } - void OnChannelConnected(int32 peer_pid) override { - if (expect_fail_) - FAIL(); - QuitMessageLoop(); - } - void OnChannelError() override { Fail(); } -#if defined(OS_POSIX) - void OnChannelDenied() override { Fail(); } - void OnChannelListenError() override { Fail(); } -#endif - - private: - void Fail() { - if (!expect_fail_) - FAIL(); - QuitMessageLoop(); - } - - void QuitMessageLoop() { - BrowserThread::PostTask( - BrowserThread::UI, FROM_HERE, base::MessageLoop::QuitClosure()); - } - - ResourceContext* context_; - IPC::Channel* channel_; - bool set_plugin_info_called_; - bool expect_fail_; - DISALLOW_COPY_AND_ASSIGN(MockPluginProcessHostClient); -}; - -class MockPluginServiceFilter : public content::PluginServiceFilter { - public: - MockPluginServiceFilter() {} - - bool IsPluginAvailable(int render_process_id, - int render_view_id, - const void* context, - const GURL& url, - const GURL& policy_url, - WebPluginInfo* plugin) override { - return true; - } - - bool CanLoadPlugin(int render_process_id, - const base::FilePath& path) override { - return false; - } -}; - -class PluginServiceTest : public ContentBrowserTest { - public: - PluginServiceTest() {} - - ResourceContext* GetResourceContext() { - return shell()->web_contents()->GetBrowserContext()->GetResourceContext(); - } - - void SetUpCommandLine(base::CommandLine* command_line) override { -#if defined(OS_MACOSX) - base::FilePath browser_directory; - PathService::Get(base::DIR_MODULE, &browser_directory); - command_line->AppendSwitchPath(switches::kExtraPluginDir, - browser_directory.AppendASCII("plugins")); -#endif - // TODO(jam): since these plugin tests are running under Chrome, we need to - // tell it to disable its security features for old plugins. Once this is - // running under content_browsertests, these flags won't be needed. - // http://crbug.com/90448 - // switches::kAlwaysAuthorizePlugins - command_line->AppendSwitch("always-authorize-plugins"); - } -}; - -// Try to open a channel to the test plugin. Minimal plugin process spawning -// test for the PluginService interface. -IN_PROC_BROWSER_TEST_F(PluginServiceTest, OpenChannelToPlugin) { - if (!PluginServiceImpl::GetInstance()->NPAPIPluginsSupported()) - return; - MockPluginProcessHostClient mock_client(GetResourceContext(), false); - BrowserThread::PostTask( - BrowserThread::IO, FROM_HERE, - base::Bind(&OpenChannel, &mock_client)); - RunMessageLoop(); -} - -IN_PROC_BROWSER_TEST_F(PluginServiceTest, OpenChannelToDeniedPlugin) { - if (!PluginServiceImpl::GetInstance()->NPAPIPluginsSupported()) - return; - MockPluginServiceFilter filter; - PluginServiceImpl::GetInstance()->SetFilter(&filter); - MockPluginProcessHostClient mock_client(GetResourceContext(), true); - BrowserThread::PostTask( - BrowserThread::IO, FROM_HERE, - base::Bind(&OpenChannel, &mock_client)); - RunMessageLoop(); -} - -// A strict mock that fails if any of the methods are called. They shouldn't be -// called since the request should get canceled before then. -class MockCanceledPluginServiceClient : public PluginProcessHost::Client { - public: - MockCanceledPluginServiceClient(ResourceContext* context) - : context_(context), - get_resource_context_called_(false) { - } - - ~MockCanceledPluginServiceClient() override {} - - // Client implementation. - MOCK_METHOD0(ID, int()); - ResourceContext* GetResourceContext() override { - get_resource_context_called_ = true; - return context_; - } - MOCK_METHOD0(OffTheRecord, bool()); - MOCK_METHOD1(OnFoundPluginProcessHost, void(PluginProcessHost* host)); - MOCK_METHOD0(OnSentPluginChannelRequest, void()); - MOCK_METHOD1(OnChannelOpened, void(const IPC::ChannelHandle& handle)); - MOCK_METHOD1(SetPluginInfo, void(const WebPluginInfo& info)); - MOCK_METHOD0(OnError, void()); - - bool get_resource_context_called() const { - return get_resource_context_called_; - } - - private: - ResourceContext* context_; - bool get_resource_context_called_; - - DISALLOW_COPY_AND_ASSIGN(MockCanceledPluginServiceClient); -}; - -void QuitUIMessageLoopFromIOThread() { - BrowserThread::PostTask( - BrowserThread::UI, FROM_HERE, base::MessageLoop::QuitClosure()); -} - -void OpenChannelAndThenCancel(PluginProcessHost::Client* client) { - OpenChannel(client); - // Immediately cancel it. This is guaranteed to work since PluginService needs - // to consult its filter on the FILE thread. - PluginServiceImpl::GetInstance()->CancelOpenChannelToNpapiPlugin(client); - // Before we terminate the test, add a roundtrip through the FILE thread to - // make sure that it's had a chance to post back to the IO thread. Then signal - // the UI thread to stop and exit the test. - BrowserThread::PostTaskAndReply( - BrowserThread::FILE, FROM_HERE, - base::Bind(&base::DoNothing), - base::Bind(&QuitUIMessageLoopFromIOThread)); -} - -// Should not attempt to open a channel, since it should be canceled early on. -IN_PROC_BROWSER_TEST_F(PluginServiceTest, CancelOpenChannelToPluginService) { - ::testing::StrictMock mock_client( - GetResourceContext()); - BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, - base::Bind(OpenChannelAndThenCancel, &mock_client)); - RunMessageLoop(); - EXPECT_TRUE(mock_client.get_resource_context_called()); -} - -class MockCanceledBeforeSentPluginProcessHostClient - : public MockCanceledPluginServiceClient { - public: - MockCanceledBeforeSentPluginProcessHostClient( - ResourceContext* context) - : MockCanceledPluginServiceClient(context), - set_plugin_info_called_(false), - on_found_plugin_process_host_called_(false), - host_(NULL) {} - - ~MockCanceledBeforeSentPluginProcessHostClient() override {} - - // Client implementation. - void SetPluginInfo(const WebPluginInfo& info) override { - DCHECK_CURRENTLY_ON(BrowserThread::IO); - ASSERT_TRUE(info.mime_types.size()); - ASSERT_EQ(kNPAPITestPluginMimeType, info.mime_types[0].mime_type); - set_plugin_info_called_ = true; - } - void OnFoundPluginProcessHost(PluginProcessHost* host) override { - DCHECK_CURRENTLY_ON(BrowserThread::IO); - set_on_found_plugin_process_host_called(); - set_host(host); - // This gets called right before we request the plugin<=>renderer channel, - // so we have to post a task to cancel it. - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::Bind(&PluginProcessHost::CancelPendingRequest, - base::Unretained(host), this)); - base::ThreadTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::Bind(&QuitUIMessageLoopFromIOThread)); - } - - bool set_plugin_info_called() const { - return set_plugin_info_called_; - } - - bool on_found_plugin_process_host_called() const { - return on_found_plugin_process_host_called_; - } - - protected: - void set_on_found_plugin_process_host_called() { - on_found_plugin_process_host_called_ = true; - } - void set_host(PluginProcessHost* host) { - host_ = host; - } - - PluginProcessHost* host() const { return host_; } - - private: - bool set_plugin_info_called_; - bool on_found_plugin_process_host_called_; - PluginProcessHost* host_; - - DISALLOW_COPY_AND_ASSIGN(MockCanceledBeforeSentPluginProcessHostClient); -}; - -IN_PROC_BROWSER_TEST_F( - PluginServiceTest, CancelBeforeSentOpenChannelToPluginProcessHost) { - if (!PluginServiceImpl::GetInstance()->NPAPIPluginsSupported()) - return; - ::testing::StrictMock - mock_client(GetResourceContext()); - BrowserThread::PostTask( - BrowserThread::IO, FROM_HERE, - base::Bind(&OpenChannel, &mock_client)); - RunMessageLoop(); - EXPECT_TRUE(mock_client.get_resource_context_called()); - EXPECT_TRUE(mock_client.set_plugin_info_called()); - EXPECT_TRUE(mock_client.on_found_plugin_process_host_called()); -} - -class MockCanceledAfterSentPluginProcessHostClient - : public MockCanceledBeforeSentPluginProcessHostClient { - public: - MockCanceledAfterSentPluginProcessHostClient( - ResourceContext* context) - : MockCanceledBeforeSentPluginProcessHostClient(context), - on_sent_plugin_channel_request_called_(false) {} - ~MockCanceledAfterSentPluginProcessHostClient() override {} - - // Client implementation. - - int ID() override { return 42; } - bool OffTheRecord() override { return false; } - - // We override this guy again since we don't want to cancel yet. - void OnFoundPluginProcessHost(PluginProcessHost* host) override { - DCHECK_CURRENTLY_ON(BrowserThread::IO); - set_on_found_plugin_process_host_called(); - set_host(host); - } - - void OnSentPluginChannelRequest() override { - on_sent_plugin_channel_request_called_ = true; - host()->CancelSentRequest(this); - BrowserThread::PostTask( - BrowserThread::UI, FROM_HERE, base::MessageLoop::QuitClosure()); - } - - bool on_sent_plugin_channel_request_called() const { - return on_sent_plugin_channel_request_called_; - } - - private: - bool on_sent_plugin_channel_request_called_; - - DISALLOW_COPY_AND_ASSIGN(MockCanceledAfterSentPluginProcessHostClient); -}; - -// Should not attempt to open a channel, since it should be canceled early on. -IN_PROC_BROWSER_TEST_F( - PluginServiceTest, CancelAfterSentOpenChannelToPluginProcessHost) { - if (!PluginServiceImpl::GetInstance()->NPAPIPluginsSupported()) - return; - ::testing::StrictMock - mock_client(GetResourceContext()); - BrowserThread::PostTask( - BrowserThread::IO, FROM_HERE, - base::Bind(&OpenChannel, &mock_client)); - RunMessageLoop(); - EXPECT_TRUE(mock_client.get_resource_context_called()); - EXPECT_TRUE(mock_client.set_plugin_info_called()); - EXPECT_TRUE(mock_client.on_found_plugin_process_host_called()); - EXPECT_TRUE(mock_client.on_sent_plugin_channel_request_called()); -} - -} // namespace content diff --git a/content/content_browsertests.isolate b/content/content_browsertests.isolate index a6f069f7329a1a..9f0fc4f17046c0 100644 --- a/content/content_browsertests.isolate +++ b/content/content_browsertests.isolate @@ -95,7 +95,6 @@ 'variables': { 'files': [ '<(PRODUCT_DIR)/Content Shell.app/', - '<(PRODUCT_DIR)/plugins/npapi_test_plugin.plugin/', '<(PRODUCT_DIR)/plugins/test_netscape_plugin.plugin/', '<(PRODUCT_DIR)/ppapi_tests.plugin/Contents/MacOS/ppapi_tests', ], @@ -108,7 +107,6 @@ '<(PRODUCT_DIR)/Content Shell Helper.app.dSYM/', '<(PRODUCT_DIR)/Content Shell.app.dSYM/', '<(PRODUCT_DIR)/content_browsertests.dSYM/', - '<(PRODUCT_DIR)/npapi_test_plugin.plugin.dSYM/', '<(PRODUCT_DIR)/ppapi_tests.plugin.dSYM/', '<(PRODUCT_DIR)/test_netscape_plugin.plugin.dSYM/', ], @@ -120,7 +118,6 @@ '<(PRODUCT_DIR)/content_shell.pak', '<(PRODUCT_DIR)/osmesa.dll', '<(PRODUCT_DIR)/plugins/np_test_netscape_plugin.dll', - '<(PRODUCT_DIR)/plugins/npapi_test_plugin.dll', '<(PRODUCT_DIR)/ppapi_tests.dll', ], }, diff --git a/content/content_tests.gypi b/content/content_tests.gypi index 33a722cf5d27cc..9b868f524ea794 100644 --- a/content/content_tests.gypi +++ b/content/content_tests.gypi @@ -285,8 +285,6 @@ 'test/webrtc_content_browsertest_base.h', ], 'content_browsertests_plugins_sources': [ - 'browser/plugin_data_remover_impl_browsertest.cc', - 'browser/plugin_service_impl_browsertest.cc', 'renderer/pepper/fake_pepper_plugin_instance.cc', 'renderer/pepper/mock_renderer_ppapi_host.cc', 'renderer/pepper/pepper_device_enumeration_host_helper_unittest.cc', @@ -1496,13 +1494,6 @@ 'browser/compositor/image_transport_factory_browsertest.cc', ], }], - ['OS!="android" and OS!="ios" and OS!="linux"', { - # npapi test plugin doesn't build on android or ios - 'dependencies': [ - # Runtime dependencies - 'copy_npapi_test_plugin', - ], - }], ['enable_webrtc==1', { 'sources': [ '<@(content_browsertests_webrtc_sources)' ], 'dependencies': [ @@ -2062,149 +2053,5 @@ }, ], }], - ['OS!="android" and OS!="ios" and OS!="linux"', { - # npapi test plugin doesn't build on android or ios - 'targets': [ - { - 'target_name': 'npapi_test_plugin', - 'type': 'loadable_module', - 'variables': { - 'chromium_code': 1, - }, - 'mac_bundle': 1, - 'dependencies': [ - '<(DEPTH)/base/base.gyp:base', - '<(DEPTH)/third_party/icu/icu.gyp:icuuc', - '<(DEPTH)/third_party/npapi/npapi.gyp:npapi', - ], - 'sources': [ - 'test/plugin/npapi_constants.cc', - 'test/plugin/npapi_constants.h', - 'test/plugin/npapi_test.cc', - 'test/plugin/npapi_test.def', - 'test/plugin/npapi_test.rc', - 'test/plugin/plugin_arguments_test.cc', - 'test/plugin/plugin_arguments_test.h', - 'test/plugin/plugin_client.cc', - 'test/plugin/plugin_client.h', - 'test/plugin/plugin_create_instance_in_paint.cc', - 'test/plugin/plugin_create_instance_in_paint.h', - 'test/plugin/plugin_delete_plugin_in_deallocate_test.cc', - 'test/plugin/plugin_delete_plugin_in_deallocate_test.h', - 'test/plugin/plugin_delete_plugin_in_stream_test.cc', - 'test/plugin/plugin_delete_plugin_in_stream_test.h', - 'test/plugin/plugin_execute_stream_javascript.cc', - 'test/plugin/plugin_execute_stream_javascript.h', - 'test/plugin/plugin_get_javascript_url2_test.cc', - 'test/plugin/plugin_get_javascript_url2_test.h', - 'test/plugin/plugin_get_javascript_url_test.cc', - 'test/plugin/plugin_get_javascript_url_test.h', - 'test/plugin/plugin_geturl_test.cc', - 'test/plugin/plugin_geturl_test.h', - 'test/plugin/plugin_javascript_open_popup.cc', - 'test/plugin/plugin_javascript_open_popup.h', - 'test/plugin/plugin_new_fails_test.cc', - 'test/plugin/plugin_new_fails_test.h', - 'test/plugin/plugin_npobject_identity_test.cc', - 'test/plugin/plugin_npobject_identity_test.h', - 'test/plugin/plugin_npobject_lifetime_test.cc', - 'test/plugin/plugin_npobject_lifetime_test.h', - 'test/plugin/plugin_npobject_proxy_test.cc', - 'test/plugin/plugin_npobject_proxy_test.h', - 'test/plugin/plugin_private_test.cc', - 'test/plugin/plugin_private_test.h', - 'test/plugin/plugin_request_read_test.cc', - 'test/plugin/plugin_request_read_test.h', - 'test/plugin/plugin_schedule_timer_test.cc', - 'test/plugin/plugin_schedule_timer_test.h', - 'test/plugin/plugin_setup_test.cc', - 'test/plugin/plugin_setup_test.h', - 'test/plugin/plugin_test.cc', - 'test/plugin/plugin_test.h', - 'test/plugin/plugin_test_factory.cc', - 'test/plugin/plugin_test_factory.h', - 'test/plugin/plugin_thread_async_call_test.cc', - 'test/plugin/plugin_thread_async_call_test.h', - 'test/plugin/plugin_window_size_test.cc', - 'test/plugin/plugin_window_size_test.h', - 'test/plugin/plugin_windowed_test.cc', - 'test/plugin/plugin_windowed_test.h', - 'test/plugin/plugin_windowless_test.cc', - 'test/plugin/plugin_windowless_test.h', - 'test/plugin/resource.h', - ], - 'include_dirs': [ - '../..', - ], - 'xcode_settings': { - 'INFOPLIST_FILE': '<(DEPTH)/content/test/plugin/Info.plist', - }, - 'conditions': [ - ['OS!="win"', { - 'sources!': [ - # windows-specific resources - 'test/plugin/npapi_test.def', - 'test/plugin/npapi_test.rc', - # Seems windows specific. - 'test/plugin/plugin_create_instance_in_paint.cc', - 'test/plugin/plugin_create_instance_in_paint.h', - # TODO(port): Port these. - # plugin_npobject_lifetime_test.cc has win32-isms - # (HWND, CALLBACK). - 'test/plugin/plugin_npobject_lifetime_test.cc', - # The window APIs are necessarily platform-specific. - 'test/plugin/plugin_window_size_test.cc', - 'test/plugin/plugin_windowed_test.cc', - ], - }], - ['OS=="mac"', { - 'product_extension': 'plugin', - 'link_settings': { - 'libraries': [ - '$(SDKROOT)/System/Library/Frameworks/Carbon.framework', - ], - }, - }], - ['os_posix == 1 and OS != "mac" and (target_arch == "x64" or target_arch == "arm")', { - # Shared libraries need -fPIC on x86-64 - 'cflags': ['-fPIC'] - }], - ], - }, - { - 'target_name': 'copy_npapi_test_plugin', - 'type': 'none', - 'dependencies': [ - 'npapi_test_plugin', - ], - 'conditions': [ - ['OS=="win"', { - 'copies': [ - { - 'destination': '<(PRODUCT_DIR)/plugins', - 'files': ['<(PRODUCT_DIR)/npapi_test_plugin.dll'], - }, - ], - }], - ['OS=="mac"', { - 'copies': [ - { - 'destination': '<(PRODUCT_DIR)/plugins/', - 'files': ['<(PRODUCT_DIR)/npapi_test_plugin.plugin'], - }, - ] - }], - ['os_posix == 1 and OS != "mac"', { - 'copies': [ - { - 'destination': '<(PRODUCT_DIR)/plugins', - 'files': ['<(PRODUCT_DIR)/libnpapi_test_plugin.so'], - }, - ], - }], - ], - }, - ], - }], ], } diff --git a/content/test/BUILD.gn b/content/test/BUILD.gn index acc5ffc2a9d4ca..8114b7da37c9d2 100644 --- a/content/test/BUILD.gn +++ b/content/test/BUILD.gn @@ -379,11 +379,6 @@ if (!is_mac) { [ "../browser/compositor/image_transport_factory_browsertest.cc" ] } - if (!is_android && !is_ios && !is_linux) { - # Npapi test plugin doesn't build on Android or iOS. - #data_deps += [ 'copy_npapi_test_plugin' ] TODO(GYP) - } - if (enable_webrtc) { sources += rebase_path( content_tests_gypi_values.content_browsertests_webrtc_sources, diff --git a/content/test/data/npapi/alert_in_window_message.html b/content/test/data/npapi/alert_in_window_message.html deleted file mode 100644 index 5e3438593ab02b..00000000000000 --- a/content/test/data/npapi/alert_in_window_message.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - -
-Test running.... -
- - -Alert in Window message

- -Tests that there's no deadlock when a plugin creates an alert in response to a synchronous Windows message from the browser process. - -

- -
- -
- - - - - diff --git a/content/test/data/npapi/arguments.html b/content/test/data/npapi/arguments.html deleted file mode 100644 index 835473c17cc466..00000000000000 --- a/content/test/data/npapi/arguments.html +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - -
-Test running.... -
- - -NPAPI Loading and Argument Tests

-Tests our ability to pass arguments to the plugin via the embed -tag.

- - - - - diff --git a/content/test/data/npapi/convert_point.html b/content/test/data/npapi/convert_point.html deleted file mode 100644 index aee07c566df321..00000000000000 --- a/content/test/data/npapi/convert_point.html +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - -

-Test running.... -
- - -NPAPI ConvertPoint test

-Tests that NPN_ConvertPoint works.

- -

- -
- - - diff --git a/content/test/data/npapi/cookies.html b/content/test/data/npapi/cookies.html deleted file mode 100644 index 802a3b2f20fa78..00000000000000 --- a/content/test/data/npapi/cookies.html +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - -
-Test running.... -
- - -Cookies Test

-This test fetches an URL via the plugin, and verifies that the cookies are sent -with plugin-initiated requests. - - - - - diff --git a/content/test/data/npapi/create_instance_in_paint.html b/content/test/data/npapi/create_instance_in_paint.html deleted file mode 100644 index 80e8935038ccd5..00000000000000 --- a/content/test/data/npapi/create_instance_in_paint.html +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - -

-Test running.... -
- - -Plugin Instance In Paint Test

- -Tests that there's no deadlock when a plugin instance is created while handling a paint message. - -

- -
- -
- - - - - diff --git a/content/test/data/npapi/ensure_scripting_works_in_destroy.html b/content/test/data/npapi/ensure_scripting_works_in_destroy.html deleted file mode 100644 index 80b9f65fdfeefa..00000000000000 --- a/content/test/data/npapi/ensure_scripting_works_in_destroy.html +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - -
-Test running.... -
- -Tests that scripting works during NPP_Destroy. - - - - diff --git a/content/test/data/npapi/ensure_scripting_works_in_destroy_iframe.html b/content/test/data/npapi/ensure_scripting_works_in_destroy_iframe.html deleted file mode 100644 index 0bb491d9a9b12f..00000000000000 --- a/content/test/data/npapi/ensure_scripting_works_in_destroy_iframe.html +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - -
- -
- - - - diff --git a/content/test/data/npapi/execute_script_delete_in_mouse_up.html b/content/test/data/npapi/execute_script_delete_in_mouse_up.html deleted file mode 100644 index 6a21e6636f58c5..00000000000000 --- a/content/test/data/npapi/execute_script_delete_in_mouse_up.html +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - -
-Test running.... -
- - -NPObject Proxy Test

- -Tests the case where a plugin instance is deleted in the context -of a synchronous mouse event. - -

- -
- - - - diff --git a/content/test/data/npapi/execute_script_delete_in_npn_evaluate.html b/content/test/data/npapi/execute_script_delete_in_npn_evaluate.html deleted file mode 100644 index f2e2bbec49ddc3..00000000000000 --- a/content/test/data/npapi/execute_script_delete_in_npn_evaluate.html +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - -
-Test running.... -
- - -NPObject Proxy Test

- -Tests the case where a plugin instance is deleted in the context -of NPN_Evaluate - -

- -
- - - - diff --git a/content/test/data/npapi/execute_script_delete_in_paint.html b/content/test/data/npapi/execute_script_delete_in_paint.html deleted file mode 100644 index fa9ff21bb3559c..00000000000000 --- a/content/test/data/npapi/execute_script_delete_in_paint.html +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - -
-Test running.... -
- - -NPObject Proxy Test

- -Tests the case where a plugin instance is deleted in the context -of a synchronous paint. - -

- -
- - - - diff --git a/content/test/data/npapi/get_javascript_open_popup_with_plugin.html b/content/test/data/npapi/get_javascript_open_popup_with_plugin.html deleted file mode 100644 index 8f2f01ad25a596..00000000000000 --- a/content/test/data/npapi/get_javascript_open_popup_with_plugin.html +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - -
-Test running.... -
- - -Open Popup window with plugin Test

-This test instantiates a plugin which executes the window.open call to open a popup
-window with a windowed plugin instance. The test verifies that the plugin instance in
-the popup window always has a valid parent window.
- - - - - diff --git a/content/test/data/npapi/get_javascript_url.html b/content/test/data/npapi/get_javascript_url.html deleted file mode 100644 index 404613bd5f66b3..00000000000000 --- a/content/test/data/npapi/get_javascript_url.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - -

-Test running.... -
- - -GetJavscriptURL Test

-This test fetches a javascript URL via the plugin with _top as the -target frame, and verifies that the call succeeds. - - - - - diff --git a/content/test/data/npapi/get_javascript_url2.html b/content/test/data/npapi/get_javascript_url2.html deleted file mode 100644 index 0fd4470fd43f95..00000000000000 --- a/content/test/data/npapi/get_javascript_url2.html +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/content/test/data/npapi/get_javascript_url2_frame.html b/content/test/data/npapi/get_javascript_url2_frame.html deleted file mode 100644 index dacf9c39fcf106..00000000000000 --- a/content/test/data/npapi/get_javascript_url2_frame.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - - -

-Test running.... -
- -GetJavscriptURL2 Test

-This test fetches a javascript URL via the plugin with _self as the -target frame, and verifies that the call succeeds. The plugin runs -within a subframe. - - - - diff --git a/content/test/data/npapi/geturl.html b/content/test/data/npapi/geturl.html deleted file mode 100644 index 002b63b4ae2041..00000000000000 --- a/content/test/data/npapi/geturl.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - -

-Test running.... -
- - -GetURL Test

-This test fetches an URL via the plugin, and verifies that the -callbacks are expected and that the retrieved content is correct. - - - - - diff --git a/content/test/data/npapi/geturl_redirect_notify.html b/content/test/data/npapi/geturl_redirect_notify.html deleted file mode 100644 index 568834d9e9d291..00000000000000 --- a/content/test/data/npapi/geturl_redirect_notify.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - -

-Test running.... -
- - -GetURL Test

-This test fetches a URL via the plugin and validates that the plugin does -receive notification about the redirect which is then denied. - - - - - diff --git a/content/test/data/npapi/layout_test_plugin.html b/content/test/data/npapi/layout_test_plugin.html deleted file mode 100644 index 7ee5492de755ec..00000000000000 --- a/content/test/data/npapi/layout_test_plugin.html +++ /dev/null @@ -1,17 +0,0 @@ - - -OK - - - - - - - - - diff --git a/content/test/data/npapi/many_plugins.html b/content/test/data/npapi/many_plugins.html deleted file mode 100644 index 4a3b74aea0d90e..00000000000000 --- a/content/test/data/npapi/many_plugins.html +++ /dev/null @@ -1,101 +0,0 @@ - - - - - - - - -

-Test running.... -
- - -Loading many plugins

-Tests our ability to load multiple plugins in a single page.

- - - - - - - - - - - - - - - - - - - diff --git a/content/test/data/npapi/multiple_instances_sync_calls.html b/content/test/data/npapi/multiple_instances_sync_calls.html deleted file mode 100644 index 5658a121de30c6..00000000000000 --- a/content/test/data/npapi/multiple_instances_sync_calls.html +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - -

- Test running.... -
- - NPObject Proxy Test

- - Tests the case that involves two plugin instances with second - instance making sync calls to the renderer while the first one - is still servicing an incoming sync request - -

- - -
- - diff --git a/content/test/data/npapi/new_fails.html b/content/test/data/npapi/new_fails.html deleted file mode 100644 index a4b7de939d6847..00000000000000 --- a/content/test/data/npapi/new_fails.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - -
-Test running.... -
- - -NPP_NEW test

-This test ensures we don't crash or assert if NPP_New fails. - - - - - - - diff --git a/content/test/data/npapi/no_hang_if_init_crashes.html b/content/test/data/npapi/no_hang_if_init_crashes.html deleted file mode 100644 index 00e76a982b5ab6..00000000000000 --- a/content/test/data/npapi/no_hang_if_init_crashes.html +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - -

-Test running.... -
- - -No Hang If Init Crashes

- -Tests that if a plugin crashes during NP_Initialize the renderer doesn't hang. - - - - - diff --git a/content/test/data/npapi/npapi.js b/content/test/data/npapi/npapi.js deleted file mode 100644 index 6c3ef8d746d01f..00000000000000 --- a/content/test/data/npapi/npapi.js +++ /dev/null @@ -1,30 +0,0 @@ -// -// This script provides some mechanics for testing NPAPI -// - -/* public */ function onSuccess(name, id) -{ - setTimeout(onFinished, 0, name, id, "OK"); -} - -/* public */ function onFailure(name, id, status) -{ - setTimeout(onFinished, 0, name, id, status); -} - - - -// Finish running a test by setting the status -// and the cookie. -/* private */ function onFinished(name, id, result) -{ - var statusPanel = document.getElementById("statusPanel"); - if (statusPanel) { - statusPanel.innerHTML = result; - } - - if (result == "OK") - document.title = "OK"; - else - document.title = "FAIL"; -} diff --git a/content/test/data/npapi/npn_plugin_delete_create_in_evaluate.html b/content/test/data/npapi/npn_plugin_delete_create_in_evaluate.html deleted file mode 100644 index 12f0e4d7ad7475..00000000000000 --- a/content/test/data/npapi/npn_plugin_delete_create_in_evaluate.html +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - -

-Test running.... -
- -Tests the case where a plugin instance is deleted and created in the context -of the NPN_Evaluate call. - -
- -
- - - diff --git a/content/test/data/npapi/npobject_identity.html b/content/test/data/npapi/npobject_identity.html deleted file mode 100644 index ac5e43d09833e6..00000000000000 --- a/content/test/data/npapi/npobject_identity.html +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - -
-Test running.... -
- - -NPObject Identity Test

- -Tests that identity is preserved for NPObjects passed from a plugin into JavaScript. - - - - - diff --git a/content/test/data/npapi/npobject_lifetime_test.html b/content/test/data/npapi/npobject_lifetime_test.html deleted file mode 100644 index 634fad81395849..00000000000000 --- a/content/test/data/npapi/npobject_lifetime_test.html +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - -

-Test running.... -
- - -NPObject Lifetime test

- -Tests the case where a plugin holds on to an NPObject reference -to another plugin in a different frame in the page and whether -the npobject is callable when the frame is destroyed. - -

- -
- - - - - - - - diff --git a/content/test/data/npapi/npobject_lifetime_test_second_instance.html b/content/test/data/npapi/npobject_lifetime_test_second_instance.html deleted file mode 100644 index 5876f8e7e323ff..00000000000000 --- a/content/test/data/npapi/npobject_lifetime_test_second_instance.html +++ /dev/null @@ -1,20 +0,0 @@ - - - -
-Second instance. -
- -NPObject Lifetime test second plugin instance

- -Tests the case where a plugin holds on to an NPObject reference -to another plugin in a different frame in the page and whether -the npobject is callable when the frame is destroyed. - - - - - diff --git a/content/test/data/npapi/npobject_proxy.html b/content/test/data/npapi/npobject_proxy.html deleted file mode 100644 index ef85ee7a3843ae..00000000000000 --- a/content/test/data/npapi/npobject_proxy.html +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - -

-Test running.... -
- - -NPObject Proxy Test

- -Tests that if an NPObject is proxies back to its original process, the -original pointer is returned and not a proxy. If this fails the plugin -will crash. - - - - - diff --git a/content/test/data/npapi/npobject_released_on_destruction.html b/content/test/data/npapi/npobject_released_on_destruction.html deleted file mode 100644 index b98779fadc6e3b..00000000000000 --- a/content/test/data/npapi/npobject_released_on_destruction.html +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - -

-Test running.... -
- - -NPObject released on destruction

- -Tests that if a plugin creates an NPObject and releases it on destruction, -there's no crash when the plugin goes away. - - -

- -
- - - - - diff --git a/content/test/data/npapi/npobject_set_exception.html b/content/test/data/npapi/npobject_set_exception.html deleted file mode 100644 index 1eeacbfb533738..00000000000000 --- a/content/test/data/npapi/npobject_set_exception.html +++ /dev/null @@ -1,24 +0,0 @@ - - -Set Exception Test - - - - - -

Test that if NPN_SetException is called by an out of process plugin, the - exception is sent to the proper renderer.

- -
- -
- - - diff --git a/content/test/data/npapi/plugin_delete_in_deallocate.html b/content/test/data/npapi/plugin_delete_in_deallocate.html deleted file mode 100644 index 4904469e7a17c6..00000000000000 --- a/content/test/data/npapi/plugin_delete_in_deallocate.html +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - -
-Test running.... -
- -NPObject Delete in Deallocate

- -Tests the case where deallocation of an NPObject belonging to the plugin -triggers scripting which causes the whole plugin to be torn down, and verifies -that the object being deallocated is not deallocated a second time. - - - - - - - - diff --git a/content/test/data/npapi/plugin_range_request.dat b/content/test/data/npapi/plugin_range_request.dat deleted file mode 100644 index ad471007bd7f59..00000000000000 --- a/content/test/data/npapi/plugin_range_request.dat +++ /dev/null @@ -1 +0,0 @@ -0123456789 \ No newline at end of file diff --git a/content/test/data/npapi/plugin_range_request.dat.mock-http-headers b/content/test/data/npapi/plugin_range_request.dat.mock-http-headers deleted file mode 100644 index ae6213ee400dac..00000000000000 --- a/content/test/data/npapi/plugin_range_request.dat.mock-http-headers +++ /dev/null @@ -1,3 +0,0 @@ -HTTP/1.0 206 Partial Content -Content-Length: 6 -Content-Range: bytes 4-9/10 diff --git a/content/test/data/npapi/plugin_read_page.html b/content/test/data/npapi/plugin_read_page.html deleted file mode 100644 index 17bcef8e24b2ad..00000000000000 --- a/content/test/data/npapi/plugin_read_page.html +++ /dev/null @@ -1,4 +0,0 @@ - -Test page read by plugin -This page has a title. - diff --git a/content/test/data/npapi/plugin_read_page.html.mock-http-headers b/content/test/data/npapi/plugin_read_page.html.mock-http-headers deleted file mode 100644 index 57fae25083f7ff..00000000000000 --- a/content/test/data/npapi/plugin_read_page.html.mock-http-headers +++ /dev/null @@ -1,2 +0,0 @@ -HTTP/1.0 200 OK -Content-type: text/html diff --git a/content/test/data/npapi/plugin_read_page_redirect_src.html b/content/test/data/npapi/plugin_read_page_redirect_src.html deleted file mode 100644 index d359a5431c9ac3..00000000000000 --- a/content/test/data/npapi/plugin_read_page_redirect_src.html +++ /dev/null @@ -1,4 +0,0 @@ - -Test redirect page -Redirect page. This page redirects to another page. - diff --git a/content/test/data/npapi/plugin_read_page_redirect_src.html.mock-http-headers b/content/test/data/npapi/plugin_read_page_redirect_src.html.mock-http-headers deleted file mode 100644 index 0818be13524252..00000000000000 --- a/content/test/data/npapi/plugin_read_page_redirect_src.html.mock-http-headers +++ /dev/null @@ -1,3 +0,0 @@ -HTTP/1.1 301 Moved Permanently -Location: http://mock.http/npapi/plugin_read_page.html -Content-type: text/html diff --git a/content/test/data/npapi/plugin_ref_target_page.html b/content/test/data/npapi/plugin_ref_target_page.html deleted file mode 100644 index b4a6e9ff7407e7..00000000000000 --- a/content/test/data/npapi/plugin_ref_target_page.html +++ /dev/null @@ -1,19 +0,0 @@ - -Target page for validating referrers in URL requests issued by <br /> -plugins - - - - - -Plugin referrer test page. - diff --git a/content/test/data/npapi/plugin_ref_target_page.html.mock-http-headers b/content/test/data/npapi/plugin_ref_target_page.html.mock-http-headers deleted file mode 100644 index 57fae25083f7ff..00000000000000 --- a/content/test/data/npapi/plugin_ref_target_page.html.mock-http-headers +++ /dev/null @@ -1,2 +0,0 @@ -HTTP/1.0 200 OK -Content-type: text/html diff --git a/content/test/data/npapi/plugin_single_range_request.html b/content/test/data/npapi/plugin_single_range_request.html deleted file mode 100644 index 5432495b49f373..00000000000000 --- a/content/test/data/npapi/plugin_single_range_request.html +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - -

-Test running.... -
- -

-Plugun Single Range Request test. -

-

-This test verifies that we correctly serve -NPN_RequestRead calls with single range. -

- - - - - diff --git a/content/test/data/npapi/plugin_thread_async_call.html b/content/test/data/npapi/plugin_thread_async_call.html deleted file mode 100644 index 156c844a473ea4..00000000000000 --- a/content/test/data/npapi/plugin_thread_async_call.html +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - -
-Test running.... -
- - -NPAPI NPN_PluginThreadAsyncCall test

-Tests that a plugin can schedule async callbacks.

- - - -

- -
- - - diff --git a/content/test/data/npapi/plugin_url_request_404.html b/content/test/data/npapi/plugin_url_request_404.html deleted file mode 100644 index deb200e1596909..00000000000000 --- a/content/test/data/npapi/plugin_url_request_404.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - -
-Test running.... -
- - -GetURL 404 Response Test

-This test fetches a URL which results in the server sending back a 404 -response in the header. The plugin should expect a valid response followed -by a failure. - - - - diff --git a/content/test/data/npapi/plugin_url_request_fail_write.html b/content/test/data/npapi/plugin_url_request_fail_write.html deleted file mode 100644 index ee55af6d7abbcd..00000000000000 --- a/content/test/data/npapi/plugin_url_request_fail_write.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - -

-Test running.... -
- - -GetURL Plugin Fails NPP_Write Test

-This test fetches a URL and passes data off to the plugin. The plugin returns -an error from the NPP_Write call. This test verifies that we do not crash -as a result. - - - - diff --git a/content/test/data/npapi/plugin_url_request_referrer_test.html b/content/test/data/npapi/plugin_url_request_referrer_test.html deleted file mode 100644 index 87e51fcfbad8cf..00000000000000 --- a/content/test/data/npapi/plugin_url_request_referrer_test.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - -

-Test running.... -
- - -Plugin URL request referrer test

-This test verifies that the HTTP referrer value is set correctly in HTTP
-requests issued by plugins. - - - - - diff --git a/content/test/data/npapi/popup_window_with_target_plugin.html b/content/test/data/npapi/popup_window_with_target_plugin.html deleted file mode 100644 index a7942a85364351..00000000000000 --- a/content/test/data/npapi/popup_window_with_target_plugin.html +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - -

-Test running.... -
- - -Open Popup window with plugin Test

-This test instantiates a plugin which executes the window.open call to open a popup
-window with a windowed plugin instance. The test verifies that the plugin instance in
-the popup window always has a valid parent window.
- - - - - diff --git a/content/test/data/npapi/private.html b/content/test/data/npapi/private.html deleted file mode 100644 index 46cacdeb60d56f..00000000000000 --- a/content/test/data/npapi/private.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - -

-Test running.... -
- - -NPAPI Private Mode test

-Tests that a plugin can query the private browsing mode.

- - - - - diff --git a/content/test/data/npapi/resize_during_paint.html b/content/test/data/npapi/resize_during_paint.html deleted file mode 100644 index a661c84aeffbfc..00000000000000 --- a/content/test/data/npapi/resize_during_paint.html +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - -

-Test running.... -
- -Resize During Paint Test

-This test ensures that if a windowless plugin resizes during a paint, -deallocated memory isn't used.
- - - - - - - diff --git a/content/test/data/npapi/schedule_timer.html b/content/test/data/npapi/schedule_timer.html deleted file mode 100644 index 2546bb991fe572..00000000000000 --- a/content/test/data/npapi/schedule_timer.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - -

-Test running.... -
- - -NPAPI NPN_ScheduleTimer test

-Tests that a plugin can schedule and unschedule timers.

- - - - - diff --git a/content/test/data/npapi/self_delete_plugin_geturl.html b/content/test/data/npapi/self_delete_plugin_geturl.html deleted file mode 100644 index 2d14340b4ff0cf..00000000000000 --- a/content/test/data/npapi/self_delete_plugin_geturl.html +++ /dev/null @@ -1,37 +0,0 @@ - - -Self Deleting Plugin Test - GetURL - - - - - - -

Test to delete a plugin during script execution

- -

-This test is for a corner case when a plugin executes a script -that deletes the invoking plugin itself. -

- -
- -
- - - - - diff --git a/content/test/data/npapi/self_delete_plugin_invoke.html b/content/test/data/npapi/self_delete_plugin_invoke.html deleted file mode 100644 index 73b940f2eae181..00000000000000 --- a/content/test/data/npapi/self_delete_plugin_invoke.html +++ /dev/null @@ -1,33 +0,0 @@ - - -Self Deleting Plugin Test - Invoke - - - - - - -

Test to delete a plugin during script execution

- -

-This test is for a corner case when a plugin executes a script -that deletes the invoking plugin itself. -

- -
- -
- - - - - diff --git a/content/test/data/npapi/self_delete_plugin_invoke_alert.html b/content/test/data/npapi/self_delete_plugin_invoke_alert.html deleted file mode 100644 index 4176d2c9d7b18e..00000000000000 --- a/content/test/data/npapi/self_delete_plugin_invoke_alert.html +++ /dev/null @@ -1,43 +0,0 @@ - - -Self Deleting Plugin Test - Invoke - - - - - - -

Test to delete a plugin during script execution

- -

-This test is for a corner case when a plugin executes a script -that deletes the invoking plugin itself then shows a modal dialog. -See http://code.google.com/p/chromium/issues/detail?id=4270. -

- -
- -
- - - - - - diff --git a/content/test/data/npapi/self_delete_plugin_stream.html b/content/test/data/npapi/self_delete_plugin_stream.html deleted file mode 100644 index a43c38a99c8daa..00000000000000 --- a/content/test/data/npapi/self_delete_plugin_stream.html +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - -
-Test running.... -
- - -
- -
- - - - diff --git a/content/test/data/npapi/verify_plugin_window_rect.html b/content/test/data/npapi/verify_plugin_window_rect.html deleted file mode 100644 index 7dca47a022a988..00000000000000 --- a/content/test/data/npapi/verify_plugin_window_rect.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - -
-Test running.... -
- - -Plugin Window Rect Test

- -Tests whether the plugin window has a non zero client rect. - -

- -
- - - - diff --git a/content/test/plugin/Info.plist b/content/test/plugin/Info.plist deleted file mode 100644 index 37145fd8a9714f..00000000000000 --- a/content/test/plugin/Info.plist +++ /dev/null @@ -1,46 +0,0 @@ - - - - - CFBundleDevelopmentRegion - English - CFBundleExecutable - NPAPITestPlugIn - CFBundleIdentifier - org.chromium.npapi_test_plugin - CFBundleInfoDictionaryVersion - 6.0 - CFBundleExecutable - ${EXECUTABLE_NAME} - CFBundleName - ${PRODUCT_NAME} - CFBundlePackageType - BRPL - CFBundleShortVersionString - 1.0 - CFBundleSignature - ???? - CFBundleVersion - 1.0 - CFPlugInDynamicRegisterFunction - - CFPlugInDynamicRegistration - NO - WebPluginDescription - Simple NPAPI plug-in for Chromium unit tests - WebPluginMIMETypes - - application/vnd.npapi-test - - WebPluginExtensions - - npapitest - - WebPluginTypeDescription - test npapi - - - WebPluginName - Chromium NPAPI Test Plugin - - diff --git a/content/test/plugin/npapi_constants.cc b/content/test/plugin/npapi_constants.cc deleted file mode 100644 index 7f517a2c85cf03..00000000000000 --- a/content/test/plugin/npapi_constants.cc +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) 2010 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 "content/test/plugin/npapi_constants.h" - -namespace NPAPIClient { - -const char kTestCompleteCookie[] = "status"; -const char kTestCompleteSuccess[] = "OK"; - -} // namespace NPAPIClient diff --git a/content/test/plugin/npapi_constants.h b/content/test/plugin/npapi_constants.h deleted file mode 100644 index 986c04662d41c0..00000000000000 --- a/content/test/plugin/npapi_constants.h +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) 2010 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. - -// Constants for the NPAPI test - -#ifndef CONTENT_TEST_PLUGIN_NPAPI_CONSTANTS_H_ -#define CONTENT_TEST_PLUGIN_NPAPI_CONSTANTS_H_ - -namespace NPAPIClient { - -// The name of the cookie which will be used to communicate between -// the plugin and the test harness. -extern const char kTestCompleteCookie[]; - -// The cookie value which will be sent to the client upon successful -// test. -extern const char kTestCompleteSuccess[]; - -} // namespace NPAPIClient - -#endif // CONTENT_TEST_PLUGIN_NPAPI_CONSTANTS_H_ diff --git a/content/test/plugin/npapi_test.cc b/content/test/plugin/npapi_test.cc deleted file mode 100644 index 02e9093411b6af..00000000000000 --- a/content/test/plugin/npapi_test.cc +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright (c) 2010 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. - -// -// npapitest -// -// This is a NPAPI Plugin Program which is used to test the Browser's NPAPI -// host implementation. It is used in conjunction with the npapi_unittest. -// -// As a NPAPI Plugin, you can invoke it by creating a web page of the following -// type: -// -// -// -// arguments: -// src: This is the initial content which will be sent to the plugin. -// type: Must be "application/vnd.npapi-test" -// name: The testcase to run when invoked -// id: The id of the test being run (for testing concurrent plugins) -// -// The Plugin drives the actual test, calling host functions and validating the -// Host callbacks which it receives. It is the duty of the plugin to record -// all errors. -// -// To indicate test completion, the plugin expects the containing HTML page to -// implement two javascript functions: -// onSuccess(string testname); -// onFailure(string testname, string results); -// The HTML host pages used in this test will then set a document cookie -// which the automated test framework can poll for and discover that the -// test has completed. -// -// -// TESTS -// When the PluginClient receives a NPP_New callback from the browser, -// it looks at the "name" argument which is passed in. It verifies that -// the name matches a known test, and instantiates that test. The test is -// a subclass of PluginTest. -// -// - -#include "base/basictypes.h" - -#if defined(OS_WIN) -#include -#endif - -#if defined(__GNUC__) && __GNUC__ >= 4 -#define EXPORT __attribute__((visibility ("default"))) -#else -#define EXPORT -#endif - -#include "content/test/plugin/plugin_client.h" - -#if defined(OS_WIN) -BOOL API_CALL DllMain(HINSTANCE hDll, DWORD dwReason, LPVOID lpReserved) { - return TRUE; -} -#endif - -extern "C" { -EXPORT NPError API_CALL NP_GetEntryPoints(NPPluginFuncs* pFuncs) { - return NPAPIClient::PluginClient::GetEntryPoints(pFuncs); -} - -EXPORT NPError API_CALL NP_Shutdown() { - return NPAPIClient::PluginClient::Shutdown(); -} - -#if defined(OS_WIN) || defined(OS_MACOSX) -EXPORT NPError API_CALL NP_Initialize(NPNetscapeFuncs* npnFuncs) { - return NPAPIClient::PluginClient::Initialize(npnFuncs); -} -#elif defined(OS_POSIX) -EXPORT NPError API_CALL NP_Initialize(NPNetscapeFuncs* npnFuncs, - NPPluginFuncs* nppFuncs) { - NPError error = NPAPIClient::PluginClient::Initialize(npnFuncs); - if (error == NPERR_NO_ERROR) { - error = NP_GetEntryPoints(nppFuncs); - } - return error; -} - -EXPORT NPError API_CALL NP_GetValue(NPP instance, NPPVariable variable, - void* value) { - NPError err = NPERR_NO_ERROR; - - switch (variable) { - case NPPVpluginNameString: - *(static_cast(value)) = "NPAPI Test Plugin"; - break; - case NPPVpluginDescriptionString: - *(static_cast(value)) = - "Simple NPAPI plugin for Chromium unit tests"; - break; - case NPPVpluginNeedsXEmbed: - *(static_cast(value)) = true; - break; - default: - err = NPERR_GENERIC_ERROR; - break; - } - - return err; -} - -EXPORT const char* API_CALL NP_GetMIMEDescription(void) { - // The layout test LayoutTests/fast/js/navigator-mimeTypes-length.html - // asserts that the number of mimetypes handled by plugins should be - // greater than the number of plugins. We specify a mimetype here so - // this plugin has at least one. - return "application/vnd.npapi-test:npapitest:test npapi"; -} -#endif // OS_POSIX -} // extern "C" - -namespace WebCore { - const char* currentTextBreakLocaleID() { return "en_us"; } -} diff --git a/content/test/plugin/npapi_test.def b/content/test/plugin/npapi_test.def deleted file mode 100644 index 4481c164f09bce..00000000000000 --- a/content/test/plugin/npapi_test.def +++ /dev/null @@ -1,6 +0,0 @@ -LIBRARY npapi_test_plugin - -EXPORTS - NP_GetEntryPoints @1 - NP_Initialize @2 - NP_Shutdown @3 diff --git a/content/test/plugin/npapi_test.rc b/content/test/plugin/npapi_test.rc deleted file mode 100644 index d877b1048e1025..00000000000000 --- a/content/test/plugin/npapi_test.rc +++ /dev/null @@ -1,106 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#define APSTUDIO_HIDDEN_SYMBOLS -#include "windows.h" -#undef APSTUDIO_HIDDEN_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#define APSTUDIO_HIDDEN_SYMBOLS\r\n" - "#include ""windows.h""\r\n" - "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,1 - PRODUCTVERSION 1,0,0,1 - FILEFLAGSMASK 0x17L -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x2L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904e4" - BEGIN - VALUE "FileDescription", "NPAPI Test Plugin" - VALUE "FileVersion", "1, 0, 0, 1" - VALUE "InternalName", "npapi_test_plugin" - VALUE "LegalCopyright", "Copyright (C) 2007" - VALUE "MIMEType", "application/vnd.npapi-test" - VALUE "OriginalFilename", "npapi_test_plugin.dll" - VALUE "ProductName", "NPAPI Test Plugin" - VALUE "ProductVersion", "1, 0, 0, 1" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1252 - END -END - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/content/test/plugin/plugin_arguments_test.cc b/content/test/plugin/plugin_arguments_test.cc deleted file mode 100644 index 63ac3b80705836..00000000000000 --- a/content/test/plugin/plugin_arguments_test.cc +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (c) 2010 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 - -#include "content/test/plugin/plugin_arguments_test.h" - -#include "base/basictypes.h" -#include "base/strings/string_util.h" -#include "base/strings/stringprintf.h" - -namespace NPAPIClient { - -PluginArgumentsTest::PluginArgumentsTest(NPP id, - NPNetscapeFuncs *host_functions) - : PluginTest(id, host_functions) { -} - -NPError PluginArgumentsTest::New(uint16 mode, int16 argc, - const char* argn[], const char* argv[], - NPSavedData* saved) { - // mode: should be the string either "NP_EMBED" or "NP_FULL", - // depending on the mode passed in. - // count: the count of "val" arguments. If the value is - // 2, then we'll find arguments "val1" and "val2". If - // the value is 0, then there will be no "val" arguments. - // size: each val string will be this size * the value's - // index. E.g if size is "10", val1 will be 10bytes, - // and val2 will be 20bytes. - const char *mode_string = GetArgValue("mode", argc, argn, argv); - ExpectAsciiStringNotEqual(mode_string, (const char *)NULL); - if (mode_string != NULL) { - std::string mode_dep_string = mode_string; - if (mode == NP_EMBED) - ExpectStringLowerCaseEqual(mode_dep_string, "np_embed"); - else if (mode == NP_FULL) - ExpectStringLowerCaseEqual(mode_dep_string, "np_full"); - } - - const char *count_string = GetArgValue("count", argc, argn, argv); - if (count_string != NULL) { - int max_args = atoi(count_string); - - const char *size_string = GetArgValue("size", argc, argn, argv); - ExpectAsciiStringNotEqual(size_string, (const char *)NULL); - if (size_string != NULL) { - int size = atoi(size_string); - - for (int index = 1; index <= max_args; index++) { - std::string arg_name = base::StringPrintf("%s%d", "val", index); - const char *val_string = GetArgValue(arg_name.c_str(), argc, argn, - argv); - ExpectAsciiStringNotEqual(val_string, (const char*)NULL); - if (val_string != NULL) - ExpectIntegerEqual((int)strlen(val_string), (index*size)); - } - } - } - - return PluginTest::New(mode, argc, argn, argv, saved); -} - -NPError PluginArgumentsTest::SetWindow(NPWindow* pNPWindow) { - // This test just tests the arguments. We're done now. - this->SignalTestCompleted(); - - return NPERR_NO_ERROR; -} - -} // namespace NPAPIClient diff --git a/content/test/plugin/plugin_arguments_test.h b/content/test/plugin/plugin_arguments_test.h deleted file mode 100644 index 95b04c72c1e6c5..00000000000000 --- a/content/test/plugin/plugin_arguments_test.h +++ /dev/null @@ -1,47 +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. - -#ifndef CONTENT_TEST_PLUGIN_PLUGIN_ARGUMENTS_TEST_H_ -#define CONTENT_TEST_PLUGIN_PLUGIN_ARGUMENTS_TEST_H_ - -#include "base/compiler_specific.h" -#include "content/test/plugin/plugin_test.h" - -namespace NPAPIClient { - -// The PluginArgumentsTest test that we properly receive arguments -// intended for the plugin. -// -// This is basically overkill for testing that the arguments passed -// to the plugin match what we expect. -// -// We expect to find the following arguments: -// mode: should be the string either "NP_EMBED" or "NP_FULL", -// depending on the mode passed in. -// count: the count of "val" arguments. If the value is -// 2, then we'll find arguments "val1" and "val2". If -// the value is 0, then there will be no "val" arguments. -// size: each val string will be this size * the value's -// index. E.g if size is "10", val1 will be 10bytes, -// and val2 will be 20bytes. -// -class PluginArgumentsTest : public PluginTest { - public: - // Constructor. - PluginArgumentsTest(NPP id, NPNetscapeFuncs *host_functions); - - // Initialize this PluginTest based on the arguments from NPP_New. - NPError New(uint16 mode, - int16 argc, - const char* argn[], - const char* argv[], - NPSavedData* saved) override; - - // NPAPI SetWindow handler. - NPError SetWindow(NPWindow* pNPWindow) override; -}; - -} // namespace NPAPIClient - -#endif // CONTENT_TEST_PLUGIN_PLUGIN_ARGUMENTS_TEST_H_ diff --git a/content/test/plugin/plugin_client.cc b/content/test/plugin/plugin_client.cc deleted file mode 100644 index f2f4e68428ffe2..00000000000000 --- a/content/test/plugin/plugin_client.cc +++ /dev/null @@ -1,323 +0,0 @@ -// Copyright (c) 2012 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 "content/test/plugin/plugin_client.h" - -#include "base/strings/string_util.h" -#include "content/test/plugin/plugin_execute_stream_javascript.h" -#include "content/test/plugin/plugin_test.h" -#include "content/test/plugin/plugin_test_factory.h" - -namespace NPAPIClient { - -class NPWithProperty : public NPObject { - public: - NPWithProperty() : NPObject() {} - - static NPObject* Allocate(NPP npp, NPClass* npclass) { - return new NPWithProperty(); - } - - static void Deallocate(NPObject* npobject) { - delete static_cast(npobject); - } - - static bool HasProperty(NPObject* npobject, NPIdentifier name) { - return (name == PluginClient::HostFunctions()-> - getstringidentifier("loadedProperty")); - } - - static bool GetProperty(NPObject* npobject, - NPIdentifier name, - NPVariant* result) { - if (name == PluginClient::HostFunctions()-> - getstringidentifier("loadedProperty")) { - BOOLEAN_TO_NPVARIANT(true, *result); - return true; - } - return false; - } -}; - -static NPClass* GetNPClass() { - static NPClass plugin_class = { - NP_CLASS_STRUCT_VERSION, - NPWithProperty::Allocate, - NPWithProperty::Deallocate, - NULL, // Invalidate - NULL, // HasMethod - NULL, // Invoke - NULL, // InvokeDefault - NPWithProperty::HasProperty, - NPWithProperty::GetProperty, - NULL, // SetProperty - NULL, // RemoveProperty - }; - return &plugin_class; -} - -NPNetscapeFuncs* PluginClient::host_functions_; - -NPError PluginClient::GetEntryPoints(NPPluginFuncs* pFuncs) { - if (pFuncs == NULL) - return NPERR_INVALID_FUNCTABLE_ERROR; - - if (pFuncs->size < sizeof(NPPluginFuncs)) - return NPERR_INVALID_FUNCTABLE_ERROR; - - pFuncs->version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR; - pFuncs->newp = NPP_New; - pFuncs->destroy = NPP_Destroy; - pFuncs->setwindow = NPP_SetWindow; - pFuncs->newstream = NPP_NewStream; - pFuncs->destroystream = NPP_DestroyStream; - pFuncs->asfile = NPP_StreamAsFile; - pFuncs->writeready = NPP_WriteReady; - pFuncs->write = NPP_Write; - pFuncs->print = NPP_Print; - pFuncs->event = NPP_HandleEvent; - pFuncs->urlnotify = NPP_URLNotify; - pFuncs->getvalue = NPP_GetValue; - pFuncs->setvalue = NPP_SetValue; - pFuncs->javaClass = NULL; - pFuncs->urlredirectnotify = NPP_URLRedirectNotify; - pFuncs->clearsitedata = NPP_ClearSiteData; - - return NPERR_NO_ERROR; -} - -NPError PluginClient::Initialize(NPNetscapeFuncs* pFuncs) { - if (pFuncs == NULL) { - return NPERR_INVALID_FUNCTABLE_ERROR; - } - - if (static_cast((pFuncs->version >> 8) & 0xff) > - NP_VERSION_MAJOR) { - return NPERR_INCOMPATIBLE_VERSION_ERROR; - } - -#if defined(OS_WIN) - // Check if we should crash. - HANDLE crash_event = CreateEvent(NULL, TRUE, FALSE, L"TestPluginCrashOnInit"); - if (WaitForSingleObject(crash_event, 0) == WAIT_OBJECT_0) { - int *zero = NULL; - *zero = 0; - } - CloseHandle(crash_event); -#endif - - host_functions_ = pFuncs; - - return NPERR_NO_ERROR; -} - -NPError PluginClient::Shutdown() { - return NPERR_NO_ERROR; -} - -} // namespace NPAPIClient - -extern "C" { -NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, - int16 argc, char* argn[], char* argv[], NPSavedData* saved) { - if (instance == NULL) - return NPERR_INVALID_INSTANCE_ERROR; - - NPAPIClient::PluginTest* new_test = NULL; - if (mode == NP_FULL) { - new_test = new::NPAPIClient::ExecuteStreamJavaScript( - instance, NPAPIClient::PluginClient::HostFunctions()); - } else { - // We look at the test name requested via the plugin arguments. We match - // that against a given test and try to instantiate it. - - // lookup the name parameter - std::string test_name; - for (int name_index = 0; name_index < argc; name_index++) { - if (base::strcasecmp(argn[name_index], "name") == 0) { - test_name = argv[name_index]; - break; - } - } - if (test_name.empty()) - return NPERR_GENERIC_ERROR; // no name found - - new_test = NPAPIClient::CreatePluginTest(test_name, - instance, NPAPIClient::PluginClient::HostFunctions()); - if (new_test == NULL) { - // If we don't have a test case for this, create a - // generic one which basically never fails. - LOG(WARNING) << "Unknown test name '" << test_name - << "'; using default test."; - new_test = new NPAPIClient::PluginTest(instance, - NPAPIClient::PluginClient::HostFunctions()); - } - } - -#if defined(OS_MACOSX) - // Set modern drawing and event models. - NPError drawing_ret = NPAPIClient::PluginClient::HostFunctions()->setvalue( - instance, NPPVpluginDrawingModel, (void*)NPDrawingModelCoreGraphics); - NPError event_ret = NPAPIClient::PluginClient::HostFunctions()->setvalue( - instance, NPPVpluginEventModel, (void*)NPEventModelCocoa); - if (drawing_ret != NPERR_NO_ERROR || event_ret != NPERR_NO_ERROR) - return NPERR_INCOMPATIBLE_VERSION_ERROR; -#endif - - NPError ret = new_test->New(mode, argc, (const char**)argn, - (const char**)argv, saved); - if ((ret == NPERR_NO_ERROR) && new_test->IsWindowless()) { - NPAPIClient::PluginClient::HostFunctions()->setvalue( - instance, NPPVpluginWindowBool, NULL); - } - - return ret; -} - -NPError NPP_Destroy(NPP instance, NPSavedData** save) { - if (instance == NULL) - return NPERR_INVALID_INSTANCE_ERROR; - - NPAPIClient::PluginTest* plugin = - reinterpret_cast(instance->pdata); - - NPError rv = plugin->Destroy(); - delete plugin; - return rv; -} - -NPError NPP_SetWindow(NPP instance, NPWindow* pNPWindow) { - if (instance == NULL) - return NPERR_INVALID_INSTANCE_ERROR; - - NPAPIClient::PluginTest* plugin = - reinterpret_cast(instance->pdata); - - return plugin->SetWindow(pNPWindow); -} - -NPError NPP_NewStream(NPP instance, NPMIMEType type, - NPStream* stream, NPBool seekable, uint16* stype) { - if (instance == NULL) - return NPERR_INVALID_INSTANCE_ERROR; - - NPAPIClient::PluginTest* plugin = - reinterpret_cast(instance->pdata); - - return plugin->NewStream(type, stream, seekable, stype); -} - -int32 NPP_WriteReady(NPP instance, NPStream *stream) { - if (instance == NULL) - return NPERR_INVALID_INSTANCE_ERROR; - - NPAPIClient::PluginTest* plugin = - reinterpret_cast(instance->pdata); - - return plugin->WriteReady(stream); -} - -int32 NPP_Write(NPP instance, NPStream *stream, int32 offset, - int32 len, void *buffer) { - if (instance == NULL) - return NPERR_INVALID_INSTANCE_ERROR; - - NPAPIClient::PluginTest* plugin = - reinterpret_cast(instance->pdata); - - return plugin->Write(stream, offset, len, buffer); -} - -NPError NPP_DestroyStream(NPP instance, NPStream *stream, NPError reason) { - if (instance == NULL) - return NPERR_INVALID_INSTANCE_ERROR; - - NPAPIClient::PluginTest* plugin = - reinterpret_cast(instance->pdata); - - return plugin->DestroyStream(stream, reason); -} - -void NPP_StreamAsFile(NPP instance, NPStream* stream, const char* fname) { - if (instance == NULL) - return; - - NPAPIClient::PluginTest* plugin = - reinterpret_cast(instance->pdata); - - return plugin->StreamAsFile(stream, fname); -} - -void NPP_Print(NPP instance, NPPrint* printInfo) { - if (instance == NULL) - return; - - // XXXMB - do work here. -} - -void NPP_URLNotify(NPP instance, const char* url, NPReason reason, - void* notifyData) { - if (instance == NULL) - return; - - NPAPIClient::PluginTest* plugin = - reinterpret_cast(instance->pdata); - - return plugin->URLNotify(url, reason, notifyData); -} - -NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value) { - if (instance == NULL) - return NPERR_INVALID_INSTANCE_ERROR; - - if (variable == NPPVpluginNeedsXEmbed) { - *static_cast(value) = 1; - return NPERR_NO_ERROR; - } - - if (variable == NPPVpluginScriptableNPObject) { - *(NPObject**)value = - NPAPIClient::PluginClient::HostFunctions()->createobject( - instance, NPAPIClient::GetNPClass()); - return NPERR_NO_ERROR; - } - - // XXXMB - do work here. - return NPERR_GENERIC_ERROR; -} - -NPError NPP_SetValue(NPP instance, NPNVariable variable, void *value) { - if (instance == NULL) - return NPERR_INVALID_INSTANCE_ERROR; - - // XXXMB - do work here. - return NPERR_GENERIC_ERROR; -} - -int16 NPP_HandleEvent(NPP instance, void* event) { - if (instance == NULL) - return 0; - - NPAPIClient::PluginTest* plugin = - reinterpret_cast(instance->pdata); - - return plugin->HandleEvent(event); -} - -void NPP_URLRedirectNotify(NPP instance, const char* url, int32_t status, - void* notify_data) { - if (instance) { - NPAPIClient::PluginTest* plugin = - reinterpret_cast(instance->pdata); - plugin->URLRedirectNotify(url, status, notify_data); - } -} - -NPError NPP_ClearSiteData(const char* site, - uint64 flags, - uint64 max_age) { - VLOG(0) << "NPP_ClearSiteData called"; - return NPERR_NO_ERROR; -} -} // extern "C" diff --git a/content/test/plugin/plugin_client.h b/content/test/plugin/plugin_client.h deleted file mode 100644 index 3b5ef3e1d394cf..00000000000000 --- a/content/test/plugin/plugin_client.h +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) 2010 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. - -#ifndef CONTENT_TEST_PLUGIN_PLUGIN_CLIENT_H_ -#define CONTENT_TEST_PLUGIN_PLUGIN_CLIENT_H_ - -#include "third_party/npapi/bindings/npapi.h" -#include "third_party/npapi/bindings/nphostapi.h" - -namespace NPAPIClient { - -// A PluginClient is a NPAPI Plugin. This class contains -// the bootstrapping functions used by the browser to load -// the plugin. -class PluginClient { - public: - // Although not documented in the NPAPI specification, this function - // gets the list of entry points in the NPAPI Plugin (client) for the - // NPAPI Host to call. - static NPError GetEntryPoints(NPPluginFuncs* pFuncs); - - // The browser calls this function only once: when a plugin is loaded, - // before the first instance is created. This is the first function that - // the browser calls. NP_Initialize tells the plugin that the browser has - // loaded it and provides global initialization. Allocate any memory or - // resources shared by all instances of your plugin at this time. - static NPError Initialize(NPNetscapeFuncs* pFuncs); - - // The browser calls this function once after the last instance of your - // plugin is destroyed, before unloading the plugin library itself. Use - // NP_Shutdown to delete any data allocated in NP_Initialize to be shared - // by all instances of a plugin. - static NPError Shutdown(); - - // The table of functions provided by the host. - static NPNetscapeFuncs *HostFunctions() { return host_functions_; } - - private: - static NPNetscapeFuncs* host_functions_; -}; - -} // namespace NPAPIClient - -#endif // CONTENT_TEST_PLUGIN_PLUGIN_CLIENT_H_ diff --git a/content/test/plugin/plugin_create_instance_in_paint.cc b/content/test/plugin/plugin_create_instance_in_paint.cc deleted file mode 100644 index 4aa69e437e6f20..00000000000000 --- a/content/test/plugin/plugin_create_instance_in_paint.cc +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) 2010 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 "content/test/plugin/plugin_create_instance_in_paint.h" - -#include "base/logging.h" -#include "content/test/plugin/plugin_client.h" - -namespace NPAPIClient { - -CreateInstanceInPaintTest::CreateInstanceInPaintTest( - NPP id, NPNetscapeFuncs *host_functions) - : PluginTest(id, host_functions), - window_(NULL), created_(false) { -} - -NPError CreateInstanceInPaintTest::SetWindow(NPWindow* pNPWindow) { - if (pNPWindow->window == NULL) - return NPERR_NO_ERROR; - - if (test_id() == "1") { - if (!window_) { - static ATOM window_class = 0; - if (!window_class) { - WNDCLASSEX wcex; - wcex.cbSize = sizeof(WNDCLASSEX); - wcex.style = CS_DBLCLKS; - wcex.lpfnWndProc = - &NPAPIClient::CreateInstanceInPaintTest::WindowProc; - wcex.cbClsExtra = 0; - wcex.cbWndExtra = 0; - wcex.hInstance = GetModuleHandle(NULL); - wcex.hIcon = 0; - wcex.hCursor = 0; - wcex.hbrBackground = reinterpret_cast(COLOR_WINDOW+1); - wcex.lpszMenuName = 0; - wcex.lpszClassName = L"CreateInstanceInPaintTestWindowClass"; - wcex.hIconSm = 0; - window_class = RegisterClassEx(&wcex); - } - - HWND parent = reinterpret_cast(pNPWindow->window); - window_ = CreateWindowEx( - WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR, - MAKEINTATOM(window_class), 0, - WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE , - 0, 0, 100, 100, parent, 0, GetModuleHandle(NULL), 0); - DCHECK(window_); - // TODO: this property leaks. - ::SetProp(window_, L"Plugin_Instance", this); - } - } else if (test_id() == "2") { - SignalTestCompleted(); - } else { - NOTREACHED(); - } - return NPERR_NO_ERROR; -} - -LRESULT CALLBACK CreateInstanceInPaintTest::WindowProc( - HWND window, UINT message, WPARAM wparam, LPARAM lparam) { - if (message == WM_PAINT) { - CreateInstanceInPaintTest* this_instance = - reinterpret_cast - (::GetProp(window, L"Plugin_Instance")); - if (this_instance->test_id() == "1" && !this_instance->created_) { - ::RemoveProp(window, L"Plugin_Instance"); - this_instance->created_ = true; - this_instance->HostFunctions()->geturlnotify( - this_instance->id(), "javascript:CreateNewInstance()", NULL, - reinterpret_cast(1)); - } - } - - return DefWindowProc(window, message, wparam, lparam); -} - -} // namespace NPAPIClient diff --git a/content/test/plugin/plugin_create_instance_in_paint.h b/content/test/plugin/plugin_create_instance_in_paint.h deleted file mode 100644 index 6ee65814469cbe..00000000000000 --- a/content/test/plugin/plugin_create_instance_in_paint.h +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) 2009 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. - -#ifndef CONTENT_TEST_PLUGIN_PLUGIN_CREATE_INSTANCE_IN_PAINT_H_ -#define CONTENT_TEST_PLUGIN_PLUGIN_CREATE_INSTANCE_IN_PAINT_H_ - -#include "content/test/plugin/plugin_test.h" - -namespace NPAPIClient { - -// This class tests that creating a new plugin via script while handling a -// Windows message doesn't cause a deadlock. -class CreateInstanceInPaintTest : public PluginTest { - public: - // Constructor. - CreateInstanceInPaintTest(NPP id, NPNetscapeFuncs *host_functions); - // - // NPAPI functions - // - NPError SetWindow(NPWindow* pNPWindow) override; - - private: - static LRESULT CALLBACK WindowProc( - HWND window, UINT message, WPARAM wparam, LPARAM lparam); - - HWND window_; - bool created_; -}; - -} // namespace NPAPIClient - -#endif // CONTENT_TEST_PLUGIN_PLUGIN_CREATE_INSTANCE_IN_PAINT_H_ diff --git a/content/test/plugin/plugin_delete_plugin_in_deallocate_test.cc b/content/test/plugin/plugin_delete_plugin_in_deallocate_test.cc deleted file mode 100644 index 733107d2dc3add..00000000000000 --- a/content/test/plugin/plugin_delete_plugin_in_deallocate_test.cc +++ /dev/null @@ -1,153 +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 "content/test/plugin/plugin_delete_plugin_in_deallocate_test.h" - -#include "base/basictypes.h" -#include "base/compiler_specific.h" - -namespace { - -NPAPIClient::DeletePluginInDeallocateTest* g_signalling_instance_ = NULL; - -class DeletePluginInDeallocateTestNPObject : public NPObject { - public: - DeletePluginInDeallocateTestNPObject() - : NPObject(), id_(NULL), host_functions_(NULL), deallocate_count_(0) {} - - static NPObject* Allocate(NPP npp, NPClass* npclass) { - return new DeletePluginInDeallocateTestNPObject(); - } - - static void Deallocate(NPObject* npobject) { - DeletePluginInDeallocateTestNPObject* object = - reinterpret_cast(npobject); - ++object->deallocate_count_; - - // Call window.deletePlugin to tear-down our plugin from inside deallocate. - if (object->deallocate_count_ == 1) { - NPIdentifier delete_id = - object->host_functions_->getstringidentifier("deletePlugin"); - NPObject* window_obj = NULL; - object->host_functions_->getvalue(object->id_, NPNVWindowNPObject, - &window_obj); - NPVariant rv; - object->host_functions_->invoke(object->id_, window_obj, delete_id, NULL, - 0, &rv); - } - } - - NPP id_; - NPNetscapeFuncs* host_functions_; - int deallocate_count_; -}; - -NPClass* GetDeletePluginInDeallocateTestClass() { - static NPClass plugin_class = { - NP_CLASS_STRUCT_VERSION, - DeletePluginInDeallocateTestNPObject::Allocate, - DeletePluginInDeallocateTestNPObject::Deallocate, - NULL, // Invalidate - NULL, // HasMethod - NULL, // Invoke - NULL, // InvokeDefault - NULL, // HasProperty - NULL, // GetProperty - NULL, // SetProperty - NULL, // RemoveProperty - }; - return &plugin_class; -} - -} // namespace - -namespace NPAPIClient { - -DeletePluginInDeallocateTest::DeletePluginInDeallocateTest( - NPP id, NPNetscapeFuncs* host_functions) - : PluginTest(id, host_functions), npobject_(NULL), test_started_(false) { -} - -NPError DeletePluginInDeallocateTest::SetWindow(NPWindow* pNPWindow) { -#if !defined(OS_MACOSX) - if (pNPWindow->window == NULL) - return NPERR_NO_ERROR; -#endif - - // Ensure that we run the test once, even if SetWindow is called again. - if (test_started_) - return NPERR_NO_ERROR; - test_started_ = true; - - // Because of http://crbug.com/94829, we have to have a second plugin - // instance that we can use to signal completion. - if (test_id() == "signaller") { - g_signalling_instance_ = this; - return NPERR_NO_ERROR; - } - - // Create a custom NPObject and give our Id and the Netscape function table. - npobject_ = HostFunctions()->createobject( - id(), GetDeletePluginInDeallocateTestClass()); - DeletePluginInDeallocateTestNPObject* test_object = - reinterpret_cast(npobject_); - test_object->id_ = id(); - test_object->host_functions_ = HostFunctions(); - - // Fetch the window script object for our page. - NPObject* window = NULL; - HostFunctions()->getvalue(id(), NPNVWindowNPObject, &window); - - // Pass it to the window.setTestObject function, which will later release it. - NPIdentifier set_test_object_id = - HostFunctions()->getstringidentifier("setTestObject"); - NPVariant func_var; - NULL_TO_NPVARIANT(func_var); - HostFunctions()->getproperty(id(), window, set_test_object_id, &func_var); - - NPObject* func = NPVARIANT_TO_OBJECT(func_var); - NPVariant func_arg; - OBJECT_TO_NPVARIANT(npobject_, func_arg); - NPVariant func_result; - HostFunctions()->invokeDefault(id(), func, &func_arg, 1, - &func_result); - - // Release the object - the page's reference should keep it alive. - HostFunctions()->releaseobject(npobject_); - - return NPERR_NO_ERROR; -} - -NPError DeletePluginInDeallocateTest::Destroy() { - // Because of http://crbug.com/94829, we can't signal completion from within - // the NPP_Destroy of the plugin that is being destroyed. We work-around - // that by testing using a second instance, and signalling though the main - // test instance. - - // There should always be a signalling instance by the time we reach here. - if (!g_signalling_instance_) - return NPERR_NO_ERROR; - - // If we're the signalling instance, do nothing. - if (g_signalling_instance_ == this) - return NPERR_NO_ERROR; - - if (!npobject_) { - g_signalling_instance_->SetError("SetWindow was not invoked."); - } else { - // Verify that our object was deallocated exactly once. - DeletePluginInDeallocateTestNPObject* test_object = - reinterpret_cast(npobject_); - if (test_object->deallocate_count_ != 1) - g_signalling_instance_->SetError( - "Object was not deallocated exactly once."); - delete test_object; - } - - g_signalling_instance_->SignalTestCompleted(); - - return NPERR_NO_ERROR; -} - -} // namespace NPAPIClient diff --git a/content/test/plugin/plugin_delete_plugin_in_deallocate_test.h b/content/test/plugin/plugin_delete_plugin_in_deallocate_test.h deleted file mode 100644 index f2e856fe6f0769..00000000000000 --- a/content/test/plugin/plugin_delete_plugin_in_deallocate_test.h +++ /dev/null @@ -1,32 +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. - -#ifndef CONTENT_TEST_PLUGIN_PLUGIN_DELETE_PLUGIN_IN_DEALLOCATE_TEST_H_ -#define CONTENT_TEST_PLUGIN_PLUGIN_DELETE_PLUGIN_IN_DEALLOCATE_TEST_H_ - -#include "base/compiler_specific.h" -#include "content/test/plugin/plugin_test.h" - -namespace NPAPIClient { - -// This test verifies that if a plugin scripts the page from within an -// NPObject's deallocation, and the page tears down the plugin, then that -// object doesn't end up being double-freed. - -class DeletePluginInDeallocateTest : public PluginTest { - public: - // Constructor. - DeletePluginInDeallocateTest(NPP id, NPNetscapeFuncs* host_functions); - - // NPAPI handlers. - NPError SetWindow(NPWindow* pNPWindow) override; - NPError Destroy() override; - - NPObject* npobject_; - bool test_started_; -}; - -} // namespace NPAPIClient - -#endif // CONTENT_TEST_PLUGIN_PLUGIN_DELETE_PLUGIN_IN_DEALLOCATE_TEST_H_ diff --git a/content/test/plugin/plugin_delete_plugin_in_stream_test.cc b/content/test/plugin/plugin_delete_plugin_in_stream_test.cc deleted file mode 100644 index edb2bbef82a0da..00000000000000 --- a/content/test/plugin/plugin_delete_plugin_in_stream_test.cc +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) 2010 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 "content/test/plugin/plugin_delete_plugin_in_stream_test.h" - -#include "content/test/plugin/plugin_client.h" - -namespace NPAPIClient { - -#define kUrl "javascript:window.location+\"\"" -#define kUrlStreamId 1 - -DeletePluginInStreamTest::DeletePluginInStreamTest(NPP id, NPNetscapeFuncs *host_functions) - : PluginTest(id, host_functions), - test_started_(false) { -} - -NPError DeletePluginInStreamTest::SetWindow(NPWindow* pNPWindow) { -#if !defined(OS_MACOSX) - if (pNPWindow->window == NULL) - return NPERR_NO_ERROR; -#endif - - if (!test_started_) { - std::string url = "self_delete_plugin_stream.html"; - HostFunctions()->geturlnotify(id(), url.c_str(), NULL, - reinterpret_cast(kUrlStreamId)); - test_started_ = true; - } - return NPERR_NO_ERROR; -} - -NPError DeletePluginInStreamTest::NewStream(NPMIMEType type, NPStream* stream, - NPBool seekable, uint16* stype) { - NPIdentifier delete_id = HostFunctions()->getstringidentifier("DeletePluginWithinScript"); - - NPObject *window_obj = NULL; - HostFunctions()->getvalue(id(), NPNVWindowNPObject, &window_obj); - - NPVariant rv; - HostFunctions()->invoke(id(), window_obj, delete_id, NULL, 0, &rv); - - return NPERR_NO_ERROR; -} - -} // namespace NPAPIClient diff --git a/content/test/plugin/plugin_delete_plugin_in_stream_test.h b/content/test/plugin/plugin_delete_plugin_in_stream_test.h deleted file mode 100644 index 2613a72fcba72f..00000000000000 --- a/content/test/plugin/plugin_delete_plugin_in_stream_test.h +++ /dev/null @@ -1,34 +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. - -#ifndef CONTENT_TEST_PLUGIN_PLUGIN_DELETE_PLUGIN_IN_STREAM_TEST_H_ -#define CONTENT_TEST_PLUGIN_PLUGIN_DELETE_PLUGIN_IN_STREAM_TEST_H_ - -#include "base/compiler_specific.h" -#include "content/test/plugin/plugin_test.h" - -namespace NPAPIClient { - -// This class tests -class DeletePluginInStreamTest : public PluginTest { - public: - // Constructor. - DeletePluginInStreamTest(NPP id, NPNetscapeFuncs *host_functions); - // - // NPAPI functions - // - NPError SetWindow(NPWindow* pNPWindow) override; - NPError NewStream(NPMIMEType type, - NPStream* stream, - NPBool seekable, - uint16* stype) override; - - private: - bool test_started_; - std::string self_url_; -}; - -} // namespace NPAPIClient - -#endif // CONTENT_TEST_PLUGIN_PLUGIN_DELETE_PLUGIN_IN_STREAM_TEST_H_ diff --git a/content/test/plugin/plugin_execute_stream_javascript.cc b/content/test/plugin/plugin_execute_stream_javascript.cc deleted file mode 100644 index 33f6eec8ea97e9..00000000000000 --- a/content/test/plugin/plugin_execute_stream_javascript.cc +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (c) 2012 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 "content/test/plugin/plugin_execute_stream_javascript.h" - -#include "base/basictypes.h" -#include "content/test/plugin/plugin_client.h" - -namespace NPAPIClient { - -static const int kMaxLength = 4096; - -ExecuteStreamJavaScript::ExecuteStreamJavaScript( - NPP id, NPNetscapeFuncs *host_functions) - : PluginTest(id, host_functions) { -} - -NPError ExecuteStreamJavaScript::NewStream(NPMIMEType type, NPStream* stream, - NPBool seekable, uint16* stype) { - return NPERR_NO_ERROR; -} - -int32 ExecuteStreamJavaScript::WriteReady(NPStream *stream) { - return kMaxLength; -} - -int32 ExecuteStreamJavaScript::Write(NPStream *stream, int32 offset, int32 len, - void *buffer) { - if (stream == NULL) { - SetError("Write got null stream"); - return -1; - } - if (len < 0 || len > kMaxLength) { - SetError("Write got bogus stream chunk size"); - return -1; - } - - std::string javascript("javascript:"); - javascript.append(static_cast(buffer), len); - size_t js_length = javascript.length(); - if (js_length != static_cast(js_length)) { - SetError("Javascript too long."); - return -1; - } - - NPString script_string = { javascript.c_str(), - static_cast(js_length) }; - NPObject *window_obj = NULL; - NPAPIClient::PluginClient::HostFunctions()->getvalue( - id(), NPNVWindowNPObject, &window_obj); - - NPVariant unused_result; - NPAPIClient::PluginClient::HostFunctions()->evaluate( - id(), window_obj, &script_string, &unused_result); - - return len; -} - -NPError ExecuteStreamJavaScript::DestroyStream(NPStream *stream, - NPError reason) { - return NPERR_NO_ERROR; -} - -} // namespace NPAPIClient diff --git a/content/test/plugin/plugin_execute_stream_javascript.h b/content/test/plugin/plugin_execute_stream_javascript.h deleted file mode 100644 index 750fc40b6437f9..00000000000000 --- a/content/test/plugin/plugin_execute_stream_javascript.h +++ /dev/null @@ -1,33 +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. - -#ifndef CONTENT_TEST_PLUGIN_PLUGIN_EXECUTE_STREAM_JAVASCRIPT_H_ -#define CONTENT_TEST_PLUGIN_PLUGIN_EXECUTE_STREAM_JAVASCRIPT_H_ - -#include "base/compiler_specific.h" -#include "content/test/plugin/plugin_test.h" - -namespace NPAPIClient { - -// This class tests executes the JavaScript given in the stream URL. -class ExecuteStreamJavaScript : public PluginTest { - public: - // Constructor. - ExecuteStreamJavaScript(NPP id, NPNetscapeFuncs *host_functions); - - // - // NPAPI functions - // - NPError NewStream(NPMIMEType type, - NPStream* stream, - NPBool seekable, - uint16* stype) override; - int32 WriteReady(NPStream* stream) override; - int32 Write(NPStream* stream, int32 offset, int32 len, void* buffer) override; - NPError DestroyStream(NPStream* stream, NPError reason) override; -}; - -} // namespace NPAPIClient - -#endif // CONTENT_TEST_PLUGIN_PLUGIN_EXECUTE_STREAM_JAVASCRIPT_H_ diff --git a/content/test/plugin/plugin_get_javascript_url2_test.cc b/content/test/plugin/plugin_get_javascript_url2_test.cc deleted file mode 100644 index 8d97daff492323..00000000000000 --- a/content/test/plugin/plugin_get_javascript_url2_test.cc +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright (c) 2010 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 "content/test/plugin/plugin_get_javascript_url2_test.h" - -#include "base/basictypes.h" - -// url for "self". -#define SELF_URL "javascript:window.location+\"\"" -// The identifier for the self url stream. -#define SELF_URL_STREAM_ID 1 - -// The maximum chunk size of stream data. -#define STREAM_CHUNK 197 - -namespace NPAPIClient { - -ExecuteGetJavascriptUrl2Test::ExecuteGetJavascriptUrl2Test( - NPP id, NPNetscapeFuncs *host_functions) - : PluginTest(id, host_functions), - test_started_(false) { -} - -NPError ExecuteGetJavascriptUrl2Test::SetWindow(NPWindow* pNPWindow) { -#if !defined(OS_MACOSX) - if (pNPWindow->window == NULL) - return NPERR_NO_ERROR; -#endif - - if (!test_started_) { - std::string url = SELF_URL; - HostFunctions()->geturlnotify(id(), url.c_str(), "_self", - reinterpret_cast(SELF_URL_STREAM_ID)); - test_started_ = true; - } - return NPERR_NO_ERROR; -} - -NPError ExecuteGetJavascriptUrl2Test::NewStream(NPMIMEType type, NPStream* stream, - NPBool seekable, uint16* stype) { - if (stream == NULL) { - SetError("NewStream got null stream"); - return NPERR_INVALID_PARAM; - } - - static_assert(sizeof(unsigned long) <= sizeof(stream->notifyData), - "cast validity check"); - unsigned long stream_id = reinterpret_cast(stream->notifyData); - switch (stream_id) { - case SELF_URL_STREAM_ID: - break; - default: - SetError("Unexpected NewStream callback"); - break; - } - return NPERR_NO_ERROR; -} - -int32 ExecuteGetJavascriptUrl2Test::WriteReady(NPStream *stream) { - return STREAM_CHUNK; -} - -int32 ExecuteGetJavascriptUrl2Test::Write(NPStream *stream, int32 offset, int32 len, - void *buffer) { - if (stream == NULL) { - SetError("Write got null stream"); - return -1; - } - if (len < 0 || len > STREAM_CHUNK) { - SetError("Write got bogus stream chunk size"); - return -1; - } - - static_assert(sizeof(unsigned long) <= sizeof(stream->notifyData), - "cast validity check"); - unsigned long stream_id = reinterpret_cast(stream->notifyData); - switch (stream_id) { - case SELF_URL_STREAM_ID: - self_url_.append(static_cast(buffer), len); - break; - default: - SetError("Unexpected write callback"); - break; - } - // Pretend that we took all the data. - return len; -} - - -NPError ExecuteGetJavascriptUrl2Test::DestroyStream(NPStream *stream, NPError reason) { - if (stream == NULL) { - SetError("NewStream got null stream"); - return NPERR_INVALID_PARAM; - } - - static_assert(sizeof(unsigned long) <= sizeof(stream->notifyData), - "cast validity check"); - unsigned long stream_id = reinterpret_cast(stream->notifyData); - switch (stream_id) { - case SELF_URL_STREAM_ID: - // don't care - break; - default: - SetError("Unexpected NewStream callback"); - break; - } - return NPERR_NO_ERROR; -} - -void ExecuteGetJavascriptUrl2Test::URLNotify(const char* url, NPReason reason, void* data) { - static_assert(sizeof(unsigned long) <= sizeof(data), - "cast validity check"); - - unsigned long stream_id = reinterpret_cast(data); - switch (stream_id) { - case SELF_URL_STREAM_ID: - if (strcmp(url, SELF_URL) != 0) - SetError("URLNotify reported incorrect url for SELF_URL"); - if (self_url_.empty()) - SetError("Failed to obtain window location."); - SignalTestCompleted(); - break; - default: - SetError("Unexpected NewStream callback"); - break; - } -} - -} // namespace NPAPIClient diff --git a/content/test/plugin/plugin_get_javascript_url2_test.h b/content/test/plugin/plugin_get_javascript_url2_test.h deleted file mode 100644 index 112fef69328076..00000000000000 --- a/content/test/plugin/plugin_get_javascript_url2_test.h +++ /dev/null @@ -1,40 +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. - -#ifndef CONTENT_TEST_PLUGIN_PLUGIN_GET_JAVASCRIPT_URL2_TEST_H_ -#define CONTENT_TEST_PLUGIN_PLUGIN_GET_JAVASCRIPT_URL2_TEST_H_ - -#include "base/compiler_specific.h" -#include "content/test/plugin/plugin_test.h" - -namespace NPAPIClient { - -// This class tests NPP_GetURLNotify for a javascript URL with _top -// as the target frame. -class ExecuteGetJavascriptUrl2Test : public PluginTest { - public: - // Constructor. - ExecuteGetJavascriptUrl2Test(NPP id, NPNetscapeFuncs *host_functions); - - // - // NPAPI functions - // - NPError SetWindow(NPWindow* pNPWindow) override; - NPError NewStream(NPMIMEType type, - NPStream* stream, - NPBool seekable, - uint16* stype) override; - int32 WriteReady(NPStream* stream) override; - int32 Write(NPStream* stream, int32 offset, int32 len, void* buffer) override; - NPError DestroyStream(NPStream* stream, NPError reason) override; - void URLNotify(const char* url, NPReason reason, void* data) override; - - private: - bool test_started_; - std::string self_url_; -}; - -} // namespace NPAPIClient - -#endif // CONTENT_TEST_PLUGIN_PLUGIN_GET_JAVASCRIPT_URL2_TEST_H_ diff --git a/content/test/plugin/plugin_get_javascript_url_test.cc b/content/test/plugin/plugin_get_javascript_url_test.cc deleted file mode 100644 index 13ccdcd155536f..00000000000000 --- a/content/test/plugin/plugin_get_javascript_url_test.cc +++ /dev/null @@ -1,220 +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 "content/test/plugin/plugin_get_javascript_url_test.h" - -#include "base/basictypes.h" -#include "base/logging.h" - -// url for "self". -#define SELF_URL "javascript:window.location+\"\"" -// The identifier for the self url stream. -#define SELF_URL_STREAM_ID 1 - -// The maximum chunk size of stream data. -#define STREAM_CHUNK 197 - -#if defined(OS_WIN) -const int kNPNEvaluateTimerID = 100; -const int kNPNEvaluateTimerElapse = 50; -#endif - -namespace NPAPIClient { - -ExecuteGetJavascriptUrlTest::ExecuteGetJavascriptUrlTest( - NPP id, NPNetscapeFuncs *host_functions) - : PluginTest(id, host_functions), - test_started_(false), -#if defined(OS_WIN) - window_(NULL), -#endif - npn_evaluate_context_(false) { -} - -NPError ExecuteGetJavascriptUrlTest::SetWindow(NPWindow* pNPWindow) { -#if !defined(OS_MACOSX) - if (pNPWindow->window == NULL) - return NPERR_NO_ERROR; -#endif - - if (!test_started_) { - std::string url = SELF_URL; - HostFunctions()->geturlnotify(id(), url.c_str(), "_top", - reinterpret_cast(SELF_URL_STREAM_ID)); - test_started_ = true; - -#if defined(OS_WIN) - HWND window_handle = reinterpret_cast(pNPWindow->window); - if (!::GetProp(window_handle, L"Plugin_Instance")) { - // TODO: this propery leaks. - ::SetProp(window_handle, L"Plugin_Instance", this); - // We attempt to retreive the NPObject for the plugin instance identified - // by the NPObjectLifetimeTestInstance2 class as it may not have been - // instantiated yet. - SetTimer(window_handle, kNPNEvaluateTimerID, kNPNEvaluateTimerElapse, - TimerProc); - } - window_ = window_handle; -#endif - } - - return NPERR_NO_ERROR; -} - -#if defined(OS_WIN) -void CALLBACK ExecuteGetJavascriptUrlTest::TimerProc( - HWND window, UINT message, UINT_PTR timer_id, DWORD elapsed_time) { - ExecuteGetJavascriptUrlTest* this_instance = - reinterpret_cast - (::GetProp(window, L"Plugin_Instance")); - CHECK(this_instance); - - ::RemoveProp(window, L"Plugin_Instance"); - - NPObject *window_obj = NULL; - this_instance->HostFunctions()->getvalue(this_instance->id(), - NPNVWindowNPObject, - &window_obj); - if (!window_obj) { - this_instance->SetError("Failed to get NPObject for plugin instance2"); - this_instance->SignalTestCompleted(); - return; - } - - std::string script = "javascript:window.location"; - NPString script_string; - script_string.UTF8Characters = script.c_str(); - script_string.UTF8Length = static_cast(script.length()); - NPVariant result_var; - - this_instance->npn_evaluate_context_ = true; - this_instance->HostFunctions()->evaluate( - this_instance->id(), window_obj, &script_string, &result_var); - this_instance->npn_evaluate_context_ = false; -} -#endif - -NPError ExecuteGetJavascriptUrlTest::NewStream(NPMIMEType type, - NPStream* stream, - NPBool seekable, - uint16* stype) { - if (stream == NULL) { - SetError("NewStream got null stream"); - return NPERR_INVALID_PARAM; - } - - if (npn_evaluate_context_) { - SetError("NewStream received in context of NPN_Evaluate"); - return NPERR_NO_ERROR; - } - - static_assert(sizeof(unsigned long) <= sizeof(stream->notifyData), - "cast validity check"); - unsigned long stream_id = reinterpret_cast(stream->notifyData); - switch (stream_id) { - case SELF_URL_STREAM_ID: - break; - default: - SetError("Unexpected NewStream callback"); - break; - } - return NPERR_NO_ERROR; -} - -int32 ExecuteGetJavascriptUrlTest::WriteReady(NPStream *stream) { - if (npn_evaluate_context_) { - SetError("WriteReady received in context of NPN_Evaluate"); - return NPERR_NO_ERROR; - } - return STREAM_CHUNK; -} - -int32 ExecuteGetJavascriptUrlTest::Write(NPStream *stream, int32 offset, - int32 len, void *buffer) { - if (stream == NULL) { - SetError("Write got null stream"); - return -1; - } - if (len < 0 || len > STREAM_CHUNK) { - SetError("Write got bogus stream chunk size"); - return -1; - } - - if (npn_evaluate_context_) { - SetError("Write received in context of NPN_Evaluate"); - return len; - } - - static_assert(sizeof(unsigned long) <= sizeof(stream->notifyData), - "cast validity check"); - unsigned long stream_id = reinterpret_cast(stream->notifyData); - switch (stream_id) { - case SELF_URL_STREAM_ID: - self_url_.append(static_cast(buffer), len); - break; - default: - SetError("Unexpected write callback"); - break; - } - // Pretend that we took all the data. - return len; -} - - -NPError ExecuteGetJavascriptUrlTest::DestroyStream(NPStream *stream, - NPError reason) { - if (stream == NULL) { - SetError("NewStream got null stream"); - return NPERR_INVALID_PARAM; - } - -#if defined(OS_WIN) - KillTimer(window_, kNPNEvaluateTimerID); -#endif - - if (npn_evaluate_context_) { - SetError("DestroyStream received in context of NPN_Evaluate"); - return NPERR_NO_ERROR; - } - - static_assert(sizeof(unsigned long) <= sizeof(stream->notifyData), - "cast validity check"); - unsigned long stream_id = reinterpret_cast(stream->notifyData); - switch (stream_id) { - case SELF_URL_STREAM_ID: - // don't care - break; - default: - SetError("Unexpected NewStream callback"); - break; - } - return NPERR_NO_ERROR; -} - -void ExecuteGetJavascriptUrlTest::URLNotify(const char* url, NPReason reason, - void* data) { - static_assert(sizeof(unsigned long) <= sizeof(data), - "cast validity check"); - - if (npn_evaluate_context_) { - SetError("URLNotify received in context of NPN_Evaluate"); - return; - } - - unsigned long stream_id = reinterpret_cast(data); - switch (stream_id) { - case SELF_URL_STREAM_ID: - if (strcmp(url, SELF_URL) != 0) - SetError("URLNotify reported incorrect url for SELF_URL"); - if (self_url_.empty()) - SetError("Failed to obtain window location."); - SignalTestCompleted(); - break; - default: - SetError("Unexpected NewStream callback"); - break; - } -} - -} // namespace NPAPIClient diff --git a/content/test/plugin/plugin_get_javascript_url_test.h b/content/test/plugin/plugin_get_javascript_url_test.h deleted file mode 100644 index c87ef4d9aa0750..00000000000000 --- a/content/test/plugin/plugin_get_javascript_url_test.h +++ /dev/null @@ -1,49 +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. - -#ifndef CONTENT_TEST_PLUGIN_PLUGIN_GET_JAVASCRIPT_URL_TEST_H_ -#define CONTENT_TEST_PLUGIN_PLUGIN_GET_JAVASCRIPT_URL_TEST_H_ - -#include "base/compiler_specific.h" -#include "content/test/plugin/plugin_test.h" - -namespace NPAPIClient { - -// This class tests NPP_GetURLNotify for a javascript URL with _top -// as the target frame. -class ExecuteGetJavascriptUrlTest : public PluginTest { - public: - // Constructor. - ExecuteGetJavascriptUrlTest(NPP id, NPNetscapeFuncs *host_functions); - // - // NPAPI functions - // - NPError SetWindow(NPWindow* pNPWindow) override; - NPError NewStream(NPMIMEType type, - NPStream* stream, - NPBool seekable, - uint16* stype) override; - int32 WriteReady(NPStream* stream) override; - int32 Write(NPStream* stream, int32 offset, int32 len, void* buffer) override; - NPError DestroyStream(NPStream* stream, NPError reason) override; - void URLNotify(const char* url, NPReason reason, void* data) override; - - private: -#if defined(OS_WIN) - static void CALLBACK TimerProc(HWND window, UINT message, UINT_PTR timer_id, - DWORD elapsed_time); -#endif - bool test_started_; - // This flag is set to true in the context of the NPN_Evaluate call. - bool npn_evaluate_context_; - std::string self_url_; - -#if defined(OS_WIN) - HWND window_; -#endif -}; - -} // namespace NPAPIClient - -#endif // CONTENT_TEST_PLUGIN_PLUGIN_GET_JAVASCRIPT_URL_TEST_H_ diff --git a/content/test/plugin/plugin_geturl_test.cc b/content/test/plugin/plugin_geturl_test.cc deleted file mode 100644 index c230e4d1b2a54c..00000000000000 --- a/content/test/plugin/plugin_geturl_test.cc +++ /dev/null @@ -1,477 +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 "content/test/plugin/plugin_geturl_test.h" - -#include - -#include "base/basictypes.h" -#include "base/files/file_util.h" -#include "base/strings/string_number_conversions.h" -#include "base/strings/string_util.h" -#include "base/strings/utf_string_conversions.h" - -// url for "self". The %22%22 is to make a statement for javascript to -// evaluate and return. -#define SELF_URL "javascript:window.location+\"\"" - -// The identifier for the self url stream. -#define SELF_URL_STREAM_ID 1 - -// The identifier for the fetched url stream. -#define FETCHED_URL_STREAM_ID 2 - -// url for testing GetURL with a bogus URL. -#define BOGUS_URL "bogoproto:///x:/asdf.xysdhffieasdf.asdhj/" - -// url for testing redirect notifications sent to plugins. -#define REDIRECT_SRC_URL \ - "http://mock.http/npapi/plugin_read_page_redirect_src.html" - -// The notification id for the redirect notification url that we will cancel. -#define REDIRECT_SRC_URL_NOTIFICATION_CANCEL_ID 4 - -// The notification id for the redirect notification url that we will accept. -#define REDIRECT_SRC_URL_NOTIFICATION_ALLOW_ID 5 - -// The identifier for the bogus url stream. -#define BOGUS_URL_STREAM_ID 3 - -// The maximum chunk size of stream data. -#define STREAM_CHUNK 197 - -namespace NPAPIClient { - -PluginGetURLTest::PluginGetURLTest(NPP id, NPNetscapeFuncs *host_functions) - : PluginTest(id, host_functions), - tests_started_(false), - tests_in_progress_(0), - test_file_(NULL), - expect_404_response_(false), - npn_evaluate_context_(false), - handle_url_redirects_(false), - received_url_redirect_cancel_notification_(false), - received_url_redirect_allow_notification_(false), - check_cookies_(false) { -} - -PluginGetURLTest::~PluginGetURLTest() {} - -NPError PluginGetURLTest::New(uint16 mode, int16 argc, const char* argn[], - const char* argv[], NPSavedData* saved) { - const char* page_not_found_url = GetArgValue("page_not_found_url", argc, - argn, argv); - if (page_not_found_url) { - page_not_found_url_ = page_not_found_url; - expect_404_response_ = true; - } - - const char* fail_write_url = GetArgValue("fail_write_url", argc, - argn, argv); - if (fail_write_url) { - fail_write_url_ = fail_write_url; - } - - const char* referrer_target_url = GetArgValue("ref_target", argc, - argn, argv); - if (referrer_target_url) { - referrer_target_url_ = referrer_target_url; - } - - if (!base::strcasecmp(GetArgValue("name", argc, argn, argv), - "geturlredirectnotify")) { - handle_url_redirects_ = true; - } - - NPError error = PluginTest::New(mode, argc, argn, argv, saved); - - // The above sets test_name(). - if (test_name() == "cookies") - check_cookies_ = true; - - return error; -} - -NPError PluginGetURLTest::SetWindow(NPWindow* pNPWindow) { -#if !defined(OS_MACOSX) - if (pNPWindow->window == NULL) - return NPERR_NO_ERROR; -#endif - - if (!tests_started_) { - tests_started_ = true; - - tests_in_progress_++; - - if (expect_404_response_) { - HostFunctions()->geturl(id(), page_not_found_url_.c_str(), NULL); - return NPERR_NO_ERROR; - } else if (!fail_write_url_.empty()) { - HostFunctions()->geturl(id(), fail_write_url_.c_str(), NULL); - return NPERR_NO_ERROR; - } else if (!referrer_target_url_.empty()) { - HostFunctions()->pushpopupsenabledstate(id(), true); - HostFunctions()->geturl(id(), referrer_target_url_.c_str(), "_blank"); - HostFunctions()->poppopupsenabledstate(id()); - return NPERR_NO_ERROR; - } else if (handle_url_redirects_) { - HostFunctions()->geturlnotify( - id(), REDIRECT_SRC_URL, NULL, - reinterpret_cast(REDIRECT_SRC_URL_NOTIFICATION_CANCEL_ID)); - return NPERR_NO_ERROR; - } else if (check_cookies_) { - HostFunctions()->geturlnotify( - id(), - "plugin_ref_target_page.html", - NULL, - reinterpret_cast(SELF_URL_STREAM_ID)); - return NPERR_NO_ERROR; - } - - std::string url = SELF_URL; - HostFunctions()->geturlnotify(id(), url.c_str(), NULL, - reinterpret_cast(SELF_URL_STREAM_ID)); - - tests_in_progress_++; - std::string bogus_url = BOGUS_URL; - HostFunctions()->geturlnotify(id(), bogus_url.c_str(), NULL, - reinterpret_cast(BOGUS_URL_STREAM_ID)); - } - return NPERR_NO_ERROR; -} - -NPError PluginGetURLTest::NewStream(NPMIMEType type, NPStream* stream, - NPBool seekable, uint16* stype) { - if (stream == NULL) { - SetError("NewStream got null stream"); - return NPERR_INVALID_PARAM; - } - - if (test_completed()) { - return PluginTest::NewStream(type, stream, seekable, stype); - } - - if (!referrer_target_url_.empty()) { - return NPERR_NO_ERROR; - } - - static_assert(sizeof(unsigned long) <= sizeof(stream->notifyData), - "cast validity check"); - - if (expect_404_response_) { - NPObject *window_obj = NULL; - HostFunctions()->getvalue(id(), NPNVWindowNPObject, &window_obj); - if (!window_obj) { - SetError("Failed to get NPObject for plugin instance2"); - SignalTestCompleted(); - return NPERR_NO_ERROR; - } - - std::string script = "javascript:document.title=\"OK\""; - NPString script_string; - script_string.UTF8Characters = script.c_str(); - script_string.UTF8Length = static_cast(script.length()); - NPVariant result_var; - - npn_evaluate_context_ = true; - HostFunctions()->evaluate(id(), window_obj, &script_string, &result_var); - npn_evaluate_context_ = false; - return NPERR_NO_ERROR; - } - - if (!fail_write_url_.empty() || check_cookies_) { - return NPERR_NO_ERROR; - } - - - unsigned long stream_id = reinterpret_cast( - stream->notifyData); - - switch (stream_id) { - case SELF_URL_STREAM_ID: - break; - case FETCHED_URL_STREAM_ID: - { - std::string filename = self_url_; - if (filename.find("file:///", 0) != 0) { - SetError("Test expects a file-url."); - break; - } - - // TODO(evanm): use the net:: functions to convert file:// URLs to - // on-disk file paths. But it probably doesn't actually matter in - // this test. - -#if defined(OS_WIN) - filename = filename.substr(8); // remove "file:///" - // Assume an ASCII path on Windows. - base::FilePath path = base::FilePath(base::ASCIIToUTF16(filename)); -#else - filename = filename.substr(7); // remove "file://" - base::FilePath path = base::FilePath(filename); -#endif - - test_file_ = base::OpenFile(path, "r"); - if (!test_file_) { - SetError("Could not open source file"); - } - } - break; - case BOGUS_URL_STREAM_ID: - SetError("Unexpected NewStream for BOGUS_URL"); - break; - case REDIRECT_SRC_URL_NOTIFICATION_CANCEL_ID: - SetError("Should not redirect to URL when plugin denied it."); - break; - case REDIRECT_SRC_URL_NOTIFICATION_ALLOW_ID: - break; - default: - SetError("Unexpected NewStream callback"); - break; - } - return NPERR_NO_ERROR; -} - -int32 PluginGetURLTest::WriteReady(NPStream *stream) { - if (test_completed()) { - return PluginTest::WriteReady(stream); - } - - if (!referrer_target_url_.empty() || check_cookies_) { - return STREAM_CHUNK; - } - - static_assert(sizeof(unsigned long) <= sizeof(stream->notifyData), - "cast validity check"); - unsigned long stream_id = reinterpret_cast( - stream->notifyData); - if (stream_id == BOGUS_URL_STREAM_ID) - SetError("Received WriteReady for BOGUS_URL"); - - return STREAM_CHUNK; -} - -int32 PluginGetURLTest::Write(NPStream *stream, int32 offset, int32 len, - void *buffer) { - if (test_completed()) { - return PluginTest::Write(stream, offset, len, buffer); - } - - if (!fail_write_url_.empty()) { - SignalTestCompleted(); - return -1; - } - - if (!referrer_target_url_.empty() || check_cookies_) { - return len; - } - - if (stream == NULL) { - SetError("Write got null stream"); - return -1; - } - if (len < 0 || len > STREAM_CHUNK) { - SetError("Write got bogus stream chunk size"); - return -1; - } - - static_assert(sizeof(unsigned long) <= sizeof(stream->notifyData), - "cast validity check"); - unsigned long stream_id = reinterpret_cast( - stream->notifyData); - switch (stream_id) { - case SELF_URL_STREAM_ID: - self_url_.append(static_cast(buffer), len); - break; - case FETCHED_URL_STREAM_ID: - { - char read_buffer[STREAM_CHUNK]; - int32 bytes = - static_cast(fread(read_buffer, 1, len, test_file_)); - // Technically, fread could return fewer than len - // bytes. But this is not likely. - if (bytes != len) - SetError("Did not read correct bytelength from source file"); - if (memcmp(read_buffer, buffer, len)) - SetError("Content mismatch between data and source!"); - } - break; - case BOGUS_URL_STREAM_ID: - SetError("Unexpected write callback for BOGUS_URL"); - break; - case REDIRECT_SRC_URL_NOTIFICATION_ALLOW_ID: - break; - default: - SetError("Unexpected write callback"); - break; - } - // Pretend that we took all the data. - return len; -} - - -NPError PluginGetURLTest::DestroyStream(NPStream *stream, NPError reason) { - if (test_completed()) { - return PluginTest::DestroyStream(stream, reason); - } - - if (stream == NULL) { - SetError("NewStream got null stream"); - return NPERR_INVALID_PARAM; - } - - static_assert(sizeof(unsigned long) <= sizeof(stream->notifyData), - "cast validity check"); - - if (expect_404_response_) { - if (npn_evaluate_context_) { - SetError("Received destroyStream in the context of NPN_Evaluate."); - } - - SignalTestCompleted(); - return NPERR_NO_ERROR; - } - - if (!referrer_target_url_.empty()) { - return NPERR_NO_ERROR; - } - - if (check_cookies_) { - SignalTestCompleted(); - return NPERR_NO_ERROR; - } - - unsigned long stream_id = - reinterpret_cast(stream->notifyData); - switch (stream_id) { - case SELF_URL_STREAM_ID: - // don't care - break; - case REDIRECT_SRC_URL_NOTIFICATION_ALLOW_ID: - break; - case FETCHED_URL_STREAM_ID: - { - char read_buffer[STREAM_CHUNK]; - size_t bytes = fread(read_buffer, 1, sizeof(read_buffer), test_file_); - if (bytes != 0) - SetError("Data and source mismatch on length"); - base::CloseFile(test_file_); - } - break; - default: - SetError("Unexpected NewStream callback"); - break; - } - return NPERR_NO_ERROR; -} - -void PluginGetURLTest::StreamAsFile(NPStream* stream, const char* fname) { - if (stream == NULL) { - SetError("NewStream got null stream"); - return; - } - - static_assert(sizeof(unsigned long) <= sizeof(stream->notifyData), - "cast validity check"); - unsigned long stream_id = - reinterpret_cast(stream->notifyData); - switch (stream_id) { - case SELF_URL_STREAM_ID: - // don't care - break; - default: - SetError("Unexpected NewStream callback"); - break; - } -} - -void PluginGetURLTest::URLNotify(const char* url, NPReason reason, void* data) { - if (!tests_in_progress_) { - SetError("URLNotify received after tests completed"); - return; - } - - if (!url) { - SetError("URLNotify received NULL url"); - return; - } - - if (check_cookies_) - return; - - static_assert(sizeof(unsigned long) <= sizeof(data), "cast validity check"); - unsigned long stream_id = reinterpret_cast(data); - switch (stream_id) { - case SELF_URL_STREAM_ID: - if (strcmp(url, SELF_URL) != 0) - SetError("URLNotify reported incorrect url for SELF_URL"); - - // We have our stream url. Go fetch it. - HostFunctions()->geturlnotify(id(), self_url_.c_str(), NULL, - reinterpret_cast(FETCHED_URL_STREAM_ID)); - break; - case FETCHED_URL_STREAM_ID: - if (!url || strcmp(url, self_url_.c_str()) != 0) - SetError("URLNotify reported incorrect url for FETCHED_URL"); - tests_in_progress_--; - break; - case BOGUS_URL_STREAM_ID: - if (reason != NPRES_NETWORK_ERR) { - std::string err = "BOGUS_URL received unexpected URLNotify status: "; - err.append(base::IntToString(reason)); - SetError(err); - } - tests_in_progress_--; - break; - case REDIRECT_SRC_URL_NOTIFICATION_CANCEL_ID: { - if (!received_url_redirect_cancel_notification_) { - SetError("Failed to receive URLRedirect notification for cancel"); - } - if (reason != NPRES_NETWORK_ERR) { - SetError("Redirected URL didn't get canceled"); - } - break; - } - case REDIRECT_SRC_URL_NOTIFICATION_ALLOW_ID: { - if (!received_url_redirect_allow_notification_) { - SetError("Failed to receive URLRedirect notification for allow"); - } - if (reason != NPRES_DONE) { - SetError("Redirected URL didn't complete successfully"); - } - tests_in_progress_--; - break; - } - default: - SetError("Unexpected NewStream callback"); - break; - } - - if (tests_in_progress_ == 0) - SignalTestCompleted(); -} - -void PluginGetURLTest::URLRedirectNotify(const char* url, - int32_t status, - void* notify_data) { - unsigned long stream_id = reinterpret_cast(notify_data); - if (stream_id == REDIRECT_SRC_URL_NOTIFICATION_CANCEL_ID) { - if (!base::strcasecmp(url, - "http://mock.http/npapi/plugin_read_page.html")) { - received_url_redirect_cancel_notification_ = true; - // Disallow redirect notification. - HostFunctions()->urlredirectresponse(id(), notify_data, false); - - // Now start a request that we will allow to redirect. - HostFunctions()->geturlnotify( - id(), REDIRECT_SRC_URL, NULL, - reinterpret_cast(REDIRECT_SRC_URL_NOTIFICATION_ALLOW_ID)); - } - } else if (stream_id == REDIRECT_SRC_URL_NOTIFICATION_ALLOW_ID) { - received_url_redirect_allow_notification_ = true; - HostFunctions()->urlredirectresponse(id(), notify_data, true); - } -} - -} // namespace NPAPIClient diff --git a/content/test/plugin/plugin_geturl_test.h b/content/test/plugin/plugin_geturl_test.h deleted file mode 100644 index 6d35d5f1c7bda4..00000000000000 --- a/content/test/plugin/plugin_geturl_test.h +++ /dev/null @@ -1,70 +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. - -#ifndef CONTENT_TEST_PLUGIN_PLUGIN_GETURL_TEST_H_ -#define CONTENT_TEST_PLUGIN_PLUGIN_GETURL_TEST_H_ - -#include - -#include "base/compiler_specific.h" -#include "content/test/plugin/plugin_test.h" - -namespace NPAPIClient { - -// The PluginGetURLTest test functionality of the NPN_GetURL -// and NPN_GetURLNotify methods. -// -// This test first discovers it's URL by sending a GetURL request -// for 'javascript:top.location'. After receiving that, the -// test will request the url itself (again via GetURL). -class PluginGetURLTest : public PluginTest { - public: - // Constructor. - PluginGetURLTest(NPP id, NPNetscapeFuncs *host_functions); - ~PluginGetURLTest() override; - - // - // NPAPI functions - // - NPError New(uint16 mode, - int16 argc, - const char* argn[], - const char* argv[], - NPSavedData* saved) override; - NPError SetWindow(NPWindow* pNPWindow) override; - NPError NewStream(NPMIMEType type, - NPStream* stream, - NPBool seekable, - uint16* stype) override; - int32 WriteReady(NPStream* stream) override; - int32 Write(NPStream* stream, int32 offset, int32 len, void* buffer) override; - NPError DestroyStream(NPStream* stream, NPError reason) override; - void StreamAsFile(NPStream* stream, const char* fname) override; - void URLNotify(const char* url, NPReason reason, void* data) override; - void URLRedirectNotify(const char* url, - int32_t status, - void* notify_data) override; - - private: - bool tests_started_; - int tests_in_progress_; - std::string self_url_; - FILE* test_file_; - bool expect_404_response_; - // This flag is set to true in the context of the NPN_Evaluate call. - bool npn_evaluate_context_; - // The following two flags handle URL redirect notifications received by - // plugins. - bool handle_url_redirects_; - bool received_url_redirect_cancel_notification_; - bool received_url_redirect_allow_notification_; - std::string page_not_found_url_; - std::string fail_write_url_; - std::string referrer_target_url_; - bool check_cookies_; -}; - -} // namespace NPAPIClient - -#endif // CONTENT_TEST_PLUGIN_PLUGIN_GETURL_TEST_H_ diff --git a/content/test/plugin/plugin_javascript_open_popup.cc b/content/test/plugin/plugin_javascript_open_popup.cc deleted file mode 100644 index 0b8daf8280ceca..00000000000000 --- a/content/test/plugin/plugin_javascript_open_popup.cc +++ /dev/null @@ -1,83 +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 "content/test/plugin/plugin_javascript_open_popup.h" - -#include "build/build_config.h" -#include "base/logging.h" - -#include "content/test/plugin/plugin_client.h" - -namespace NPAPIClient { - -ExecuteJavascriptOpenPopupWithPluginTest:: - ExecuteJavascriptOpenPopupWithPluginTest(NPP id, - NPNetscapeFuncs *host_functions) - : PluginTest(id, host_functions), - popup_window_test_started_(false) { -} - -int16 ExecuteJavascriptOpenPopupWithPluginTest::SetWindow( - NPWindow* window) { -#if !defined(OS_MACOSX) - if (window->window == NULL) - return NPERR_NO_ERROR; -#endif - - if (!popup_window_test_started_) { - popup_window_test_started_ = true; - HostFunctions()->geturl( - id(), "popup_window_with_target_plugin.html", "_blank"); - } - return NPERR_NO_ERROR; -} - -// ExecuteJavascriptPopupWindowTargetPluginTest member defines. -ExecuteJavascriptPopupWindowTargetPluginTest:: - ExecuteJavascriptPopupWindowTargetPluginTest( - NPP id, NPNetscapeFuncs* host_functions) - : PluginTest(id, host_functions), - test_completed_(false) { -} - -int16 ExecuteJavascriptPopupWindowTargetPluginTest::SetWindow( - NPWindow* window) { -#if !defined(OS_MACOSX) - if (window->window == NULL) - return NPERR_NO_ERROR; -#endif - - if (!test_completed_) { - if (CheckWindow(window)) { - SignalTestCompleted(); - test_completed_ = true; - } - } - return PluginTest::SetWindow(window); -} - -#if defined(OS_WIN) -bool ExecuteJavascriptPopupWindowTargetPluginTest::CheckWindow( - NPWindow* window) { - HWND window_handle = reinterpret_cast(window->window); - - if (IsWindow(window_handle)) { - HWND parent_window = GetParent(window_handle); - if (!IsWindow(parent_window)) - SetError("Windowed plugin instantiated with NULL parent"); - return true; - } - - return false; -} - -#elif defined(OS_MACOSX) -bool ExecuteJavascriptPopupWindowTargetPluginTest::CheckWindow( - NPWindow* window) { - // TODO(port) scaffolding--replace with a real test once NPWindow is done. - return false; -} -#endif - -} // namespace NPAPIClient diff --git a/content/test/plugin/plugin_javascript_open_popup.h b/content/test/plugin/plugin_javascript_open_popup.h deleted file mode 100644 index 4158d5d700528d..00000000000000 --- a/content/test/plugin/plugin_javascript_open_popup.h +++ /dev/null @@ -1,48 +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. - -#ifndef CONTENT_TEST_PLUGIN_PLUGIN_JAVASCRIPT_OPEN_POPUP_H_ -#define CONTENT_TEST_PLUGIN_PLUGIN_JAVASCRIPT_OPEN_POPUP_H_ - -#include "base/compiler_specific.h" -#include "content/test/plugin/plugin_test.h" - -namespace NPAPIClient { - -// This class tests the case where a windowed plugin instance is -// instantiated in a popup window. The plugin instance needs to -// have a valid parent window. -class ExecuteJavascriptOpenPopupWithPluginTest : public PluginTest { - public: - // Constructor. - ExecuteJavascriptOpenPopupWithPluginTest( - NPP id, NPNetscapeFuncs *host_functions); - // NPAPI SetWindow handler. - NPError SetWindow(NPWindow* window) override; - - private: - bool popup_window_test_started_; -}; - -// This class represents a windowed plugin instance instantiated within a -// popup window. It verifies that the plugin instance has a valid parent. -class ExecuteJavascriptPopupWindowTargetPluginTest : public PluginTest { - public: - ExecuteJavascriptPopupWindowTargetPluginTest( - NPP id, NPNetscapeFuncs *host_functions); - // NPAPI SetWindow handler. - NPError SetWindow(NPWindow* window) override; - - private: - // Do a platform-specific validation of the passed-in |window|. - // E.g. on Windows, verifies window->window is a reasonable HWND. - // Returns true if the test should be marked complete. - bool CheckWindow(NPWindow* window); - - bool test_completed_; -}; - -} // namespace NPAPIClient - -#endif // CONTENT_TEST_PLUGIN_PLUGIN_JAVASCRIPT_OPEN_POPUP_H_ diff --git a/content/test/plugin/plugin_new_fails_test.cc b/content/test/plugin/plugin_new_fails_test.cc deleted file mode 100644 index 1d2e53e708fc40..00000000000000 --- a/content/test/plugin/plugin_new_fails_test.cc +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) 2010 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 "content/test/plugin/plugin_new_fails_test.h" - -namespace NPAPIClient { - -NewFailsTest::NewFailsTest(NPP id, NPNetscapeFuncs *host_functions) - : PluginTest(id, host_functions) { -} - -NPError NewFailsTest::New(uint16 mode, int16 argc, const char* argn[], - const char* argv[], NPSavedData* saved) { - return NPERR_GENERIC_ERROR; -} - -} // namespace NPAPIClient diff --git a/content/test/plugin/plugin_new_fails_test.h b/content/test/plugin/plugin_new_fails_test.h deleted file mode 100644 index abd85ce989658d..00000000000000 --- a/content/test/plugin/plugin_new_fails_test.h +++ /dev/null @@ -1,25 +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. - -#ifndef CONTENT_TEST_PLUGIN_PLUGIN_NEW_FAILS_TEST_H_ -#define CONTENT_TEST_PLUGIN_PLUGIN_NEW_FAILS_TEST_H_ - -#include "base/compiler_specific.h" -#include "content/test/plugin/plugin_test.h" - -namespace NPAPIClient { - -class NewFailsTest : public PluginTest { - public: - NewFailsTest(NPP id, NPNetscapeFuncs *host_functions); - NPError New(uint16 mode, - int16 argc, - const char* argn[], - const char* argv[], - NPSavedData* saved) override; -}; - -} // namespace NPAPIClient - -#endif // CONTENT_TEST_PLUGIN_PLUGIN_NEW_FAILS_TEST_H_ diff --git a/content/test/plugin/plugin_npobject_identity_test.cc b/content/test/plugin/plugin_npobject_identity_test.cc deleted file mode 100644 index 74046e471c63b5..00000000000000 --- a/content/test/plugin/plugin_npobject_identity_test.cc +++ /dev/null @@ -1,90 +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 "content/test/plugin/plugin_npobject_identity_test.h" - -#include "base/basictypes.h" -#include "base/compiler_specific.h" - -namespace { - -class NPThingy : public NPObject { - public: - NPThingy() : NPObject() {} - - static NPObject* Allocate(NPP npp, NPClass* npclass) { - return new NPThingy(); - } - - static void Deallocate(NPObject* npobject) { - delete static_cast(npobject); - } -}; - -NPClass* GetNPThingyClass() { - static NPClass plugin_class = { - NP_CLASS_STRUCT_VERSION, - NPThingy::Allocate, - NPThingy::Deallocate, - NULL, // Invalidate - NULL, // HasMethod - NULL, // Invoke - NULL, // InvokeDefault - NULL, // HasProperty - NULL, // GetProperty - NULL, // SetProperty - NULL, // RemoveProperty - }; - return &plugin_class; -} - - -} // namespace - -namespace NPAPIClient { - -NPObjectIdentityTest::NPObjectIdentityTest(NPP id, - NPNetscapeFuncs *host_functions) - : PluginTest(id, host_functions) { -} - -NPError NPObjectIdentityTest::SetWindow(NPWindow* pNPWindow) { -#if !defined(OS_MACOSX) - if (pNPWindow->window == NULL) - return NPERR_NO_ERROR; -#endif - - NPIdentifier are_these_the_same_id = HostFunctions()->getstringidentifier( - "areTheseTheSame"); - - // Get a function from window.areTheseTheSame. - NPObject* window; - HostFunctions()->getvalue(id(), NPNVWindowNPObject, &window); - NPVariant func_var; - HostFunctions()->getproperty(id(), window, are_these_the_same_id, &func_var); - NPObject* func = NPVARIANT_TO_OBJECT(func_var); - - // Create a custom NPObject and pass it in both arguments to areTheseTheSame. - NPObject* thingy = HostFunctions()->createobject(id(), GetNPThingyClass()); - NPVariant func_args[2]; - OBJECT_TO_NPVARIANT(thingy, func_args[0]); - OBJECT_TO_NPVARIANT(thingy, func_args[1]); - NPVariant were_the_same_var; - HostFunctions()->invokeDefault(id(), func, (const NPVariant*)&func_args, 2, - &were_the_same_var); - - // Confirm that JavaScript could see that the objects were the same. - bool were_the_same = NPVARIANT_TO_BOOLEAN(were_the_same_var); - if (!were_the_same) - SetError("Identity was lost in passing from NPAPI into JavaScript."); - - HostFunctions()->releaseobject(thingy); - - // If this test failed, then we'd have crashed by now. - SignalTestCompleted(); - - return NPERR_NO_ERROR; -} - -} // namespace NPAPIClient diff --git a/content/test/plugin/plugin_npobject_identity_test.h b/content/test/plugin/plugin_npobject_identity_test.h deleted file mode 100644 index fa749a5eda3ee3..00000000000000 --- a/content/test/plugin/plugin_npobject_identity_test.h +++ /dev/null @@ -1,27 +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. -#ifndef CONTENT_TEST_PLUGIN_PLUGIN_NPOBJECT_IDENTITY_TEST_H_ -#define CONTENT_TEST_PLUGIN_PLUGIN_NPOBJECT_IDENTITY_TEST_H_ - -#include "base/compiler_specific.h" -#include "content/test/plugin/plugin_test.h" - -namespace NPAPIClient { - -// The NPObjectProxyTest tests that when we proxy an NPObject that is itself -// a proxy, we don't create a new proxy but instead just use the original -// pointer. - -class NPObjectIdentityTest : public PluginTest { - public: - // Constructor. - NPObjectIdentityTest(NPP id, NPNetscapeFuncs *host_functions); - - // NPAPI SetWindow handler. - NPError SetWindow(NPWindow* pNPWindow) override; -}; - -} // namespace NPAPIClient - -#endif // CONTENT_TEST_PLUGIN_PLUGIN_NPOBJECT_IDENTITY_TEST_H_ diff --git a/content/test/plugin/plugin_npobject_lifetime_test.cc b/content/test/plugin/plugin_npobject_lifetime_test.cc deleted file mode 100644 index 3e28874776ed42..00000000000000 --- a/content/test/plugin/plugin_npobject_lifetime_test.cc +++ /dev/null @@ -1,174 +0,0 @@ -// Copyright (c) 2010 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 "content/test/plugin/plugin_npobject_lifetime_test.h" - -namespace NPAPIClient { - -const int kNPObjectLifetimeTimer = 100; -const int kNPObjectLifetimeTimerElapse = 2000; - -NPObject* NPObjectLifetimeTestInstance2::plugin_instance_object_ = NULL; - -NPObjectDeletePluginInNPN_Evaluate* - NPObjectDeletePluginInNPN_Evaluate::g_npn_evaluate_test_instance_ = NULL; - -NPObjectLifetimeTest::NPObjectLifetimeTest(NPP id, - NPNetscapeFuncs *host_functions) - : PluginTest(id, host_functions), - other_plugin_instance_object_(NULL), - timer_id_(0) { -} - -NPError NPObjectLifetimeTest::SetWindow(NPWindow* pNPWindow) { - if (pNPWindow->window == NULL) - return NPERR_NO_ERROR; - - HWND window_handle = reinterpret_cast(pNPWindow->window); - if (!::GetProp(window_handle, L"Plugin_Instance")) { - // TODO: this propery leaks. - ::SetProp(window_handle, L"Plugin_Instance", this); - // We attempt to retreive the NPObject for the plugin instance identified - // by the NPObjectLifetimeTestInstance2 class as it may not have been - // instantiated yet. - timer_id_ = SetTimer(window_handle, kNPObjectLifetimeTimer, - kNPObjectLifetimeTimerElapse, TimerProc); - } - return NPERR_NO_ERROR; -} - -void CALLBACK NPObjectLifetimeTest::TimerProc( - HWND window, UINT message, UINT_PTR timer_id, - DWORD elapsed_milli_seconds) { - - NPObjectLifetimeTest* this_instance = - reinterpret_cast - (::GetProp(window, L"Plugin_Instance")); - KillTimer(window, this_instance->timer_id_); - ::RemoveProp(window, L"Plugin_Instance"); - - this_instance->timer_id_ = 0; - - this_instance->other_plugin_instance_object_ = - NPObjectLifetimeTestInstance2::plugin_instance_object_; - this_instance->HostFunctions()->retainobject( - this_instance->other_plugin_instance_object_); - - NPString script; - script.UTF8Characters = "javascript:DeleteSecondPluginInstance()"; - script.UTF8Length = static_cast(strlen(script.UTF8Characters)); - - this_instance->HostFunctions()->geturlnotify( - this_instance->id(), "javascript:DeleteSecondPluginInstance()", NULL, - reinterpret_cast(1)); -} - -void NPObjectLifetimeTest::URLNotify(const char* url, NPReason reason, - void* data) { - // Create a "location" identifier. - NPIdentifier identifier = HostFunctions()->getstringidentifier("location"); - // Declare a local variant value. - NPVariant variantValue; - // Get the location property from the window object (which is another object). - HostFunctions()->getproperty(id(), other_plugin_instance_object_, identifier, - &variantValue ); - HostFunctions()->releaseobject(other_plugin_instance_object_); - other_plugin_instance_object_ = NULL; - // If this test failed, then we'd have crashed by now. - SignalTestCompleted(); -} - -NPObjectLifetimeTestInstance2::NPObjectLifetimeTestInstance2( - NPP id, NPNetscapeFuncs *host_functions) - : PluginTest(id, host_functions) { -} - -NPObjectLifetimeTestInstance2::~NPObjectLifetimeTestInstance2() { - if (plugin_instance_object_) { - HostFunctions()->releaseobject(plugin_instance_object_); - plugin_instance_object_ = NULL; - } -} - -NPError NPObjectLifetimeTestInstance2::SetWindow(NPWindow* pNPWindow) { - if (pNPWindow->window == NULL) - return NPERR_NO_ERROR; - - if (!plugin_instance_object_) { - if (!HostFunctions()->getvalue(id(), NPNVWindowNPObject, - &plugin_instance_object_)) { - SetError("Failed to get NPObject for plugin instance2"); - SignalTestCompleted(); - return NPERR_GENERIC_ERROR; - } - } - - return NPERR_NO_ERROR; -} - - -NPObjectDeletePluginInNPN_Evaluate::NPObjectDeletePluginInNPN_Evaluate( - NPP id, NPNetscapeFuncs *host_functions) - : PluginTest(id, host_functions), - plugin_instance_object_(NULL), - timer_id_(0) { - g_npn_evaluate_test_instance_ = this; -} - -NPObjectDeletePluginInNPN_Evaluate::~NPObjectDeletePluginInNPN_Evaluate() { - if (plugin_instance_object_) { - HostFunctions()->releaseobject(plugin_instance_object_); - plugin_instance_object_ = NULL; - } -} - -NPError NPObjectDeletePluginInNPN_Evaluate::SetWindow(NPWindow* np_window) { - if (np_window->window == NULL) - return NPERR_NO_ERROR; - - HWND window_handle = reinterpret_cast(np_window->window); - // We setup a timerproc to invoke NPN_Evaluate to destroy this plugin - // instance. This is to ensure that we don't destroy the plugin instance - // while it is being used in webkit as this leads to crashes and is a - // more accurate representation of the renderer crash as described in - // http://b/issue?id=1134683. - if (!timer_id_) { - timer_id_ = SetTimer(window_handle, kNPObjectLifetimeTimer, - kNPObjectLifetimeTimerElapse, TimerProc); - } - return NPERR_NO_ERROR; -} - -void CALLBACK NPObjectDeletePluginInNPN_Evaluate::TimerProc( - HWND window, UINT message, UINT_PTR timer_id, - DWORD elapsed_milli_seconds) { - - KillTimer(window, g_npn_evaluate_test_instance_->timer_id_); - g_npn_evaluate_test_instance_->timer_id_ = 0; - NPObject *window_obj = NULL; - g_npn_evaluate_test_instance_->HostFunctions()->getvalue( - g_npn_evaluate_test_instance_->id(), NPNVWindowNPObject, - &window_obj); - - if (!window_obj) { - g_npn_evaluate_test_instance_->SetError( - "Failed to get NPObject for plugin instance2"); - g_npn_evaluate_test_instance_->SignalTestCompleted(); - return; - } - - std::string script = "javascript:DeletePluginWithinScript()"; - NPString script_string; - script_string.UTF8Characters = script.c_str(); - script_string.UTF8Length = - static_cast(script.length()); - - NPVariant result_var; - g_npn_evaluate_test_instance_->HostFunctions()->evaluate( - g_npn_evaluate_test_instance_->id(), window_obj, - &script_string, &result_var); - // If this test failed we would have crashed by now. -} - -} // namespace NPAPIClient diff --git a/content/test/plugin/plugin_npobject_lifetime_test.h b/content/test/plugin/plugin_npobject_lifetime_test.h deleted file mode 100644 index f1abed22e1b659..00000000000000 --- a/content/test/plugin/plugin_npobject_lifetime_test.h +++ /dev/null @@ -1,84 +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. - -#ifndef CONTENT_TEST_PLUGIN_PLUGIN_NPOBJECT_LIFETIME_TEST_H_ -#define CONTENT_TEST_PLUGIN_PLUGIN_NPOBJECT_LIFETIME_TEST_H_ - -#include "base/compiler_specific.h" -#include "build/build_config.h" -#include "content/test/plugin/plugin_test.h" - -namespace NPAPIClient { - -// The NPObjectLifeTime class tests the case where a plugin has an NPObject -// which points to a different plugin instance on a different frame in the -// page and whether refcounts on this npobject are valid when the source frame -// is destroyed. -class NPObjectLifetimeTest : public PluginTest { - public: - // Constructor. - NPObjectLifetimeTest(NPP id, NPNetscapeFuncs *host_functions); - - // NPAPI SetWindow handler. - NPError SetWindow(NPWindow* pNPWindow) override; - - void URLNotify(const char* url, NPReason reason, void* data) override; - - protected: - NPObject* other_plugin_instance_object_; - -#if defined(OS_WIN) - static void CALLBACK TimerProc(HWND window, UINT message, UINT_PTR timer_id, - DWORD elapsed_milli_seconds); - UINT_PTR timer_id_; -#endif - DISALLOW_IMPLICIT_CONSTRUCTORS(NPObjectLifetimeTest); -}; - -// The NPObjectLifetimeTestInstance2 class represents the plugin instance -// which is deleted by the NPObjectLifeTime class via a javascript function. -class NPObjectLifetimeTestInstance2 : public PluginTest { - public: - // Constructor. - NPObjectLifetimeTestInstance2(NPP id, NPNetscapeFuncs *host_functions); - ~NPObjectLifetimeTestInstance2() override; - - // NPAPI SetWindow handler. - NPError SetWindow(NPWindow* pNPWindow) override; - - protected: - static NPObject* plugin_instance_object_; - friend class NPObjectLifetimeTest; - - DISALLOW_IMPLICIT_CONSTRUCTORS(NPObjectLifetimeTestInstance2); -}; - -// The NPObjectLifeTime class tests the case where a plugin instance is -// destroyed in NPN_Evaluate -class NPObjectDeletePluginInNPN_Evaluate : public PluginTest { - public: - // Constructor. - NPObjectDeletePluginInNPN_Evaluate(NPP id, NPNetscapeFuncs *host_functions); - ~NPObjectDeletePluginInNPN_Evaluate() override; - - // NPAPI SetWindow handler. - NPError SetWindow(NPWindow* pNPWindow) override; - - protected: - NPObject* plugin_instance_object_; -#if defined(OS_WIN) - static void CALLBACK TimerProc(HWND window, UINT message, UINT_PTR timer_id, - DWORD elapsed_milli_seconds); - UINT_PTR timer_id_; -#endif - - private: - static NPObjectDeletePluginInNPN_Evaluate* g_npn_evaluate_test_instance_; - - DISALLOW_IMPLICIT_CONSTRUCTORS(NPObjectDeletePluginInNPN_Evaluate); -}; - -} // namespace NPAPIClient - -#endif // CONTENT_TEST_PLUGIN_PLUGIN_NPOBJECT_LIFETIME_TEST_H_ diff --git a/content/test/plugin/plugin_npobject_proxy_test.cc b/content/test/plugin/plugin_npobject_proxy_test.cc deleted file mode 100644 index 3993cbe2b34478..00000000000000 --- a/content/test/plugin/plugin_npobject_proxy_test.cc +++ /dev/null @@ -1,49 +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 "content/test/plugin/plugin_npobject_proxy_test.h" - -#include "base/basictypes.h" -#include "base/compiler_specific.h" - -namespace NPAPIClient { - -NPObjectProxyTest::NPObjectProxyTest(NPP id, NPNetscapeFuncs *host_functions) - : PluginTest(id, host_functions) { -} - -NPError NPObjectProxyTest::SetWindow(NPWindow* pNPWindow) { -#if !defined(OS_MACOSX) - if (pNPWindow->window == NULL) - return NPERR_NO_ERROR; -#endif - - NPIdentifier document_id = HostFunctions()->getstringidentifier("document"); - NPIdentifier create_text_node_id = HostFunctions()->getstringidentifier("createTextNode"); - NPIdentifier append_child_id = HostFunctions()->getstringidentifier("appendChild"); - - NPVariant docv; - NPObject *window_obj = NULL; - HostFunctions()->getvalue(id(), NPNVWindowNPObject, &window_obj); - - HostFunctions()->getproperty(id(), window_obj, document_id, &docv); - NPObject *doc = NPVARIANT_TO_OBJECT(docv); - - NPVariant strv; - MSVC_SUPPRESS_WARNING(4267); - STRINGZ_TO_NPVARIANT("div", strv); - - NPVariant textv; - HostFunctions()->invoke(id(), doc, create_text_node_id, &strv, 1, &textv); - - NPVariant v; - HostFunctions()->invoke(id(), doc, append_child_id, &textv, 1, &v); - - // If this test failed, then we'd have crashed by now. - SignalTestCompleted(); - - return NPERR_NO_ERROR; -} - -} // namespace NPAPIClient diff --git a/content/test/plugin/plugin_npobject_proxy_test.h b/content/test/plugin/plugin_npobject_proxy_test.h deleted file mode 100644 index 5ffc832dce2a64..00000000000000 --- a/content/test/plugin/plugin_npobject_proxy_test.h +++ /dev/null @@ -1,28 +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. - -#ifndef CONTENT_TEST_PLUGIN_PLUGIN_NPOBJECT_PROXY_TEST_H_ -#define CONTENT_TEST_PLUGIN_PLUGIN_NPOBJECT_PROXY_TEST_H_ - -#include "base/compiler_specific.h" -#include "content/test/plugin/plugin_test.h" - -namespace NPAPIClient { - -// The NPObjectProxyTest tests that when we proxy an NPObject that is itself -// a proxy, we don't create a new proxy but instead just use the original -// pointer. - -class NPObjectProxyTest : public PluginTest { - public: - // Constructor. - NPObjectProxyTest(NPP id, NPNetscapeFuncs *host_functions); - - // NPAPI SetWindow handler. - NPError SetWindow(NPWindow* pNPWindow) override; -}; - -} // namespace NPAPIClient - -#endif // CONTENT_TEST_PLUGIN_PLUGIN_NPOBJECT_PROXY_TEST_H_ diff --git a/content/test/plugin/plugin_private_test.cc b/content/test/plugin/plugin_private_test.cc deleted file mode 100644 index 22b1a3352e0644..00000000000000 --- a/content/test/plugin/plugin_private_test.cc +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) 2010 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 "content/test/plugin/plugin_private_test.h" - -#include "base/basictypes.h" -#include "base/strings/string_util.h" -#include "content/test/plugin/plugin_client.h" - -namespace NPAPIClient { - -PrivateTest::PrivateTest(NPP id, NPNetscapeFuncs *host_functions) - : PluginTest(id, host_functions) { -} - -NPError PrivateTest::New(uint16 mode, int16 argc, - const char* argn[], const char* argv[], - NPSavedData* saved) { - PluginTest::New(mode, argc, argn, argv, saved); - - NPBool private_mode = 0; - NPNetscapeFuncs* browser = NPAPIClient::PluginClient::HostFunctions(); - NPError result = browser->getvalue( - id(), NPNVprivateModeBool, &private_mode); - if (result != NPERR_NO_ERROR) { - SetError("Failed to read NPNVprivateModeBool value."); - } else { - NPIdentifier location = HostFunctions()->getstringidentifier("location"); - NPIdentifier href = HostFunctions()->getstringidentifier("href"); - - NPObject *window_obj = NULL; - HostFunctions()->getvalue(id(), NPNVWindowNPObject, &window_obj); - - NPVariant location_var; - HostFunctions()->getproperty(id(), window_obj, location, &location_var); - - NPVariant href_var; - HostFunctions()->getproperty(id(), NPVARIANT_TO_OBJECT(location_var), href, - &href_var); - std::string href_str(href_var.value.stringValue.UTF8Characters, - href_var.value.stringValue.UTF8Length); - bool private_expected = href_str.find("?private") != href_str.npos; - if (private_mode != static_cast(private_expected)) - SetError("NPNVprivateModeBool returned incorrect value."); - - HostFunctions()->releasevariantvalue(&href_var); - HostFunctions()->releasevariantvalue(&location_var); - HostFunctions()->releaseobject(window_obj); - } - - SignalTestCompleted(); - - return NPERR_NO_ERROR; -} - -} // namespace NPAPIClient diff --git a/content/test/plugin/plugin_private_test.h b/content/test/plugin/plugin_private_test.h deleted file mode 100644 index c04b5e16cadd9d..00000000000000 --- a/content/test/plugin/plugin_private_test.h +++ /dev/null @@ -1,29 +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. - -#ifndef CONTENT_TEST_PLUGIN_PLUGIN_PRIVATE_TEST_H_ -#define CONTENT_TEST_PLUGIN_PLUGIN_PRIVATE_TEST_H_ - -#include "base/compiler_specific.h" -#include "content/test/plugin/plugin_test.h" - -namespace NPAPIClient { - -// The PluginPrivateTest tests that a plugin can query if the browser is in -// private browsing mode. -class PrivateTest : public PluginTest { - public: - PrivateTest(NPP id, NPNetscapeFuncs *host_functions); - - // Initialize this PluginTest based on the arguments from NPP_New. - NPError New(uint16 mode, - int16 argc, - const char* argn[], - const char* argv[], - NPSavedData* saved) override; -}; - -} // namespace NPAPIClient - -#endif // CONTENT_TEST_PLUGIN_PLUGIN_PRIVATE_TEST_H_ diff --git a/content/test/plugin/plugin_request_read_test.cc b/content/test/plugin/plugin_request_read_test.cc deleted file mode 100644 index 8d04a5e62ef84d..00000000000000 --- a/content/test/plugin/plugin_request_read_test.cc +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright 2013 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 "content/test/plugin/plugin_request_read_test.h" - -#include "base/basictypes.h" - -namespace NPAPIClient { - -PluginRequestReadTest::PluginRequestReadTest(NPP id, - NPNetscapeFuncs* host_functions) - : PluginTest(id, host_functions), - tests_started_(false), - read_requested_(false) { -} - -PluginRequestReadTest::~PluginRequestReadTest() { -} - -NPError PluginRequestReadTest::New(uint16 mode, int16 argc, const char* argn[], - const char* argv[], NPSavedData* saved) { - url_to_request_ = GetArgValue("url_to_request", argc, argn, argv); - return PluginTest::New(mode, argc, argn, argv, saved); -} - -NPError PluginRequestReadTest::SetWindow(NPWindow* window) { - if (!tests_started_) { - tests_started_ = true; - NPError result = HostFunctions()->geturl(id(), - url_to_request_.c_str(), - NULL); - if (result != NPERR_NO_ERROR) - SetError("Failed request anURL."); - } - return PluginTest::SetWindow(window); -} - -NPError PluginRequestReadTest::NewStream(NPMIMEType type, NPStream* stream, - NPBool seekable, uint16* stream_type) { - *stream_type = NP_SEEK; - if (!read_requested_) { - requested_ranges_.resize(1); - requested_ranges_[0].offset = 4; - requested_ranges_[0].length = 6; - requested_ranges_[0].next = NULL; - NPError result = HostFunctions()->requestread(stream, - &requested_ranges_[0]); - if (result != NPERR_NO_ERROR) - SetError("Failed request read from stream."); - read_requested_ = true; - } - return PluginTest::NewStream(type, stream, seekable, stream_type); -} - -NPError PluginRequestReadTest::DestroyStream(NPStream *stream, NPError reason) { - if (!requested_ranges_.empty()) - SetError("Some requested ranges are not received!"); - SignalTestCompleted(); - return PluginTest::DestroyStream(stream, reason); -} - -int32 PluginRequestReadTest::WriteReady(NPStream* stream) { - int32 result = 0; - for (size_t i = 0; i < requested_ranges_.size(); ++i) - result += requested_ranges_[i].length; - return result; -} - -int32 PluginRequestReadTest::Write(NPStream* stream, int32 offset, int32 len, - void* buffer) { - std::vector::iterator it; - // Remove received range (or sub-range) from requested_ranges_, and - // verify that we have received proper data. - - for (it = requested_ranges_.begin(); it != requested_ranges_.end(); ++it) { - if (it->offset == offset) - break; - } - if (it == requested_ranges_.end()) { - // It is Ok for browser to write some data from start of the stream before - // we've issued any read requests. - return len; - } - // Shrink range to mark area we have just received. - it->offset += len; - if (static_cast(it->length) < len) - it->length = 0; - else - it->length -= len; - if (it->length == 0) - requested_ranges_.erase(it); - - // Verify the data we got is right. We expect a string like "01234...". - const char* data = static_cast(buffer); - for (int32 i = 0; i < len; ++i) { - char expected = '0' + static_cast(offset + i); - if (data[i] != expected) { - SetError("Content mismatch between data and source!"); - break; - } - } - if (requested_ranges_.empty()) - SignalTestCompleted(); - - return len; -} - -} // namespace NPAPIClient - diff --git a/content/test/plugin/plugin_request_read_test.h b/content/test/plugin/plugin_request_read_test.h deleted file mode 100644 index cbb0f904dce3e6..00000000000000 --- a/content/test/plugin/plugin_request_read_test.h +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2013 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. - -#ifndef CONTENT_TEST_PLUGIN_PLUGIN_REQUEST_READ_TEST_H_ -#define CONTENT_TEST_PLUGIN_PLUGIN_REQUEST_READ_TEST_H_ - -#include -#include - -#include "base/compiler_specific.h" -#include "content/test/plugin/plugin_test.h" - -namespace NPAPIClient { - -// Tests whether the browser correctly handles single range requests from NPAPI -// plugins. -class PluginRequestReadTest : public PluginTest { - public: - PluginRequestReadTest(NPP id, NPNetscapeFuncs* host_functions); - ~PluginRequestReadTest() override; - - // - // NPAPI Functions - // - NPError New(uint16 mode, - int16 argc, - const char* argn[], - const char* argv[], - NPSavedData* saved) override; - NPError SetWindow(NPWindow* window) override; - NPError NewStream(NPMIMEType type, - NPStream* stream, - NPBool seekable, - uint16* stream_type) override; - NPError DestroyStream(NPStream* stream, NPError reason) override; - int32 WriteReady(NPStream* stream) override; - int32 Write(NPStream* stream, int32 offset, int32 len, void* buffer) override; - - private: - // Tracks ranges, which we requested, but for which we did not get response. - std::vector requested_ranges_; - std::string url_to_request_; - bool tests_started_; - bool read_requested_; -}; - -} // namespace NPAPIClient - -#endif // CONTENT_TEST_PLUGIN_PLUGIN_REQUEST_READ_TEST_H_ - diff --git a/content/test/plugin/plugin_schedule_timer_test.cc b/content/test/plugin/plugin_schedule_timer_test.cc deleted file mode 100644 index 950745d0733b47..00000000000000 --- a/content/test/plugin/plugin_schedule_timer_test.cc +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright (c) 2010 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 "content/test/plugin/plugin_schedule_timer_test.h" - -#include "base/logging.h" -#include "content/test/plugin/plugin_client.h" - -using base::Time; - -namespace NPAPIClient { - -// The times below are accurate but they are not tested against because it -// might make the test flakey. -ScheduleTimerTest::Event - ScheduleTimerTest::schedule_[ScheduleTimerTest::kNumEvents] = { - { 0, -1, 0, 100, false, -1 }, // schedule 0 100ms no-repeat - { 100, 0, 0, 200, false, -1 }, // schedule 0 200ms no-repeat - { 300, 0, 0, 100, true, -1 }, // schedule 0 100ms repeat - { 400, 0, 1, 50, true, -1 }, // schedule 1 50ms repeat - { 450, 1, -1, 0, true, -1 }, // receive 1 repeating - { 500, 0, -1, 0, true, -1 }, // receive 0 repeating - { 500, 1, -1, 0, true, -1 }, // receive 1 repeating - { 550, 1, -1, 0, true, -1 }, // receive 1 repeating - { 600, 0, -1, 0, true, 0 }, // receive 0 repeating and unschedule - { 600, 1, 2, 400, true, 1 }, // receive 1 repeating and unschedule - { 1000, 2, -1, 0, true, 2 }, // receive final and unschedule -}; - -ScheduleTimerTest::ScheduleTimerTest( - NPP id, NPNetscapeFuncs *host_functions) - : PluginTest(id, host_functions), - num_received_events_(0) { - for (int i = 0; i < kNumTimers; ++i) { - timer_ids_[i] = 0; - } - for (int i = 0; i < kNumEvents; ++i) { - received_events_[i] = false; - } -} - -NPError ScheduleTimerTest::New( - uint16 mode, int16 argc, const char* argn[], const char* argv[], - NPSavedData* saved) { - NPError error = PluginTest::New(mode, argc, argn, argv, saved); - if (error != NPERR_NO_ERROR) - return error; - - start_time_ = Time::Now(); - HandleEventIndex(0); - - return NPERR_NO_ERROR; -} - -void ScheduleTimerTest::OnTimer(uint32 timer_id) { - Time current_time = Time::Now(); - int relative_time = static_cast( - (current_time - start_time_).InMilliseconds()); - - // See if there is a matching unreceived event. - int event_index = FindUnreceivedEvent(relative_time, timer_id); - if (event_index < 0) { - SetError("Received unexpected timer event"); - SignalTestCompleted(); - return; - } - - HandleEventIndex(event_index); - - // Finish test if all events have happened. - if (num_received_events_ == kNumEvents) - SignalTestCompleted(); -} - -int ScheduleTimerTest::FindUnreceivedEvent(int time, uint32 timer_id) { - for (int i = 0; i < kNumEvents; ++i) { - const Event& event = schedule_[i]; - if (!received_events_[i] && - timer_ids_[event.received_index] == timer_id) { - return i; - } - } - return -1; -} - -namespace { -void OnTimerHelper(NPP id, uint32 timer_id) { - ScheduleTimerTest* plugin_object = - static_cast(id->pdata); - if (plugin_object) { - plugin_object->OnTimer(timer_id); - } -} -} - -void ScheduleTimerTest::HandleEventIndex(int event_index) { - const Event& event = schedule_[event_index]; - - // Mark event as received. - DCHECK(!received_events_[event_index]); - received_events_[event_index] = true; - ++num_received_events_; - - // Unschedule timer if present. - if (event.unscheduled_index >= 0) { - HostFunctions()->unscheduletimer( - id(), timer_ids_[event.unscheduled_index]); - } - - // Schedule timer if present. - if (event.scheduled_index >= 0) { - timer_ids_[event.scheduled_index] = HostFunctions()->scheduletimer( - id(), event.scheduled_interval, event.schedule_repeated, OnTimerHelper); - } -} - -} // namespace NPAPIClient diff --git a/content/test/plugin/plugin_schedule_timer_test.h b/content/test/plugin/plugin_schedule_timer_test.h deleted file mode 100644 index bcf1b015726de2..00000000000000 --- a/content/test/plugin/plugin_schedule_timer_test.h +++ /dev/null @@ -1,68 +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. - -#ifndef CONTENT_TEST_PLUGIN_PLUGIN_SCHEDULE_TIMER_TEST_H_ -#define CONTENT_TEST_PLUGIN_PLUGIN_SCHEDULE_TIMER_TEST_H_ - -#include "base/compiler_specific.h" -#include "base/time/time.h" -#include "content/test/plugin/plugin_test.h" - -namespace NPAPIClient { - -// This class tests scheduling and unscheduling of timers using -// NPN_ScheduleTimer and NPN_UnscheduleTimer. -class ScheduleTimerTest : public PluginTest { - public: - ScheduleTimerTest(NPP id, NPNetscapeFuncs *host_functions); - - NPError New(uint16 mode, - int16 argc, - const char* argn[], - const char* argv[], - NPSavedData* saved) override; - - void OnTimer(uint32 timer_id); - - private: - // Table mapping timer index (as used in event schedule) to timer id. - static const int kNumTimers = 3; - uint32 timer_ids_[kNumTimers]; - - // Schedule of events for test. - static const int kNumEvents = 11; - struct Event { - int time; - - // The index of the timer that triggered the event or -1 for the first - // event. - int received_index; - - // The index of the timer to schedule on this event or -1. - int scheduled_index; - - // Info about the timer to be scheduled (if any). - uint32 scheduled_interval; - bool schedule_repeated; - - // The index of the timer to unschedule on this event or -1. - int unscheduled_index; - }; - static Event schedule_[kNumEvents]; - int num_received_events_; - - // Set of events that have been received (by index). - bool received_events_[kNumEvents]; - - // Time of initial event. - base::Time start_time_; - - // Returns index of matching unreceived event or -1 if not found. - int FindUnreceivedEvent(int time, uint32 timer_id); - void HandleEventIndex(int event_index); -}; - -} // namespace NPAPIClient - -#endif // CONTENT_TEST_PLUGIN_PLUGIN_SCHEDULE_TIMER_TEST_H_ diff --git a/content/test/plugin/plugin_setup_test.cc b/content/test/plugin/plugin_setup_test.cc deleted file mode 100644 index 02f85f1e752fbb..00000000000000 --- a/content/test/plugin/plugin_setup_test.cc +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) 2010 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 "base/basictypes.h" -#include "base/strings/string_util.h" - -#include "content/test/plugin/plugin_setup_test.h" - -namespace NPAPIClient { - -PluginSetupTest::PluginSetupTest(NPP id, NPNetscapeFuncs *host_functions) - : PluginTest(id, host_functions) { -} - -NPError PluginSetupTest::SetWindow(NPWindow* pNPWindow) { - this->SignalTestCompleted(); - - return NPERR_NO_ERROR; -} - -} // namespace NPAPIClient diff --git a/content/test/plugin/plugin_setup_test.h b/content/test/plugin/plugin_setup_test.h deleted file mode 100644 index 1708ce1e3eb628..00000000000000 --- a/content/test/plugin/plugin_setup_test.h +++ /dev/null @@ -1,24 +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. - -#ifndef CONTENT_TEST_PLUGIN_PLUGIN_SETUP_TEST_H_ -#define CONTENT_TEST_PLUGIN_PLUGIN_SETUP_TEST_H_ - -#include "content/test/plugin/plugin_test.h" - -namespace NPAPIClient { - -// A very simple test that just sets up a new plugin. -class PluginSetupTest : public PluginTest { - public: - // Constructor. - PluginSetupTest(NPP id, NPNetscapeFuncs *host_functions); - - // NPAPI SetWindow handler. - NPError SetWindow(NPWindow* pNPWindow) override; -}; - -} // namespace NPAPIClient - -#endif // CONTENT_TEST_PLUGIN_PLUGIN_SETUP_TEST_H_ diff --git a/content/test/plugin/plugin_test.cc b/content/test/plugin/plugin_test.cc deleted file mode 100644 index 84ad5ab4f789d7..00000000000000 --- a/content/test/plugin/plugin_test.cc +++ /dev/null @@ -1,199 +0,0 @@ -// Copyright (c) 2010 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 "content/test/plugin/plugin_test.h" - -#include "base/strings/string_number_conversions.h" -#include "base/strings/string_util.h" -#include "content/test/plugin/npapi_constants.h" - -namespace NPAPIClient { - -PluginTest::PluginTest(NPP id, NPNetscapeFuncs *host_functions) { - id_ = id; - id_->pdata = this; - host_functions_ = host_functions; - test_completed_ = false; -} - -PluginTest::~PluginTest() {} - -bool PluginTest::IsWindowless() const { return false; } - -NPError PluginTest::New(uint16 mode, int16 argc, const char* argn[], - const char* argv[], NPSavedData* saved) { - test_name_ = this->GetArgValue("name", argc, argn, argv); - const char* id = this->GetArgValue("id", argc, argn, argv); - if (id) // NULL for NP_FULL - test_id_ = id; - return NPERR_NO_ERROR; -} - -NPError PluginTest::Destroy() { - return NPERR_NO_ERROR; -} - -NPError PluginTest::SetWindow(NPWindow* pNPWindow) { - return NPERR_NO_ERROR; -} - -// It's a shame I have to implement URLEncode. But, using webkit's -// or using chrome's means a ball of string of dlls and dependencies that -// is very very long. After spending far too much time on it, -// I'll just encode it myself. Too bad Microsoft doesn't implement -// this in a reusable way either. Both webkit and chrome will -// end up using libicu, which is a string of dependencies we don't -// want. - -inline unsigned char toHex(const unsigned char x) { - return x > 9 ? (x + 'A' - 10) : (x + '0'); -} - -std::string URLEncode(const std::string &sIn) { - std::string sOut; - - const size_t length = sIn.length(); - for (size_t idx = 0; idx < length;) { - const char ch = sIn.at(idx); - if (isalnum(ch)) { - sOut.append(1, ch); - } else if (isspace(ch) && ((ch != '\n') && (ch != '\r'))) { - sOut.append(1, '+'); - } else { - sOut.append(1, '%'); - sOut.append(1, toHex(ch>>4)); - sOut.append(1, toHex(ch%16)); - } - idx++; - } - return sOut; -} - -void PluginTest::SignalTestCompleted() { - NPObject *window_obj = NULL; - host_functions_->getvalue(id_, NPNVWindowNPObject, &window_obj); - if (!window_obj) - return; - - test_completed_ = true; - // To signal test completion, we expect a couple of - // javascript functions to be defined in the webpage - // which hosts this plugin: - // onSuccess(test_name, test_id) - // onFailure(test_name, test_id, error_message) - std::string script("javascript:"); - if (Succeeded()) { - script.append("onSuccess(\""); - script.append(test_name_); - script.append("\",\""); - script.append(test_id_); - script.append("\");"); - } else { - script.append("onFailure(\""); - script.append(test_name_); - script.append("\",\""); - script.append(test_id_); - script.append("\",\""); - script.append(test_status_); - script.append("\");"); - } - - NPString script_string; - script_string.UTF8Characters = script.c_str(); - script_string.UTF8Length = static_cast(script.length()); - - NPVariant result_var; - host_functions_->evaluate(id_, window_obj, &script_string, &result_var); -} - -const char *PluginTest::GetArgValue(const char *name, const int16 argc, - const char *argn[], const char *argv[]) { - for (int idx = 0; idx < argc; idx++) - if (base::strcasecmp(argn[idx], name) == 0) - return argv[idx]; - return NULL; -} - -void PluginTest::SetError(const std::string &msg) { - test_status_.append(msg); -} - -void PluginTest::ExpectStringLowerCaseEqual(const std::string &val1, - const std::string &val2) { - if (!base::LowerCaseEqualsASCII(val1, val2.c_str())) { - std::string err; - err = "Expected Equal for '"; - err.append(val1); - err.append("' and '"); - err.append(val2); - err.append("'"); - SetError(err); - } -} - -void PluginTest::ExpectAsciiStringNotEqual(const char *val1, const char *val2) { - if (val1 == val2) { - std::string err; - err = "Expected Not Equal for '"; - err.append(val1); - err.append("' and '"); - err.append(val2); - err.append("'"); - SetError(err); - } -} - -void PluginTest::ExpectIntegerEqual(int val1, int val2) { - if (val1 != val2) { - std::string err; - err = "Expected Equal for '"; - err.append(base::IntToString(val1)); - err.append("' and '"); - err.append(base::IntToString(val2)); - err.append("'"); - SetError(err); - } -} - -NPError PluginTest::NewStream(NPMIMEType type, NPStream* stream, - NPBool seekable, uint16* stype) { - // There is no default action here. - return NPERR_NO_ERROR; -} - -int32 PluginTest::WriteReady(NPStream *stream) { - // Take data in small chunks - return 4096; -} - -int32 PluginTest::Write(NPStream *stream, int32 offset, int32 len, - void *buffer) { - // Pretend that we took all the data. - return len; -} - -NPError PluginTest::DestroyStream(NPStream *stream, NPError reason) { - // There is no default action. - return NPERR_NO_ERROR; -} - -void PluginTest::StreamAsFile(NPStream* stream, const char* fname) { - // There is no default action. -} - -void PluginTest::URLNotify(const char* url, NPReason reason, void* data) { - // There is no default action -} - -int16 PluginTest::HandleEvent(void* event) { - // There is no default action - return 0; -} - -void PluginTest::URLRedirectNotify(const char* url, int32_t status, - void* notify_data) { - // There is no default action -} - -} // namespace NPAPIClient diff --git a/content/test/plugin/plugin_test.h b/content/test/plugin/plugin_test.h deleted file mode 100644 index e2f5124aed8734..00000000000000 --- a/content/test/plugin/plugin_test.h +++ /dev/null @@ -1,104 +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. - -#ifndef CONTENT_TEST_PLUGIN_PLUGIN_TEST_H_ -#define CONTENT_TEST_PLUGIN_PLUGIN_TEST_H_ - -#include - -#include "third_party/npapi/bindings/npapi.h" -#include "third_party/npapi/bindings/nphostapi.h" - -namespace NPAPIClient { - -// A PluginTest represents an instance of the plugin, which in -// our case is a test case. -class PluginTest { - public: - // Constructor. - PluginTest(NPP id, NPNetscapeFuncs *host_functions); - - // Destructor - virtual ~PluginTest(); - - // Returns true if the test runs in windowless plugin mode. - virtual bool IsWindowless() const; - - // - // NPAPI Functions - // - virtual NPError New(uint16 mode, int16 argc, const char* argn[], - const char* argv[], NPSavedData* saved); - virtual NPError Destroy(); - virtual NPError SetWindow(NPWindow* pNPWindow); - virtual NPError NewStream(NPMIMEType type, NPStream* stream, - NPBool seekable, uint16* stype); - virtual int32 WriteReady(NPStream *stream); - virtual int32 Write(NPStream *stream, int32 offset, int32 len, - void *buffer); - virtual NPError DestroyStream(NPStream *stream, NPError reason); - virtual void StreamAsFile(NPStream* stream, const char* fname); - virtual void URLNotify(const char* url, NPReason reason, void* data); - virtual int16 HandleEvent(void* event); - virtual void URLRedirectNotify(const char* url, int32_t status, - void* notify_data); - - // Returns true if the test has not had any errors. - bool Succeeded() { return test_status_.length() == 0; } - - // Sets an error for the test case. Appends the msg to the - // error that will be returned from the test. - void SetError(const std::string &msg); - - // Expect two string values are equal, and if not, logs an - // appropriate error about it. - void ExpectStringLowerCaseEqual(const std::string &val1, - const std::string &val2); - - // Expect two values to not be equal, and if they are - // logs an appropriate error about it. - void ExpectAsciiStringNotEqual(const char *val1, const char *val2); - - // Expect two integer values are equal, and if not, logs an - // appropriate error about it. - void ExpectIntegerEqual(int val1, int val2); - - // Signals to the Test that invoked us that the test is - // completed. This is done by forcing the plugin to - // set a cookie in the browser window, which the test program - // is waiting for. Note - because this is done by - // using javascript, the browser must have the frame - // setup before the plugin calls this function. So plugin - // tests MUST NOT call this function prior to having - // received the SetWindow() callback from the browser. - void SignalTestCompleted(); - - protected: - // Helper function to lookup names in the input array. - // If the name is found, returns the value, otherwise - // returns NULL. - const char *GetArgValue(const char *name, const int16 argc, - const char *argn[], const char *argv[]); - - // Access to the list of functions provided - // by the NPAPI host. - NPNetscapeFuncs *HostFunctions() { return host_functions_; } - - // The NPP Identifier for this plugin instance. - NPP id() { return id_; } - std::string test_id() const { return test_id_; } - std::string test_name() const { return test_name_; } - bool test_completed() const { return test_completed_; } - private: - NPP id_; - NPNetscapeFuncs * host_functions_; - std::string test_name_; - std::string test_id_; - std::string test_status_; - bool test_completed_; -}; - -} // namespace NPAPIClient - -#endif // CONTENT_TEST_PLUGIN_PLUGIN_TEST_H_ diff --git a/content/test/plugin/plugin_test_factory.cc b/content/test/plugin/plugin_test_factory.cc deleted file mode 100644 index 303953499dad50..00000000000000 --- a/content/test/plugin/plugin_test_factory.cc +++ /dev/null @@ -1,118 +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 "content/test/plugin/plugin_test_factory.h" - -#include "content/test/plugin/plugin_arguments_test.h" -#include "content/test/plugin/plugin_delete_plugin_in_stream_test.h" -#include "content/test/plugin/plugin_delete_plugin_in_deallocate_test.h" -#include "content/test/plugin/plugin_get_javascript_url_test.h" -#include "content/test/plugin/plugin_get_javascript_url2_test.h" -#include "content/test/plugin/plugin_geturl_test.h" -#include "content/test/plugin/plugin_javascript_open_popup.h" -#include "content/test/plugin/plugin_new_fails_test.h" -#include "content/test/plugin/plugin_npobject_identity_test.h" -#include "content/test/plugin/plugin_npobject_lifetime_test.h" -#include "content/test/plugin/plugin_npobject_proxy_test.h" -#include "content/test/plugin/plugin_private_test.h" -#include "content/test/plugin/plugin_request_read_test.h" -#include "content/test/plugin/plugin_schedule_timer_test.h" -#include "content/test/plugin/plugin_setup_test.h" -#include "content/test/plugin/plugin_thread_async_call_test.h" -#include "content/test/plugin/plugin_window_size_test.h" -#if defined(OS_WIN) -#include "content/test/plugin/plugin_windowed_test.h" -#endif -#include "content/test/plugin/plugin_windowless_test.h" - -namespace NPAPIClient { - -PluginTest* CreatePluginTest(const std::string& test_name, - NPP instance, - NPNetscapeFuncs* host_functions) { - PluginTest* new_test = NULL; - - if (test_name == "arguments") { - new_test = new PluginArgumentsTest(instance, host_functions); - } else if (test_name == "geturl" || test_name == "geturl_404_response" || - test_name == "geturl_fail_write" || - test_name == "plugin_referrer_test" || - test_name == "geturlredirectnotify" || - test_name == "cookies") { - new_test = new PluginGetURLTest(instance, host_functions); - } else if (test_name == "npobject_identity") { - new_test = new NPObjectIdentityTest(instance, host_functions); - } else if (test_name == "npobject_proxy") { - new_test = new NPObjectProxyTest(instance, host_functions); - } else if (test_name == "invoke_js_function_on_create" || - test_name == "resize_during_paint" -#if defined(OS_WIN) || defined(OS_MACOSX) - // TODO(port): plugin_windowless_test.*. - || test_name == "execute_script_delete_in_paint" || - test_name == "execute_script_delete_in_mouse_up" || - test_name == "delete_frame_test" || - test_name == "multiple_instances_sync_calls" || - test_name == "no_hang_if_init_crashes" || - test_name == "convert_point" -#endif - ) { - new_test = new WindowlessPluginTest(instance, host_functions); - } else if (test_name == "getjavascripturl") { - new_test = new ExecuteGetJavascriptUrlTest(instance, host_functions); - } else if (test_name == "getjavascripturl2") { - new_test = new ExecuteGetJavascriptUrl2Test(instance, host_functions); -#if defined(OS_WIN) - // TODO(port): plugin_window_size_test.*. - } else if (test_name == "checkwindowrect") { - new_test = new PluginWindowSizeTest(instance, host_functions); -#endif - } else if (test_name == "self_delete_plugin_stream") { - new_test = new DeletePluginInStreamTest(instance, host_functions); -#if defined(OS_WIN) - // TODO(port): plugin_npobject_lifetime_test.*. - } else if (test_name == "npobject_lifetime_test") { - new_test = new NPObjectLifetimeTest(instance, host_functions); - } else if (test_name == "npobject_lifetime_test_second_instance") { - new_test = new NPObjectLifetimeTestInstance2(instance, host_functions); - } else if (test_name == "new_fails") { - new_test = new NewFailsTest(instance, host_functions); - } else if (test_name == "npobject_delete_plugin_in_evaluate" || - test_name == "npobject_delete_create_plugin_in_evaluate") { - new_test = new NPObjectDeletePluginInNPN_Evaluate(instance, host_functions); -#endif - } else if (test_name == "plugin_javascript_open_popup_with_plugin") { - new_test = new ExecuteJavascriptOpenPopupWithPluginTest( - instance, host_functions); - } else if (test_name == "plugin_popup_with_plugin_target") { - new_test = new ExecuteJavascriptPopupWindowTargetPluginTest( - instance, host_functions); - } else if (test_name == "plugin_thread_async_call") { - new_test = new PluginThreadAsyncCallTest(instance, host_functions); - } else if (test_name == "private") { - new_test = new PrivateTest(instance, host_functions); - } else if (test_name == "schedule_timer") { - new_test = new ScheduleTimerTest(instance, host_functions); -#if defined(OS_WIN) - // TODO(port): plugin_windowed_test.*. - } else if (test_name == "hidden_plugin" || - test_name == "create_instance_in_paint" || - test_name == "alert_in_window_message" || - test_name == "ensure_scripting_works_in_destroy" || - test_name == "set_title_in_paint" || - test_name == "set_title_in_set_window_and_paint") { - new_test = new WindowedPluginTest(instance, host_functions); -#endif - } else if (test_name == "setup") { - // "plugin" is the name for plugin documents. - new_test = new PluginSetupTest(instance, host_functions); - } else if (test_name == "delete_plugin_in_deallocate_test") { - new_test = new DeletePluginInDeallocateTest(instance, host_functions); - } else if (test_name == "plugin_request_read_single_range") { - new_test = new PluginRequestReadTest(instance, host_functions); - } - - return new_test; -} - -} // namespace NPAPIClient diff --git a/content/test/plugin/plugin_test_factory.h b/content/test/plugin/plugin_test_factory.h deleted file mode 100644 index 4cfe9d686c3654..00000000000000 --- a/content/test/plugin/plugin_test_factory.h +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) 2010 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. - -#ifndef CONTENT_TEST_PLUGIN_PLUGIN_TEST_FACTORY_H_ -#define CONTENT_TEST_PLUGIN_PLUGIN_TEST_FACTORY_H_ - -#include - -#include "third_party/npapi/bindings/nphostapi.h" - -namespace NPAPIClient { - -class PluginTest; - -extern PluginTest* CreatePluginTest(const std::string& test_name, - NPP instance, - NPNetscapeFuncs* host_functions); - -} // namespace NPAPIClient - -#endif // CONTENT_TEST_PLUGIN_PLUGIN_TEST_FACTORY_H_ diff --git a/content/test/plugin/plugin_thread_async_call_test.cc b/content/test/plugin/plugin_thread_async_call_test.cc deleted file mode 100644 index 4afd00425f061b..00000000000000 --- a/content/test/plugin/plugin_thread_async_call_test.cc +++ /dev/null @@ -1,117 +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. - -#define UNIT_TEST // To get the ShadowingAtExitManager. -#include "base/at_exit.h" - -#include "content/test/plugin/plugin_thread_async_call_test.h" - -#include "base/bind.h" -#include "base/message_loop/message_loop.h" -#include "base/strings/string_util.h" -#include "base/threading/thread.h" -#include "content/test/plugin/plugin_client.h" - -namespace NPAPIClient { - -namespace { - -// There are two plugin instances in this test. The long lived instance is used -// for reporting errors and signalling test completion. The short lived one is -// used to verify that async callbacks are not invoked after NPP_Destroy. -PluginThreadAsyncCallTest* g_short_lived_instance; -PluginThreadAsyncCallTest* g_long_lived_instance; - -void OnCallSucceededHelper(void* data) { - static_cast(data)->OnCallSucceeded(); -} - -void OnCallFailed(void* data) { - g_long_lived_instance->SetError("Async callback invoked after NPP_Destroy"); -} - -void OnCallCompletedHelper(void* data) { - static_cast(data)->OnCallCompleted(); -} -} - -PluginThreadAsyncCallTest::PluginThreadAsyncCallTest( - NPP id, NPNetscapeFuncs *host_functions) - : PluginTest(id, host_functions), at_exit_manager_(NULL) { -} - -PluginThreadAsyncCallTest::~PluginThreadAsyncCallTest() { - delete at_exit_manager_; -} - -NPError PluginThreadAsyncCallTest::New( - uint16 mode, int16 argc, const char* argn[], const char* argv[], - NPSavedData* saved) { - NPError error = PluginTest::New(mode, argc, argn, argv, saved); - if (error != NPERR_NO_ERROR) - return error; - - // Determine whether this is the short lived instance. - for (int i = 0; i < argc; ++i) { - if (base::strcasecmp(argn[i], "short_lived") == 0) { - if (base::strcasecmp(argv[i], "true") == 0) { - g_short_lived_instance = this; - } else { - g_long_lived_instance = this; - } - } - } - - // Schedule an async call that will succeed. Make sure to call that API from - // a different thread to fully test it. - if (this == g_short_lived_instance) { - // This is slightly complicated thanks to the Linux shared library build, - // which shares more compilation units between the NPAPI plugin and - // the base code. - at_exit_manager_ = new base::ShadowingAtExitManager(); - base::Thread random_thread("random_thread"); - random_thread.Start(); - random_thread.message_loop()->PostTask( - FROM_HERE, base::Bind(&PluginThreadAsyncCallTest::AsyncCall, - base::Unretained(this))); - } - - return NPERR_NO_ERROR; -} - -void PluginThreadAsyncCallTest::AsyncCall() { - HostFunctions()->pluginthreadasynccall(id(), OnCallSucceededHelper, this); -} - -void PluginThreadAsyncCallTest::OnCallSucceeded() { - // Delete the short lived instance. - NPIdentifier delete_id = HostFunctions()->getstringidentifier( - "deleteShortLivedInstance"); - - NPObject *window_obj = NULL; - HostFunctions()->getvalue(id(), NPNVWindowNPObject, &window_obj); - - NPVariant result; - HostFunctions()->invoke(id(), window_obj, delete_id, NULL, 0, &result); -} - -NPError PluginThreadAsyncCallTest::Destroy() { - if (this == g_short_lived_instance) { - // Schedule an async call that should not be called. - HostFunctions()->pluginthreadasynccall(id(), OnCallFailed, NULL); - - // Schedule an async call to end the test using the long lived instance. - HostFunctions()->pluginthreadasynccall(g_long_lived_instance->id(), - OnCallCompletedHelper, - g_long_lived_instance); - } - - return NPERR_NO_ERROR; -} - -void PluginThreadAsyncCallTest::OnCallCompleted() { - SignalTestCompleted(); -} - -} // namespace NPAPIClient diff --git a/content/test/plugin/plugin_thread_async_call_test.h b/content/test/plugin/plugin_thread_async_call_test.h deleted file mode 100644 index 06c13f5dfe3ebe..00000000000000 --- a/content/test/plugin/plugin_thread_async_call_test.h +++ /dev/null @@ -1,44 +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. - -#ifndef CONTENT_TEST_PLUGIN_PLUGIN_THREAD_ASYNC_CALL_TEST_H_ -#define CONTENT_TEST_PLUGIN_PLUGIN_THREAD_ASYNC_CALL_TEST_H_ - -#include "content/test/plugin/plugin_test.h" - -namespace base { -class ShadowingAtExitManager; -} - -namespace NPAPIClient { - -// This class tests scheduling and unscheduling of async callbacks using -// NPN_PluginThreadAsyncCall. -class PluginThreadAsyncCallTest : public PluginTest { - public: - PluginThreadAsyncCallTest(NPP id, NPNetscapeFuncs *host_functions); - ~PluginThreadAsyncCallTest() override; - - NPError New(uint16 mode, - int16 argc, - const char* argn[], - const char* argv[], - NPSavedData* saved) override; - - NPError Destroy() override; - - void AsyncCall(); - void OnCallSucceeded(); - void OnCallCompleted(); - - private: - // base::Thread needs one of these. - base::ShadowingAtExitManager* at_exit_manager_; - - DISALLOW_COPY_AND_ASSIGN(PluginThreadAsyncCallTest); -}; - -} // namespace NPAPIClient - -#endif // CONTENT_TEST_PLUGIN_PLUGIN_THREAD_ASYNC_CALL_TEST_H_ diff --git a/content/test/plugin/plugin_window_size_test.cc b/content/test/plugin/plugin_window_size_test.cc deleted file mode 100644 index 06cecf73a2bf24..00000000000000 --- a/content/test/plugin/plugin_window_size_test.cc +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (c) 2010 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 "content/test/plugin/plugin_window_size_test.h" -#include "content/test/plugin/plugin_client.h" - -namespace NPAPIClient { - -PluginWindowSizeTest::PluginWindowSizeTest(NPP id, - NPNetscapeFuncs *host_functions) - : PluginTest(id, host_functions) { -} - -NPError PluginWindowSizeTest::SetWindow(NPWindow* pNPWindow) { - if (pNPWindow->window == NULL) - return NPERR_NO_ERROR; - - HWND window = reinterpret_cast(pNPWindow->window); - if (!::IsWindow(window)) { - SetError("Invalid arguments passed in"); - return NPERR_INVALID_PARAM; - } - - RECT window_rect = {0}; - window_rect.left = pNPWindow->x; - window_rect.top = pNPWindow->y; - window_rect.right = pNPWindow->width; - window_rect.bottom = pNPWindow->height; - - if (!::IsRectEmpty(&window_rect)) { - RECT client_rect = {0}; - ::GetClientRect(window, &client_rect); - if (::IsRectEmpty(&client_rect)) { - SetError("The client rect of the plugin window is empty. Test failed"); - } - - // Bug 6742: ensure that the coordinates passed in are relative to the - // parent HWND. - POINT origin_from_os; - RECT window_rect_from_os; - ::GetWindowRect(window, &window_rect_from_os); - origin_from_os.x = window_rect_from_os.left; - origin_from_os.y = window_rect_from_os.top; - ::ScreenToClient(GetParent(window), &origin_from_os); - if (origin_from_os.x != pNPWindow->x || origin_from_os.y != pNPWindow->y) - SetError("Wrong position passed in to SetWindow! Test failed"); - - SignalTestCompleted(); - } - - return NPERR_NO_ERROR; -} - -} // namespace NPAPIClient diff --git a/content/test/plugin/plugin_window_size_test.h b/content/test/plugin/plugin_window_size_test.h deleted file mode 100644 index d8aaf225ec90f8..00000000000000 --- a/content/test/plugin/plugin_window_size_test.h +++ /dev/null @@ -1,25 +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. - -#ifndef CONTENT_TEST_PLUGIN_PLUGIN_WINDOW_SIZE_TEST_H_ -#define CONTENT_TEST_PLUGIN_PLUGIN_WINDOW_SIZE_TEST_H_ - -#include "base/compiler_specific.h" -#include "content/test/plugin/plugin_test.h" - -namespace NPAPIClient { - -// This class tests whether the plugin window has a non zero rect -// on the second SetWindow call. -class PluginWindowSizeTest : public PluginTest { - public: - // Constructor. - PluginWindowSizeTest(NPP id, NPNetscapeFuncs *host_functions); - // NPAPI SetWindow handler - NPError SetWindow(NPWindow* pNPWindow) override; -}; - -} // namespace NPAPIClient - -#endif // CONTENT_TEST_PLUGIN_PLUGIN_WINDOW_SIZE_TEST_H_ diff --git a/content/test/plugin/plugin_windowed_test.cc b/content/test/plugin/plugin_windowed_test.cc deleted file mode 100644 index 546ad21225c0b8..00000000000000 --- a/content/test/plugin/plugin_windowed_test.cc +++ /dev/null @@ -1,172 +0,0 @@ -// Copyright (c) 2010 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 "content/test/plugin/plugin_windowed_test.h" - -#include "base/logging.h" -#include "content/test/plugin/plugin_client.h" - -namespace NPAPIClient { - -WindowedPluginTest::WindowedPluginTest(NPP id, NPNetscapeFuncs *host_functions) - : PluginTest(id, host_functions), - window_(NULL), done_(false) { -} - -WindowedPluginTest::~WindowedPluginTest() { - if (window_) - DestroyWindow(window_); -} - -NPError WindowedPluginTest::SetWindow(NPWindow* pNPWindow) { - if (pNPWindow->window == NULL) - return NPERR_NO_ERROR; - - if (test_name() == "create_instance_in_paint" && test_id() == "2") { - SignalTestCompleted(); - return NPERR_NO_ERROR; - } - - if (window_) - return NPERR_NO_ERROR; - - HWND parent = reinterpret_cast(pNPWindow->window); - if (!::IsWindow(parent)) { - SetError("Invalid arguments passed in"); - return NPERR_INVALID_PARAM; - } - - if ((test_name() == "create_instance_in_paint" && test_id() == "1") || - test_name() == "alert_in_window_message" || - test_name() == "set_title_in_paint" || - test_name() == "set_title_in_set_window_and_paint") { - static ATOM window_class = 0; - if (!window_class) { - WNDCLASSEX wcex; - wcex.cbSize = sizeof(WNDCLASSEX); - wcex.style = CS_DBLCLKS; - wcex.lpfnWndProc = &NPAPIClient::WindowedPluginTest::WindowProc; - wcex.cbClsExtra = 0; - wcex.cbWndExtra = 0; - wcex.hInstance = GetModuleHandle(NULL); - wcex.hIcon = 0; - wcex.hCursor = 0; - wcex.hbrBackground = reinterpret_cast(COLOR_WINDOW+1); - wcex.lpszMenuName = 0; - wcex.lpszClassName = L"CreateInstanceInPaintTestWindowClass"; - wcex.hIconSm = 0; - window_class = RegisterClassEx(&wcex); - } - - window_ = CreateWindowEx( - WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR, - MAKEINTATOM(window_class), 0, - WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE , - 0, 0, 100, 100, parent, 0, GetModuleHandle(NULL), 0); - DCHECK(window_); - // TODO: this propery leaks. - ::SetProp(window_, L"Plugin_Instance", this); - } - - if (test_name() == "set_title_in_set_window_and_paint") - CallJSFunction(this, "PluginCreated"); - - return NPERR_NO_ERROR; -} - -NPError WindowedPluginTest::Destroy() { - if (test_name() != "ensure_scripting_works_in_destroy") - return NPERR_NO_ERROR; - - // Bug 23706: ensure that scripting works with no asserts. - NPObject *window_obj = NULL; - HostFunctions()->getvalue(id(), NPNVWindowNPObject,&window_obj); - - if (!window_obj) { - SetError("Failed to get NPObject for plugin instance"); - } else { - std::string script = "javascript:GetMagicNumber()"; - NPString script_string; - script_string.UTF8Characters = script.c_str(); - script_string.UTF8Length = - static_cast(script.length()); - - NPVariant result_var; - bool result = HostFunctions()->evaluate( - id(), window_obj, &script_string, &result_var); - if (!result || - result_var.type != NPVariantType_Double || - result_var.value.doubleValue != 42.0) { - SetError("Failed to script during NPP_Destroy"); - } - } - - SignalTestCompleted(); - return NPERR_NO_ERROR; -} - -void WindowedPluginTest::CallJSFunction( - WindowedPluginTest* this_ptr, const char* function) { - NPIdentifier function_id = this_ptr->HostFunctions()->getstringidentifier( - function); - - NPObject *window_obj = NULL; - this_ptr->HostFunctions()->getvalue( - this_ptr->id(), NPNVWindowNPObject, &window_obj); - - NPVariant rv; - this_ptr->HostFunctions()->invoke( - this_ptr->id(), window_obj, function_id, NULL, 0, &rv); -} - -LRESULT CALLBACK WindowedPluginTest::WindowProc( - HWND window, UINT message, WPARAM wparam, LPARAM lparam) { - WindowedPluginTest* this_ptr = - reinterpret_cast - (::GetProp(window, L"Plugin_Instance")); - - if (message == WM_PAINT) { - PAINTSTRUCT ps; - HDC hdc = BeginPaint(window, &ps); - HBRUSH brush = CreateSolidBrush(RGB(255, 0, 0)); - HGDIOBJ orig = SelectObject(hdc, brush); - RECT r; - GetClientRect(window, &r); - Rectangle(hdc, 0, 0, r.right, r.bottom); - SelectObject(hdc, orig); // restore - DeleteObject(brush); - EndPaint(window, &ps); - } - - if (this_ptr && !this_ptr->done_) { - if (this_ptr->test_name() == "create_instance_in_paint" && - message == WM_PAINT) { - this_ptr->done_ = true; - CallJSFunction(this_ptr, "CreateNewInstance"); - } else if (this_ptr->test_name() == "alert_in_window_message" && - message == WM_PAINT) { - this_ptr->done_ = true; - // We call this function twice as we want to display two alerts - // and verify that we don't hang the browser. - CallJSFunction(this_ptr, "CallAlert"); - CallJSFunction(this_ptr, "CallAlert"); - } else if (this_ptr->test_name() == "set_title_in_paint" && - message == WM_PAINT) { - this_ptr->done_ = true; - CallJSFunction(this_ptr, "SetTitle"); - } else if (this_ptr->test_name() == "set_title_in_set_window_and_paint" && - message == WM_PAINT) { - this_ptr->done_ = true; - CallJSFunction(this_ptr, "PluginShown"); - } - - if (this_ptr->done_) { - ::RemoveProp(window, L"Plugin_Instance"); - } - } - - return DefWindowProc(window, message, wparam, lparam); -} - -} // namespace NPAPIClient diff --git a/content/test/plugin/plugin_windowed_test.h b/content/test/plugin/plugin_windowed_test.h deleted file mode 100644 index ca231527e0374a..00000000000000 --- a/content/test/plugin/plugin_windowed_test.h +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) 2010 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. - -#ifndef CONTENT_TEST_PLUGIN_PLUGIN_WINDOWED_TEST_H_ -#define CONTENT_TEST_PLUGIN_PLUGIN_WINDOWED_TEST_H_ - -#include "content/test/plugin/plugin_test.h" - -namespace NPAPIClient { - -// This class contains a list of windowed plugin tests. Please add additional -// tests to this class. -class WindowedPluginTest : public PluginTest { - public: - WindowedPluginTest(NPP id, NPNetscapeFuncs *host_functions); - ~WindowedPluginTest() override; - - private: - static LRESULT CALLBACK WindowProc( - HWND window, UINT message, WPARAM wparam, LPARAM lparam); - static void CallJSFunction(WindowedPluginTest*, const char*); - - NPError SetWindow(NPWindow* pNPWindow) override; - NPError Destroy() override; - - HWND window_; - bool done_; -}; - -} // namespace NPAPIClient - -#endif // CONTENT_TEST_PLUGIN_PLUGIN_WINDOWED_TEST_H_ diff --git a/content/test/plugin/plugin_windowless_test.cc b/content/test/plugin/plugin_windowless_test.cc deleted file mode 100644 index 5d78bef95c29c4..00000000000000 --- a/content/test/plugin/plugin_windowless_test.cc +++ /dev/null @@ -1,315 +0,0 @@ -// Copyright (c) 2012 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. - -#define STRSAFE_NO_DEPRECATE - -#include "content/test/plugin/plugin_windowless_test.h" - -#include "base/strings/string_number_conversions.h" -#include "base/strings/string_util.h" -#include "content/test/plugin/plugin_client.h" - -// NPEvent does not exist on the Mac. -#if defined(OS_MACOSX) -typedef NPCocoaEvent WindowlessPluginTestEvent; -#else -typedef NPEvent WindowlessPluginTestEvent; -#endif - -namespace NPAPIClient { - -namespace { - -// Remember the first plugin instance for tests involving multiple instances. -WindowlessPluginTest* g_other_instance = NULL; - -void OnFinishTest(void* data) { - static_cast(data)->SignalTestCompleted(); -} - -bool IsPaintEvent(WindowlessPluginTestEvent* np_event) { -#if defined(OS_WIN) - return np_event->event == WM_PAINT; -#elif defined(OS_MACOSX) - return np_event->type == NPCocoaEventDrawRect; -#else - NOTIMPLEMENTED(); - return false; -#endif -} - -bool IsMouseUpEvent(WindowlessPluginTestEvent* np_event) { -#if defined(OS_WIN) - return np_event->event == WM_LBUTTONUP; -#elif defined(OS_MACOSX) - return np_event->type == NPCocoaEventMouseUp; -#else - NOTIMPLEMENTED(); - return false; -#endif -} - -#if defined(OS_MACOSX) -bool IsWindowActivationEvent(WindowlessPluginTestEvent* np_event) { - return np_event->type == NPCocoaEventWindowFocusChanged && - np_event->data.focus.hasFocus; -} -#endif - -} // namespace - -WindowlessPluginTest::WindowlessPluginTest(NPP id, - NPNetscapeFuncs *host_functions) - : PluginTest(id, host_functions), - paint_counter_(0) { - if (!g_other_instance) - g_other_instance = this; -} - -bool WindowlessPluginTest::IsWindowless() const { - return true; -} - -NPError WindowlessPluginTest::New(uint16 mode, int16 argc, - const char* argn[], const char* argv[], - NPSavedData* saved) { - NPError error = PluginTest::New(mode, argc, argn, argv, saved); - - if (test_name() == "invoke_js_function_on_create") { - ExecuteScript( - NPAPIClient::PluginClient::HostFunctions(), g_other_instance->id(), - "PluginCreated();", NULL); - } - - return error; -} - -int16 WindowlessPluginTest::HandleEvent(void* event) { - NPNetscapeFuncs* browser = NPAPIClient::PluginClient::HostFunctions(); - - NPBool supports_windowless = 0; - NPError result = browser->getvalue(id(), NPNVSupportsWindowless, - &supports_windowless); - if ((result != NPERR_NO_ERROR) || (!supports_windowless)) { - SetError("Failed to read NPNVSupportsWindowless value"); - SignalTestCompleted(); - return PluginTest::HandleEvent(event); - } - - WindowlessPluginTestEvent* np_event = - reinterpret_cast(event); - if (IsPaintEvent(np_event)) { - paint_counter_++; -#if defined(OS_WIN) - HDC paint_dc = reinterpret_cast(np_event->wParam); - if (paint_dc == NULL) { - SetError("Invalid Window DC passed to HandleEvent for WM_PAINT"); - SignalTestCompleted(); - return NPERR_GENERIC_ERROR; - } - - HRGN clipping_region = CreateRectRgn(0, 0, 0, 0); - if (!GetClipRgn(paint_dc, clipping_region)) { - SetError("No clipping region set in window DC"); - DeleteObject(clipping_region); - SignalTestCompleted(); - return NPERR_GENERIC_ERROR; - } - - DeleteObject(clipping_region); -#endif - - if (test_name() == "execute_script_delete_in_paint") { - ExecuteScriptDeleteInPaint(browser); - } else if (test_name() == "multiple_instances_sync_calls") { - MultipleInstanceSyncCalls(browser); - } else if (test_name() == "resize_during_paint") { - if (paint_counter_ == 1) { - // So that we get another paint later. - browser->invalidaterect(id(), NULL); - } else if (paint_counter_ == 2) { - // Do this in the second paint since that's asynchronous. The first - // paint will always be synchronous (since the renderer process doesn't - // have a cache of the plugin yet). If we try calling NPN_Evaluate while - // WebKit is painting, it will assert since style recalc is happening - // during painting. - ExecuteScriptResizeInPaint(browser); - - // So that we can exit the test after the message loop is unrolled. - browser->pluginthreadasynccall(id(), OnFinishTest, this); - } - } -#if defined(OS_MACOSX) - } else if (IsWindowActivationEvent(np_event) && - test_name() == "convert_point") { - ConvertPoint(browser); -#endif - } else if (IsMouseUpEvent(np_event) && - test_name() == "execute_script_delete_in_mouse_up") { - ExecuteScript(browser, id(), "DeletePluginWithinScript();", NULL); - SignalTestCompleted(); - } else if (IsMouseUpEvent(np_event) && - test_name() == "delete_frame_test") { - ExecuteScript( - browser, id(), - "parent.document.getElementById('frame').outerHTML = ''", NULL); - } - // If this test failed, then we'd have crashed by now. - return PluginTest::HandleEvent(event); -} - -NPError WindowlessPluginTest::ExecuteScript(NPNetscapeFuncs* browser, NPP id, - const std::string& script, NPVariant* result) { - std::string script_url = "javascript:"; - script_url += script; - - size_t script_length = script_url.length(); - if (script_length != static_cast(script_length)) { - return NPERR_GENERIC_ERROR; - } - - NPString script_string = { script_url.c_str(), - static_cast(script_length) }; - NPObject *window_obj = NULL; - browser->getvalue(id, NPNVWindowNPObject, &window_obj); - - NPVariant unused_result; - if (!result) - result = &unused_result; - - return browser->evaluate(id, window_obj, &script_string, result); -} - -void WindowlessPluginTest::ExecuteScriptDeleteInPaint( - NPNetscapeFuncs* browser) { - const NPUTF8* urlString = "javascript:DeletePluginWithinScript()"; - const NPUTF8* targetString = NULL; - browser->geturl(id(), urlString, targetString); - SignalTestCompleted(); -} - -void WindowlessPluginTest::ExecuteScriptResizeInPaint( - NPNetscapeFuncs* browser) { - ExecuteScript(browser, id(), "ResizePluginWithinScript();", NULL); -} - -void WindowlessPluginTest::MultipleInstanceSyncCalls(NPNetscapeFuncs* browser) { - if (this == g_other_instance) - return; - - DCHECK(g_other_instance); - ExecuteScript(browser, g_other_instance->id(), "TestCallback();", NULL); - SignalTestCompleted(); -} - -#if defined(OS_MACOSX) -std::string StringForPoint(int x, int y) { - std::string point_string("("); - point_string.append(base::IntToString(x)); - point_string.append(", "); - point_string.append(base::IntToString(y)); - point_string.append(")"); - return point_string; -} -#endif - -void WindowlessPluginTest::ConvertPoint(NPNetscapeFuncs* browser) { -#if defined(OS_MACOSX) - // First, just sanity-test that round trips work. - NPCoordinateSpace spaces[] = { NPCoordinateSpacePlugin, - NPCoordinateSpaceWindow, - NPCoordinateSpaceFlippedWindow, - NPCoordinateSpaceScreen, - NPCoordinateSpaceFlippedScreen }; - for (unsigned int i = 0; i < arraysize(spaces); ++i) { - for (unsigned int j = 0; j < arraysize(spaces); ++j) { - double x, y, round_trip_x, round_trip_y; - if (!(browser->convertpoint(id(), 0, 0, spaces[i], &x, &y, spaces[j])) || - !(browser->convertpoint(id(), x, y, spaces[j], &round_trip_x, - &round_trip_y, spaces[i]))) { - SetError("Conversion failed"); - SignalTestCompleted(); - return; - } - if (i != j && x == 0 && y == 0) { - SetError("Converting a coordinate should change it"); - SignalTestCompleted(); - return; - } - if (round_trip_x != 0 || round_trip_y != 0) { - SetError("Round-trip conversion should return the original point"); - SignalTestCompleted(); - return; - } - } - } - - // Now, more extensive testing on a single point. - double screen_x, screen_y; - browser->convertpoint(id(), 0, 0, NPCoordinateSpacePlugin, - &screen_x, &screen_y, NPCoordinateSpaceScreen); - double flipped_screen_x, flipped_screen_y; - browser->convertpoint(id(), 0, 0, NPCoordinateSpacePlugin, - &flipped_screen_x, &flipped_screen_y, - NPCoordinateSpaceFlippedScreen); - double window_x, window_y; - browser->convertpoint(id(), 0, 0, NPCoordinateSpacePlugin, - &window_x, &window_y, NPCoordinateSpaceWindow); - double flipped_window_x, flipped_window_y; - browser->convertpoint(id(), 0, 0, NPCoordinateSpacePlugin, - &flipped_window_x, &flipped_window_y, - NPCoordinateSpaceFlippedWindow); - - CGRect main_display_bounds = CGDisplayBounds(CGMainDisplayID()); - - // Check that all the coordinates are right. The constants below are based on - // the window frame set in the UI test and the content offset in the test - // html. Y-coordinates are not checked exactly so that the test is robust - // against toolbar changes, info and bookmark bar visibility, etc. - const int kWindowHeight = 400; - const int kWindowXOrigin = 50; - const int kWindowYOrigin = 50; - const int kPluginXContentOffset = 50; - const int kPluginYContentOffset = 50; - const int kChromeYTolerance = 200; - - std::string error_string; - if (screen_x != flipped_screen_x) - error_string = "Flipping screen coordinates shouldn't change x"; - else if (flipped_screen_y != main_display_bounds.size.height - screen_y) - error_string = "Flipped screen coordinates should be flipped vertically"; - else if (screen_x != kWindowXOrigin + kPluginXContentOffset) - error_string = "Screen x location is wrong"; - else if (flipped_screen_y < kWindowYOrigin + kPluginYContentOffset || - flipped_screen_y > kWindowYOrigin + kPluginYContentOffset + - kChromeYTolerance) - error_string = "Screen y location is wrong"; - else if (window_x != flipped_window_x) - error_string = "Flipping window coordinates shouldn't change x"; - else if (flipped_window_y != kWindowHeight - window_y) - error_string = "Flipped window coordinates should be flipped vertically"; - else if (window_x != kPluginXContentOffset) - error_string = "Window x location is wrong"; - else if (flipped_window_y < kPluginYContentOffset || - flipped_window_y > kPluginYContentOffset + kChromeYTolerance) - error_string = "Window y location is wrong"; - - if (!error_string.empty()) { - error_string.append(" - "); - error_string.append(StringForPoint(screen_x, screen_y)); - error_string.append(" - "); - error_string.append(StringForPoint(flipped_screen_x, flipped_screen_y)); - error_string.append(" - "); - error_string.append(StringForPoint(window_x, window_y)); - error_string.append(" - "); - error_string.append(StringForPoint(flipped_window_x, flipped_window_y)); - SetError(error_string); - } -#else - SetError("Unimplemented"); -#endif - SignalTestCompleted(); -} - -} // namespace NPAPIClient diff --git a/content/test/plugin/plugin_windowless_test.h b/content/test/plugin/plugin_windowless_test.h deleted file mode 100644 index d26d33ed049388..00000000000000 --- a/content/test/plugin/plugin_windowless_test.h +++ /dev/null @@ -1,44 +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. - -#ifndef CONTENT_TEST_PLUGIN_PLUGIN_WINDOWLESS_TEST_H_ -#define CONTENT_TEST_PLUGIN_PLUGIN_WINDOWLESS_TEST_H_ - -#include "base/compiler_specific.h" -#include "content/test/plugin/plugin_test.h" - -namespace NPAPIClient { - -// This class contains a list of windowless plugin tests. Please add additional -// tests to this class. -class WindowlessPluginTest : public PluginTest { - public: - // Constructor. - WindowlessPluginTest(NPP id, NPNetscapeFuncs *host_functions); - - // These tests run in windowless plugin mode. - bool IsWindowless() const override; - - // NPAPI HandleEvent handler - NPError New(uint16 mode, - int16 argc, - const char* argn[], - const char* argv[], - NPSavedData* saved) override; - int16 HandleEvent(void* event) override; - - protected: - NPError ExecuteScript(NPNetscapeFuncs* browser, NPP id, - const std::string& script, NPVariant* result); - void ExecuteScriptDeleteInPaint(NPNetscapeFuncs* browser); - void ExecuteScriptResizeInPaint(NPNetscapeFuncs* browser); - void MultipleInstanceSyncCalls(NPNetscapeFuncs* browser); - void ConvertPoint(NPNetscapeFuncs* browser); - - int paint_counter_; -}; - -} // namespace NPAPIClient - -#endif // CONTENT_TEST_PLUGIN_PLUGIN_WINDOWLESS_TEST_H_ diff --git a/content/test/plugin/resource.h b/content/test/plugin/resource.h deleted file mode 100644 index 422861faa98ad8..00000000000000 --- a/content/test/plugin/resource.h +++ /dev/null @@ -1,15 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by npapi_test.rc -// - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 101 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1001 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif