diff options
-rw-r--r-- | chrome/browser/resources/pdf/pdf.js | 3 | ||||
-rw-r--r-- | chrome/browser/resources/pdf/pdf_extension_test.cc (renamed from chrome/test/data/pdf/pdf_extension_test.cc) | 15 | ||||
-rw-r--r-- | chrome/chrome_tests.gypi | 2 | ||||
-rw-r--r-- | chrome/test/data/pdf/basic_plugin_test.js | 19 | ||||
-rw-r--r-- | chrome/test/data/pdf/viewport_test.js | 8 | ||||
-rw-r--r-- | pdf/out_of_process_instance.cc | 2 |
6 files changed, 32 insertions, 17 deletions
diff --git a/chrome/browser/resources/pdf/pdf.js b/chrome/browser/resources/pdf/pdf.js index e47de3a..60384e5 100644 --- a/chrome/browser/resources/pdf/pdf.js +++ b/chrome/browser/resources/pdf/pdf.js @@ -35,6 +35,8 @@ PDFViewer.MIN_TOOLBAR_OFFSET = 15; * document. */ function PDFViewer() { + this.loaded = false; + // The sizer element is placed behind the plugin element to cause scrollbars // to be displayed in the window. It is sized according to the document size // of the pdf and zoom level. @@ -256,6 +258,7 @@ PDFViewer.prototype = { } } else if (progress == 100) { // Document load complete. + this.loaded = true; var loadEvent = new Event('pdfload'); window.dispatchEvent(loadEvent); this.sendScriptingMessage_({ diff --git a/chrome/test/data/pdf/pdf_extension_test.cc b/chrome/browser/resources/pdf/pdf_extension_test.cc index 574dbc8..73b6b80 100644 --- a/chrome/test/data/pdf/pdf_extension_test.cc +++ b/chrome/browser/resources/pdf/pdf_extension_test.cc @@ -37,7 +37,6 @@ class PDFExtensionTest : public ExtensionApiTest { } void RunTestsInFile(std::string filename, bool requiresPlugin) { -#if !defined(GOOGLE_CHROME_BUILD) base::FilePath pdf_plugin_src; PathService::Get(base::DIR_SOURCE_ROOT, &pdf_plugin_src); pdf_plugin_src = pdf_plugin_src.AppendASCII("pdf"); @@ -46,7 +45,6 @@ class PDFExtensionTest : public ExtensionApiTest { " because it requires the PDF plugin which is not available."; return; } -#endif ExtensionService* service = extensions::ExtensionSystem::Get( profile())->extension_service(); service->component_loader()->Add(IDR_PDF_MANIFEST, @@ -87,9 +85,16 @@ IN_PROC_BROWSER_TEST_F(PDFExtensionTest, Basic) { RunTestsInFile("basic_test.js", false); } -// TODO(raymes): investigate why this started failing after PDF plugin became -// open source. -IN_PROC_BROWSER_TEST_F(PDFExtensionTest, DISABLED_BasicPlugin) { +// TODO(raymes): This fails with component builds on linux because the plugin +// plugin crashes due to something related to how the plugin DLL is +// compiled/linked. crbug.com/386436. +#if defined(LINUX) && defined(COMPONENT_BUILD) +#define MAYBE_BasicPlugin DISABLED_BasicPlugin +#else +#define MAYBE_BasicPlugin BasicPlugin +#endif + +IN_PROC_BROWSER_TEST_F(PDFExtensionTest, MAYBE_BasicPlugin) { RunTestsInFile("basic_plugin_test.js", true); } diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 93c0573..26826f2 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -1333,6 +1333,7 @@ 'browser/renderer_host/render_process_host_chrome_browsertest.cc', 'browser/renderer_host/web_cache_manager_browsertest.cc', 'browser/repost_form_warning_browsertest.cc', + 'browser/resources/pdf/pdf_extension_test.cc', 'browser/safe_browsing/local_safebrowsing_test_server.cc', 'browser/safe_browsing/safe_browsing_blocking_page_test.cc', 'browser/safe_browsing/safe_browsing_service_browsertest.cc', @@ -1550,7 +1551,6 @@ 'test/base/test_chrome_web_ui_controller_factory.h', 'test/base/test_chrome_web_ui_controller_factory_browsertest.cc', 'test/data/chromeos/oobe_webui_browsertest.js', - 'test/data/pdf/pdf_extension_test.cc', 'test/data/webui/about_invalidations_browsertest.js', 'test/data/webui/accessibility_audit_browsertest.js', 'test/data/webui/assertions.js', diff --git a/chrome/test/data/pdf/basic_plugin_test.js b/chrome/test/data/pdf/basic_plugin_test.js index 8413c52..864c1ae 100644 --- a/chrome/test/data/pdf/basic_plugin_test.js +++ b/chrome/test/data/pdf/basic_plugin_test.js @@ -10,9 +10,10 @@ var tests = [ * Test that the page is sized to the size of the document. */ function testPageSize() { - // Verify that the initial zoom is 100%. - chrome.test.assertEq(1, viewer.viewport.zoom); + // Verify that the initial zoom is less than or equal to 100%. + chrome.test.assertTrue(viewer.viewport.zoom <= 1); + viewer.viewport.zoom = 1; var sizer = document.getElementById('sizer'); chrome.test.assertEq(826, sizer.offsetWidth); chrome.test.assertEq(1066, sizer.offsetHeight); @@ -23,8 +24,10 @@ var tests = [ var client = new PDFScriptingAPI(window, window.location.origin); client.setDestinationWindow(window); client.getAccessibilityJSON(chrome.test.callbackPass(function(json) { - chrome.test.assertEq('{"copyable":true,"loaded":true,"numberOfPages":1}', - json); + var dict = JSON.parse(json); + chrome.test.assertEq(true, dict.copyable); + chrome.test.assertEq(true, dict.loaded); + chrome.test.assertEq(1, dict.numberOfPages); })); }, @@ -47,6 +50,10 @@ var tests = [ } ]; -window.addEventListener('pdfload', function() { +if (viewer.loaded) { chrome.test.runTests(tests); -}); +} else { + window.addEventListener('pdfload', function() { + chrome.test.runTests(tests); + }); +} diff --git a/chrome/test/data/pdf/viewport_test.js b/chrome/test/data/pdf/viewport_test.js index 8ab1d54..7db2d95 100644 --- a/chrome/test/data/pdf/viewport_test.js +++ b/chrome/test/data/pdf/viewport_test.js @@ -359,26 +359,26 @@ var tests = [ viewport.setZoom_(1); mockCallback.reset(); - viewport.goToPage(0) + viewport.goToPage(0); chrome.test.assertTrue(mockCallback.wasCalled); chrome.test.assertEq(0, viewport.position.x); chrome.test.assertEq(0, viewport.position.y); mockCallback.reset(); - viewport.goToPage(1) + viewport.goToPage(1); chrome.test.assertTrue(mockCallback.wasCalled); chrome.test.assertEq(0, viewport.position.x); chrome.test.assertEq(100, viewport.position.y); mockCallback.reset(); - viewport.goToPage(2) + viewport.goToPage(2); chrome.test.assertTrue(mockCallback.wasCalled); chrome.test.assertEq(0, viewport.position.x); chrome.test.assertEq(300, viewport.position.y); viewport.setZoom_(0.5); mockCallback.reset(); - viewport.goToPage(2) + viewport.goToPage(2); chrome.test.assertTrue(mockCallback.wasCalled); chrome.test.assertEq(0, viewport.position.x); chrome.test.assertEq(150, viewport.position.y); diff --git a/pdf/out_of_process_instance.cc b/pdf/out_of_process_instance.cc index 8a692c9..9e77ec6 100644 --- a/pdf/out_of_process_instance.cc +++ b/pdf/out_of_process_instance.cc @@ -408,7 +408,7 @@ void OutOfProcessInstance::HandleMessage(const pp::Var& message) { pp::VarDictionary reply; reply.Set(pp::Var(kType), pp::Var(kJSGetAccessibilityJSONReplyType)); if (dict.Get(pp::Var(kJSAccessibilityPageNumber)).is_int()) { - int page = pp::Var(kJSAccessibilityPageNumber).AsInt(); + int page = dict.Get(pp::Var(kJSAccessibilityPageNumber)).AsInt(); reply.Set(pp::Var(kJSAccessibilityJSON), pp::Var(engine_->GetPageAsJSON(page))); } else { |