Changeset 162056 in webkit
- Timestamp:
- Jan 14, 2014 11:47:47 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r162047 r162056 1 2014-01-14 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] UI process crashes when the web process crashes while printing 4 https://bugs.webkit.org/show_bug.cgi?id=126977 5 6 Reviewed by Gustavo Noronha Silva. 7 8 When the web process crashes, the printing callback is 9 invalidated, so the function is called with a NULL error. 10 11 * UIProcess/API/gtk/WebKitPrintOperation.cpp: 12 (drawPagesForPrintingCompleted): Check wkError is not NULL before 13 trying to use it. 14 * UIProcess/API/gtk/WebKitWebView.cpp: 15 (webkitWebViewPrintFrame): Set the print mode of the operation 16 before emitting the print signal. 17 1 18 2014-01-14 Brady Eidson <beidson@apple.com> 2 19 -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitPrintOperation.cpp
r159042 r162056 270 270 page->endPrinting(); 271 271 272 const WebCore::ResourceError& resourceError = toImpl(wkPrintError)->platformError();272 const WebCore::ResourceError& resourceError = wkPrintError ? toImpl(wkPrintError)->platformError() : WebCore::ResourceError(); 273 273 if (!resourceError.isNull()) { 274 274 GOwnPtr<GError> printError(g_error_new_literal(g_quark_from_string(resourceError.domain().utf8().data()), -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
r161256 r162056 1679 1679 { 1680 1680 GRefPtr<WebKitPrintOperation> printOperation = adoptGRef(webkit_print_operation_new(webView)); 1681 webkitPrintOperationSetPrintMode(printOperation.get(), PrintInfo::PrintModeSync); 1681 1682 gboolean returnValue; 1682 1683 g_signal_emit(webView, signals[PRINT], 0, printOperation.get(), &returnValue); … … 1684 1685 return; 1685 1686 1686 webkitPrintOperationSetPrintMode(printOperation.get(), PrintInfo::PrintModeSync);1687 1687 WebKitPrintOperationResponse response = webkitPrintOperationRunDialogForFrame(printOperation.get(), 0, frame); 1688 1688 if (response == WEBKIT_PRINT_OPERATION_RESPONSE_CANCEL) -
trunk/Tools/ChangeLog
r162010 r162056 1 2014-01-14 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] UI process crashes when the web process crashes while printing 4 https://bugs.webkit.org/show_bug.cgi?id=126977 5 6 Reviewed by Gustavo Noronha Silva. 7 8 Add new test case to check that closing the window right after 9 printing works. It's skipped for now, because this patch only 10 fixes the UI process crash, but not the web process one. 11 12 * Scripts/run-gtk-tests: 13 (TestRunner): Skip 14 /webkit2/WebKitPrintOperation/close-after-print. 15 * TestWebKitAPI/Tests/WebKit2Gtk/TestPrinting.cpp: 16 (testPrintOperationPrintPrinter): 17 (findPrintToFilePrinter): 18 (testPrintOperationPrint): 19 (testPrintOperationErrors): 20 (testPrintOperationCloseAfterPrint): 21 (beforeAll): 22 1 23 2014-01-14 Brent Fulgham <bfulgham@apple.com> 2 24 -
trunk/Tools/Scripts/run-gtk-tests
r161499 r162056 70 70 SkippedTest("WebKit2Gtk/TestContextMenu", SkippedTest.ENTIRE_SUITE, "Test times out after r150890", 117689), 71 71 SkippedTest("WebKit2Gtk/TestWebKitWebView", "/webkit2/WebKitWebView/snapshot", "Test fails", 120404), 72 SkippedTest("WebKit2Gtk/TestPrinting", "/webkit2/WebKitPrintOperation/close-after-print", "Test times out", 126979), 72 73 SkippedTest("WebKit2/TestWebKit2", "WebKit2.MouseMoveAfterCrash", "Test is flaky", 85066), 73 74 SkippedTest("WebKit2/TestWebKit2", "WebKit2.NewFirstVisuallyNonEmptyLayoutForImages", "Test is flaky", 85066), -
trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestPrinting.cpp
r161366 r162056 73 73 74 74 #ifdef HAVE_GTK_UNIX_PRINTING 75 static gboolean testPrintOperationPrintPrinter(GtkPrinter* printer, gpointer userData) 76 { 77 if (strcmp(gtk_printer_get_name(printer), "Print to File")) 78 return FALSE; 79 80 GtkPrinter** foundPrinter = static_cast<GtkPrinter**>(userData); 81 *foundPrinter = static_cast<GtkPrinter*>(g_object_ref(printer)); 82 return TRUE; 83 } 84 85 static GtkPrinter* findPrintToFilePrinter() 86 { 87 GtkPrinter* printer = 0; 88 gtk_enumerate_printers(testPrintOperationPrintPrinter, &printer, 0, TRUE); 89 return printer; 90 } 91 75 92 class PrintTest: public WebViewTest { 76 93 public: … … 98 115 } 99 116 100 static gboolean testPrintOperationPrintPrinter(GtkPrinter* printer, gpointer userData)101 {102 if (strcmp(gtk_printer_get_name(printer), "Print to File"))103 return FALSE;104 105 GtkPrinter** foundPrinter = static_cast<GtkPrinter**>(userData);106 *foundPrinter = static_cast<GtkPrinter*>(g_object_ref(printer));107 return TRUE;108 }109 110 GtkPrinter* findPrintToFilePrinter()111 {112 GtkPrinter* printer = 0;113 gtk_enumerate_printers(testPrintOperationPrintPrinter, &printer, 0, TRUE);114 return printer;115 }116 117 117 void waitUntilPrintFinished() 118 118 { … … 129 129 test->waitUntilLoadFinished(); 130 130 131 GRefPtr<GtkPrinter> printer = adoptGRef( test->findPrintToFilePrinter());131 GRefPtr<GtkPrinter> printer = adoptGRef(findPrintToFilePrinter()); 132 132 if (!printer) { 133 133 g_message("%s", "Cannot test WebKitPrintOperation/print: no suitable printer found"); … … 162 162 test->waitUntilLoadFinished(); 163 163 164 GRefPtr<GtkPrinter> printer = adoptGRef( test->findPrintToFilePrinter());164 GRefPtr<GtkPrinter> printer = adoptGRef(findPrintToFilePrinter()); 165 165 if (!printer) { 166 166 g_message("%s", "Cannot test WebKitPrintOperation/print: no suitable printer found"); … … 190 190 test->waitUntilPrintFinished(); 191 191 } 192 193 class CloseAfterPrintTest: public WebViewTest { 194 public: 195 MAKE_GLIB_TEST_FIXTURE(CloseAfterPrintTest); 196 197 static GtkWidget* webViewCreate(WebKitWebView* webView, CloseAfterPrintTest* test) 198 { 199 return test->createWebView(); 200 } 201 202 static gboolean webViewPrint(WebKitWebView* webView, WebKitPrintOperation* printOperation, CloseAfterPrintTest* test) 203 { 204 test->print(printOperation); 205 return TRUE; 206 } 207 208 static void printOperationFinished(WebKitPrintOperation* printOperation, CloseAfterPrintTest* test) 209 { 210 test->printFinished(); 211 } 212 213 static void webViewClosed(WebKitWebView* webView, CloseAfterPrintTest* test) 214 { 215 gtk_widget_destroy(GTK_WIDGET(webView)); 216 test->m_webViewClosed = true; 217 if (test->m_printFinished) 218 g_main_loop_quit(test->m_mainLoop); 219 } 220 221 CloseAfterPrintTest() 222 : m_webViewClosed(false) 223 , m_printFinished(false) 224 { 225 webkit_settings_set_javascript_can_open_windows_automatically(webkit_web_view_get_settings(m_webView), TRUE); 226 g_signal_connect(m_webView, "create", G_CALLBACK(webViewCreate), this); 227 } 228 229 GtkWidget* createWebView() 230 { 231 GtkWidget* newWebView = webkit_web_view_new(); 232 g_object_ref_sink(newWebView); 233 234 assertObjectIsDeletedWhenTestFinishes(G_OBJECT(newWebView)); 235 g_signal_connect(newWebView, "print", G_CALLBACK(webViewPrint), this); 236 g_signal_connect(newWebView, "close", G_CALLBACK(webViewClosed), this); 237 return newWebView; 238 } 239 240 void print(WebKitPrintOperation* printOperation) 241 { 242 assertObjectIsDeletedWhenTestFinishes(G_OBJECT(printOperation)); 243 244 GRefPtr<GtkPrinter> printer = adoptGRef(findPrintToFilePrinter()); 245 if (!printer) { 246 g_message("%s", "Cannot test WebKitPrintOperation/print: no suitable printer found"); 247 return; 248 } 249 250 GOwnPtr<char> outputFilename(g_build_filename(kTempDirectory, "webkit-close-after-print.pdf", NULL)); 251 m_outputFile = adoptGRef(g_file_new_for_path(outputFilename.get())); 252 GOwnPtr<char> outputURI(g_file_get_uri(m_outputFile.get())); 253 254 GRefPtr<GtkPrintSettings> printSettings = adoptGRef(gtk_print_settings_new()); 255 gtk_print_settings_set_printer(printSettings.get(), gtk_printer_get_name(printer.get())); 256 gtk_print_settings_set(printSettings.get(), GTK_PRINT_SETTINGS_OUTPUT_URI, outputURI.get()); 257 webkit_print_operation_set_print_settings(printOperation, printSettings.get()); 258 259 m_printOperation = printOperation; 260 g_signal_connect(m_printOperation.get(), "finished", G_CALLBACK(printOperationFinished), this); 261 webkit_print_operation_print(m_printOperation.get()); 262 } 263 264 void printFinished() 265 { 266 m_printFinished = true; 267 m_printOperation = nullptr; 268 g_assert(m_outputFile); 269 g_file_delete(m_outputFile.get(), 0, 0); 270 m_outputFile = nullptr; 271 if (m_webViewClosed) 272 g_main_loop_quit(m_mainLoop); 273 } 274 275 void waitUntilPrintFinishedAndViewClosed() 276 { 277 g_main_loop_run(m_mainLoop); 278 } 279 280 GRefPtr<WebKitPrintOperation> m_printOperation; 281 GRefPtr<GFile> m_outputFile; 282 bool m_webViewClosed; 283 bool m_printFinished; 284 }; 285 286 static void testPrintOperationCloseAfterPrint(CloseAfterPrintTest* test, gconstpointer) 287 { 288 test->loadHtml("<html><body onLoad=\"w = window.open();w.print();w.close();\"></body></html>", 0); 289 test->waitUntilPrintFinishedAndViewClosed(); 290 } 192 291 #endif // HAVE_GTK_UNIX_PRINTING 193 292 … … 202 301 PrintTest::add("WebKitPrintOperation", "print", testPrintOperationPrint); 203 302 PrintTest::add("WebKitPrintOperation", "print-errors", testPrintOperationErrors); 303 CloseAfterPrintTest::add("WebKitPrintOperation", "close-after-print", testPrintOperationCloseAfterPrint); 204 304 #endif 205 305 }
Note: See TracChangeset
for help on using the changeset viewer.