Changeset 142643 in webkit
- Timestamp:
- Feb 12, 2013 10:50:43 AM (11 years ago)
- Location:
- trunk/Tools
- Files:
-
- 14 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r142637 r142643 1 2013-02-12 Jochen Eisinger <jochen@chromium.org> 2 3 [chromium] move text dump generation to TestRunner library 4 https://bugs.webkit.org/show_bug.cgi?id=109575 5 6 Reviewed by Adam Barth. 7 8 * DumpRenderTree/DumpRenderTree.gypi: 9 * DumpRenderTree/chromium/TestRunner/public/WebTestDelegate.h: 10 (WebKit): 11 (WebTestRunner::WebTestDelegate::captureHistoryForWindow): 12 * DumpRenderTree/chromium/TestRunner/public/WebTestProxy.h: 13 * DumpRenderTree/chromium/TestRunner/public/WebTestRunner.h: 14 (WebTestRunner): 15 * DumpRenderTree/chromium/TestRunner/src/TestCommon.cpp: Copied from Tools/DumpRenderTree/chromium/TestRunner/src/TestCommon.h. 16 (WebTestRunner::normalizeLayoutTestURL): 17 (WebTestRunner): 18 * DumpRenderTree/chromium/TestRunner/src/TestCommon.h: 19 (WebTestRunner): 20 * DumpRenderTree/chromium/TestRunner/src/TestRunner.cpp: 21 (WebTestRunner::TestRunner::checkResponseMimeType): 22 (WebTestRunner): 23 (WebTestRunner::TestRunner::shouldDumpAsText): 24 (WebTestRunner::TestRunner::shouldGeneratePixelResults): 25 * DumpRenderTree/chromium/TestRunner/src/TestRunner.h: 26 (TestRunner): 27 * DumpRenderTree/chromium/TestRunner/src/WebPermissions.cpp: 28 * DumpRenderTree/chromium/TestRunner/src/WebTestProxy.cpp: 29 (WebTestRunner::WebTestProxyBase::captureTree): 30 (WebTestRunner): 31 * DumpRenderTree/chromium/TestShell.cpp: 32 (TestShell::dump): 33 (TestShell::captureHistoryForWindow): 34 * DumpRenderTree/chromium/TestShell.h: 35 (TestShell): 36 * DumpRenderTree/chromium/WebViewHost.cpp: 37 (WebViewHost::captureHistoryForWindow): 38 * DumpRenderTree/chromium/WebViewHost.h: 39 1 40 2013-02-12 Jessie Berlin <jberlin@apple.com> 2 41 -
trunk/Tools/DumpRenderTree/DumpRenderTree.gypi
r142593 r142643 80 80 'chromium/TestRunner/src/SpellCheckClient.cpp', 81 81 'chromium/TestRunner/src/SpellCheckClient.h', 82 'chromium/TestRunner/src/TestCommon.cpp', 82 83 'chromium/TestRunner/src/TestCommon.h', 83 84 'chromium/TestRunner/src/TestInterfaces.cpp', -
trunk/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestDelegate.h
r142549 r142643 40 40 class WebDeviceOrientation; 41 41 class WebGamepads; 42 class WebHistoryItem; 42 43 struct WebRect; 43 44 struct WebURLError; … … 114 115 virtual void loadURLForFrame(const WebKit::WebURL&, const std::string&) { } 115 116 virtual bool allowExternalPages() { return false; } 117 virtual void captureHistoryForWindow(size_t windowIndex, WebKit::WebVector<WebKit::WebHistoryItem>* history, size_t* currentEntryIndex) { } 116 118 }; 117 119 -
trunk/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestProxy.h
r142593 r142643 94 94 void setPaintRect(const WebKit::WebRect&); 95 95 WebKit::WebRect paintRect() const; 96 97 std::string captureTree(bool debugRenderTree); 96 98 97 99 void setLogConsoleOutput(bool enabled); -
trunk/Tools/DumpRenderTree/chromium/TestRunner/public/WebTestRunner.h
r142370 r142643 41 41 class WebTestRunner { 42 42 public: 43 virtual bool shouldDumpAsText() const = 0; 44 virtual bool shouldGeneratePixelResults() const = 0; 45 virtual bool shouldDumpChildFrameScrollPositions() const = 0; 46 virtual bool shouldDumpChildFramesAsText() const = 0; 43 virtual bool shouldGeneratePixelResults() = 0; 47 44 virtual bool shouldDumpAsAudio() const = 0; 48 45 virtual const WebKit::WebArrayBufferView* audioData() const = 0; 49 46 virtual WebKit::WebPermissionClient* webPermissions() const = 0; 50 virtual bool shouldDumpBackForwardList() const = 0;51 47 virtual bool shouldDumpSelectionRect() const = 0; 52 48 virtual bool testRepaint() const = 0; -
trunk/Tools/DumpRenderTree/chromium/TestRunner/src/TestCommon.cpp
r142642 r142643 29 29 */ 30 30 31 #i fndef TestCommon_h32 # define TestCommon_h31 #include "config.h" 32 #include "TestCommon.h" 33 33 34 #include <base/compiler_specific.h> 35 #include <public/WebCommon.h> 36 #include <stdio.h> 34 using namespace std; 37 35 38 #if defined(WIN32) 39 #define snprintf(str, size, ...) _snprintf_s(str, size, size, __VA_ARGS__) 40 #endif 36 namespace WebTestRunner { 41 37 42 inline bool isASCIIAlpha(char ch) { return (ch | 0x20) >= 'a' && (ch | 0x20) <= 'z'; } 38 namespace { 43 39 44 inline bool isNotASCIIAlpha(char ch) { return !isASCIIAlpha(ch); } 40 const char layoutTestsPattern[] = "/LayoutTests/"; 41 const string::size_type layoutTestsPatternSize = sizeof(layoutTestsPattern) - 1; 42 const char fileUrlPattern[] = "file:/"; 43 const char fileTestPrefix[] = "(file test):"; 44 const char dataUrlPattern[] = "data:"; 45 const string::size_type dataUrlPatternSize = sizeof(dataUrlPattern) - 1; 45 46 46 #endif // TestCommon_h 47 } 48 49 string normalizeLayoutTestURL(const string& url) 50 { 51 string result = url; 52 size_t pos; 53 if (!url.find(fileUrlPattern) && ((pos = url.find(layoutTestsPattern)) != string::npos)) { 54 // adjust file URLs to match upstream results. 55 result.replace(0, pos + layoutTestsPatternSize, fileTestPrefix); 56 } else if (!url.find(dataUrlPattern)) { 57 // URL-escape data URLs to match results upstream. 58 string path = url.substr(dataUrlPatternSize); 59 result.replace(dataUrlPatternSize, url.length(), path); 60 } 61 return result; 62 } 63 64 } -
trunk/Tools/DumpRenderTree/chromium/TestRunner/src/TestCommon.h
r142237 r142643 35 35 #include <public/WebCommon.h> 36 36 #include <stdio.h> 37 #include <string> 37 38 38 39 #if defined(WIN32) … … 40 41 #endif 41 42 43 namespace WebTestRunner { 44 42 45 inline bool isASCIIAlpha(char ch) { return (ch | 0x20) >= 'a' && (ch | 0x20) <= 'z'; } 43 46 44 47 inline bool isNotASCIIAlpha(char ch) { return !isASCIIAlpha(ch); } 45 48 49 std::string normalizeLayoutTestURL(const std::string& url); 50 51 } 52 46 53 #endif // TestCommon_h -
trunk/Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.cpp
r142582 r142643 35 35 36 36 #include "WebBindings.h" 37 #include "WebDataSource.h" 37 38 #include "WebDeviceOrientation.h" 38 39 #include "WebDocument.h" … … 56 57 #include <public/WebData.h> 57 58 #include <public/WebPoint.h> 59 #include <public/WebURLResponse.h> 58 60 59 61 #if defined(__linux__) || defined(ANDROID) … … 426 428 } 427 429 428 bool TestRunner::shouldDumpAsText() const 429 { 430 void TestRunner::checkResponseMimeType() 431 { 432 // Text output: the test page can request different types of output 433 // which we handle here. 434 if (!m_dumpAsText) { 435 string mimeType = m_webView->mainFrame()->dataSource()->response().mimeType().utf8(); 436 if (mimeType == "text/plain") { 437 m_dumpAsText = true; 438 m_generatePixelResults = false; 439 } 440 } 441 } 442 443 bool TestRunner::shouldDumpAsText() 444 { 445 checkResponseMimeType(); 430 446 return m_dumpAsText; 431 447 } … … 436 452 } 437 453 438 bool TestRunner::shouldGeneratePixelResults() const 439 { 454 bool TestRunner::shouldGeneratePixelResults() 455 { 456 checkResponseMimeType(); 440 457 return m_generatePixelResults; 441 458 } -
trunk/Tools/DumpRenderTree/chromium/TestRunner/src/TestRunner.h
r142549 r142643 72 72 73 73 // WebTestRunner implementation. 74 virtual bool shouldDumpAsText() const OVERRIDE; 75 virtual bool shouldGeneratePixelResults() const OVERRIDE; 76 virtual bool shouldDumpChildFrameScrollPositions() const OVERRIDE; 77 virtual bool shouldDumpChildFramesAsText() const OVERRIDE; 74 virtual bool shouldGeneratePixelResults() OVERRIDE; 78 75 virtual bool shouldDumpAsAudio() const OVERRIDE; 79 76 virtual const WebKit::WebArrayBufferView* audioData() const OVERRIDE; 80 77 virtual WebKit::WebPermissionClient* webPermissions() const OVERRIDE; 81 virtual bool shouldDumpBackForwardList() const OVERRIDE;82 78 virtual bool shouldDumpSelectionRect() const OVERRIDE; 83 79 virtual bool testRepaint() const OVERRIDE; … … 86 82 87 83 // Methods used by WebTestProxyBase. 84 bool shouldDumpAsText(); 85 bool shouldDumpBackForwardList() const; 86 bool shouldDumpChildFrameScrollPositions() const; 87 bool shouldDumpChildFramesAsText() const; 88 88 void showDevTools(); 89 89 void setShouldDumpAsText(bool); … … 487 487 /////////////////////////////////////////////////////////////////////////// 488 488 // Internal helpers 489 void checkResponseMimeType(); 489 490 void completeNotifyDone(bool isTimeout); 490 491 class NotifyDoneTimedOutTask: public WebMethodTask<TestRunner> { -
trunk/Tools/DumpRenderTree/chromium/TestRunner/src/WebPermissions.cpp
r142253 r142643 32 32 #include "WebPermissions.h" 33 33 34 #include "TestCommon.h" 34 35 #include "WebTestDelegate.h" 35 36 #include <public/WebCString.h> … … 39 40 40 41 namespace WebTestRunner { 41 42 namespace {43 44 const char layoutTestsPattern[] = "/LayoutTests/";45 const string::size_type layoutTestsPatternSize = sizeof(layoutTestsPattern) - 1;46 const char fileUrlPattern[] = "file:/";47 const char fileTestPrefix[] = "(file test):";48 const char dataUrlPattern[] = "data:";49 const string::size_type dataUrlPatternSize = sizeof(dataUrlPattern) - 1;50 51 string normalizeLayoutTestURL(const string& url)52 {53 string result = url;54 size_t pos;55 if (!url.find(fileUrlPattern) && ((pos = url.find(layoutTestsPattern)) != string::npos)) {56 // adjust file URLs to match upstream results.57 result.replace(0, pos + layoutTestsPatternSize, fileTestPrefix);58 } else if (!url.find(dataUrlPattern)) {59 // URL-escape data URLs to match results upstream.60 string path = url.substr(dataUrlPatternSize);61 result.replace(dataUrlPatternSize, url.length(), path);62 }63 return result;64 }65 66 }67 42 68 43 WebPermissions::WebPermissions() -
trunk/Tools/DumpRenderTree/chromium/TestRunner/src/WebTestProxy.cpp
r142593 r142643 44 44 #include "WebConsoleMessage.h" 45 45 #include "WebDataSource.h" 46 #include "WebDocument.h" 46 47 #include "WebElement.h" 47 48 #include "WebFrame.h" 49 #include "WebHistoryItem.h" 48 50 #include "WebNode.h" 49 51 #include "WebPluginParams.h" 50 52 #include "WebPrintParams.h" 51 53 #include "WebRange.h" 54 #include "WebScriptController.h" 52 55 #include "WebTestDelegate.h" 53 56 #include "WebTestInterfaces.h" … … 55 58 #include "WebUserMediaClientMock.h" 56 59 #include "WebView.h" 60 #include <cctype> 57 61 #include <public/WebCString.h> 58 62 #include <public/WebURLError.h> … … 255 259 } 256 260 261 string dumpDocumentText(WebFrame* frame) 262 { 263 // We use the document element's text instead of the body text here because 264 // not all documents have a body, such as XML documents. 265 WebElement documentElement = frame->document().documentElement(); 266 if (documentElement.isNull()) 267 return string(); 268 return documentElement.innerText().utf8(); 269 } 270 271 string dumpFramesAsText(WebFrame* frame, bool recursive) 272 { 273 string result; 274 275 // Add header for all but the main frame. Skip empty frames. 276 if (frame->parent() && !frame->document().documentElement().isNull()) { 277 result.append("\n--------\nFrame: '"); 278 result.append(frame->uniqueName().utf8().data()); 279 result.append("'\n--------\n"); 280 } 281 282 result.append(dumpDocumentText(frame)); 283 result.append("\n"); 284 285 if (recursive) { 286 for (WebFrame* child = frame->firstChild(); child; child = child->nextSibling()) 287 result.append(dumpFramesAsText(child, recursive)); 288 } 289 290 return result; 291 } 292 293 string dumpFramesAsPrintedText(WebFrame* frame, bool recursive) 294 { 295 string result; 296 297 // Cannot do printed format for anything other than HTML 298 if (!frame->document().isHTMLDocument()) 299 return string(); 300 301 // Add header for all but the main frame. Skip empty frames. 302 if (frame->parent() && !frame->document().documentElement().isNull()) { 303 result.append("\n--------\nFrame: '"); 304 result.append(frame->uniqueName().utf8().data()); 305 result.append("'\n--------\n"); 306 } 307 308 result.append(frame->renderTreeAsText(WebFrame::RenderAsTextPrinting).utf8()); 309 result.append("\n"); 310 311 if (recursive) { 312 for (WebFrame* child = frame->firstChild(); child; child = child->nextSibling()) 313 result.append(dumpFramesAsPrintedText(child, recursive)); 314 } 315 316 return result; 317 } 318 319 string dumpFrameScrollPosition(WebFrame* frame, bool recursive) 320 { 321 string result; 322 WebSize offset = frame->scrollOffset(); 323 if (offset.width > 0 || offset.height > 0) { 324 if (frame->parent()) 325 result = string("frame '") + frame->uniqueName().utf8().data() + "' "; 326 char data[100]; 327 snprintf(data, sizeof(data), "scrolled to %d,%d\n", offset.width, offset.height); 328 result += data; 329 } 330 331 if (!recursive) 332 return result; 333 for (WebFrame* child = frame->firstChild(); child; child = child->nextSibling()) 334 result += dumpFrameScrollPosition(child, recursive); 335 return result; 336 } 337 338 struct ToLower { 339 char16 operator()(char16 c) { return tolower(c); } 340 }; 341 342 // Returns True if item1 < item2. 343 bool HistoryItemCompareLess(const WebHistoryItem& item1, const WebHistoryItem& item2) 344 { 345 string16 target1 = item1.target(); 346 string16 target2 = item2.target(); 347 std::transform(target1.begin(), target1.end(), target1.begin(), ToLower()); 348 std::transform(target2.begin(), target2.end(), target2.begin(), ToLower()); 349 return target1 < target2; 350 } 351 352 string dumpHistoryItem(const WebHistoryItem& item, int indent, bool isCurrent) 353 { 354 string result; 355 356 if (isCurrent) { 357 result.append("curr->"); 358 result.append(indent - 6, ' '); // 6 == "curr->".length() 359 } else 360 result.append(indent, ' '); 361 362 string url = normalizeLayoutTestURL(item.urlString().utf8()); 363 result.append(url); 364 if (!item.target().isEmpty()) { 365 result.append(" (in frame \""); 366 result.append(item.target().utf8()); 367 result.append("\")"); 368 } 369 if (item.isTargetItem()) 370 result.append(" **nav target**"); 371 result.append("\n"); 372 373 const WebVector<WebHistoryItem>& children = item.children(); 374 if (!children.isEmpty()) { 375 // Must sort to eliminate arbitrary result ordering which defeats 376 // reproducible testing. 377 // FIXME: WebVector should probably just be a std::vector!! 378 std::vector<WebHistoryItem> sortedChildren; 379 for (size_t i = 0; i < children.size(); ++i) 380 sortedChildren.push_back(children[i]); 381 std::sort(sortedChildren.begin(), sortedChildren.end(), HistoryItemCompareLess); 382 for (size_t i = 0; i < sortedChildren.size(); ++i) 383 result += dumpHistoryItem(sortedChildren[i], indent + 4, false); 384 } 385 386 return result; 387 } 388 389 void dumpBackForwardList(const WebVector<WebHistoryItem>& history, size_t currentEntryIndex, string& result) 390 { 391 result.append("\n============== Back Forward List ==============\n"); 392 for (int index = 0; index < history.size(); ++index) 393 result.append(dumpHistoryItem(history[index], 8, index == currentEntryIndex)); 394 result.append("===============================================\n"); 395 } 396 397 string dumpAllBackForwardLists(WebTestDelegate* delegate) 398 { 399 string result; 400 unsigned windowCount = delegate->windowCount(); 401 fprintf(stderr, "windowCount = %d\n", windowCount); 402 for (unsigned i = 0; i < windowCount; ++i) { 403 size_t currentEntryIndex = 0; 404 WebVector<WebHistoryItem> history; 405 delegate->captureHistoryForWindow(i, &history, ¤tEntryIndex); 406 dumpBackForwardList(history, currentEntryIndex, result); 407 } 408 return result; 409 } 410 257 411 } 258 412 … … 300 454 { 301 455 return m_paintRect; 456 } 457 458 string WebTestProxyBase::captureTree(bool debugRenderTree) 459 { 460 WebScriptController::flushConsoleMessages(); 461 462 bool shouldDumpAsText = m_testInterfaces->testRunner()->shouldDumpAsText(); 463 bool shouldDumpAsPrinted = m_testInterfaces->testRunner()->isPrinting(); 464 WebFrame* frame = m_testInterfaces->webView()->mainFrame(); 465 string dataUtf8; 466 if (shouldDumpAsText) { 467 bool recursive = m_testInterfaces->testRunner()->shouldDumpChildFramesAsText(); 468 dataUtf8 = shouldDumpAsPrinted ? dumpFramesAsPrintedText(frame, recursive) : dumpFramesAsText(frame, recursive); 469 } else { 470 bool recursive = m_testInterfaces->testRunner()->shouldDumpChildFrameScrollPositions(); 471 WebFrame::RenderAsTextControls renderTextBehavior = WebFrame::RenderAsTextNormal; 472 if (shouldDumpAsPrinted) 473 renderTextBehavior |= WebFrame::RenderAsTextPrinting; 474 if (debugRenderTree) 475 renderTextBehavior |= WebFrame::RenderAsTextDebug; 476 dataUtf8 = frame->renderTreeAsText(renderTextBehavior).utf8(); 477 dataUtf8 += dumpFrameScrollPosition(frame, recursive); 478 } 479 480 if (m_testInterfaces->testRunner()->shouldDumpBackForwardList()) 481 dataUtf8 += dumpAllBackForwardLists(m_delegate); 482 483 return dataUtf8; 302 484 } 303 485 -
trunk/Tools/DumpRenderTree/chromium/TestShell.cpp
r142593 r142643 45 45 #include "WebTestingSupport.h" 46 46 #include "WebRuntimeFeatures.h" 47 #include "WebScriptController.h"48 47 #include "WebSettings.h" 49 48 #include "WebTestProxy.h" … … 393 392 } 394 393 395 static string dumpDocumentText(WebFrame* frame)396 {397 // We use the document element's text instead of the body text here because398 // not all documents have a body, such as XML documents.399 WebElement documentElement = frame->document().documentElement();400 if (documentElement.isNull())401 return string();402 return documentElement.innerText().utf8();403 }404 405 static string dumpFramesAsText(WebFrame* frame, bool recursive)406 {407 string result;408 409 // Add header for all but the main frame. Skip empty frames.410 if (frame->parent() && !frame->document().documentElement().isNull()) {411 result.append("\n--------\nFrame: '");412 result.append(frame->uniqueName().utf8().data());413 result.append("'\n--------\n");414 }415 416 result.append(dumpDocumentText(frame));417 result.append("\n");418 419 if (recursive) {420 for (WebFrame* child = frame->firstChild(); child; child = child->nextSibling())421 result.append(dumpFramesAsText(child, recursive));422 }423 424 return result;425 }426 427 static string dumpFramesAsPrintedText(WebFrame* frame, bool recursive)428 {429 string result;430 431 // Cannot do printed format for anything other than HTML432 if (!frame->document().isHTMLDocument())433 return string();434 435 // Add header for all but the main frame. Skip empty frames.436 if (frame->parent() && !frame->document().documentElement().isNull()) {437 result.append("\n--------\nFrame: '");438 result.append(frame->uniqueName().utf8().data());439 result.append("'\n--------\n");440 }441 442 result.append(frame->renderTreeAsText(WebFrame::RenderAsTextPrinting).utf8());443 result.append("\n");444 445 if (recursive) {446 for (WebFrame* child = frame->firstChild(); child; child = child->nextSibling())447 result.append(dumpFramesAsPrintedText(child, recursive));448 }449 450 return result;451 }452 453 static void dumpFrameScrollPosition(WebFrame* frame, bool recursive)454 {455 WebSize offset = frame->scrollOffset();456 if (offset.width > 0 || offset.height > 0) {457 if (frame->parent())458 printf("frame '%s' ", frame->uniqueName().utf8().data());459 printf("scrolled to %d,%d\n", offset.width, offset.height);460 }461 462 if (!recursive)463 return;464 for (WebFrame* child = frame->firstChild(); child; child = child->nextSibling())465 dumpFrameScrollPosition(child, recursive);466 }467 468 struct ToLower {469 char16 operator()(char16 c) { return tolower(c); }470 };471 472 // FIXME: Eliminate std::transform(), std::vector, and std::sort().473 474 // Returns True if item1 < item2.475 static bool HistoryItemCompareLess(const WebHistoryItem& item1, const WebHistoryItem& item2)476 {477 string16 target1 = item1.target();478 string16 target2 = item2.target();479 std::transform(target1.begin(), target1.end(), target1.begin(), ToLower());480 std::transform(target2.begin(), target2.end(), target2.begin(), ToLower());481 return target1 < target2;482 }483 484 static string normalizeLayoutTestURLInternal(const string& url)485 {486 string result = url;487 size_t pos;488 if (!url.find(fileUrlPattern) && ((pos = url.find(layoutTestsPattern)) != string::npos)) {489 // adjust file URLs to match upstream results.490 result.replace(0, pos + layoutTestsPatternSize, fileTestPrefix);491 } else if (!url.find(dataUrlPattern)) {492 // URL-escape data URLs to match results upstream.493 string path = url.substr(dataUrlPatternSize);494 result.replace(dataUrlPatternSize, url.length(), path);495 }496 return result;497 }498 499 static string dumpHistoryItem(const WebHistoryItem& item, int indent, bool isCurrent)500 {501 string result;502 503 if (isCurrent) {504 result.append("curr->");505 result.append(indent - 6, ' '); // 6 == "curr->".length()506 } else507 result.append(indent, ' ');508 509 string url = normalizeLayoutTestURLInternal(item.urlString().utf8());510 result.append(url);511 if (!item.target().isEmpty()) {512 result.append(" (in frame \"");513 result.append(item.target().utf8());514 result.append("\")");515 }516 if (item.isTargetItem())517 result.append(" **nav target**");518 result.append("\n");519 520 const WebVector<WebHistoryItem>& children = item.children();521 if (!children.isEmpty()) {522 // Must sort to eliminate arbitrary result ordering which defeats523 // reproducible testing.524 // FIXME: WebVector should probably just be a std::vector!!525 std::vector<WebHistoryItem> sortedChildren;526 for (size_t i = 0; i < children.size(); ++i)527 sortedChildren.push_back(children[i]);528 std::sort(sortedChildren.begin(), sortedChildren.end(), HistoryItemCompareLess);529 for (size_t i = 0; i < sortedChildren.size(); ++i)530 result += dumpHistoryItem(sortedChildren[i], indent + 4, false);531 }532 533 return result;534 }535 536 static void dumpBackForwardList(const TestNavigationController& navigationController, string& result)537 {538 result.append("\n============== Back Forward List ==============\n");539 for (int index = 0; index < navigationController.entryCount(); ++index) {540 int currentIndex = navigationController.lastCommittedEntryIndex();541 WebHistoryItem historyItem = navigationController.entryAtIndex(index)->contentState();542 if (historyItem.isNull()) {543 historyItem.initialize();544 historyItem.setURLString(navigationController.entryAtIndex(index)->URL().spec().utf16());545 }546 result.append(dumpHistoryItem(historyItem, 8, index == currentIndex));547 }548 result.append("===============================================\n");549 }550 551 string TestShell::dumpAllBackForwardLists()552 {553 string result;554 for (unsigned i = 0; i < m_windowList.size(); ++i)555 dumpBackForwardList(*m_windowList[i]->navigationController(), result);556 return result;557 }558 559 394 void TestShell::dump() 560 395 { 561 WebScriptController::flushConsoleMessages();562 563 396 // Dump the requested representation. 564 397 WebFrame* frame = m_webView->mainFrame(); 565 398 if (!frame) 566 399 return; 567 bool shouldDumpAsText = m_testInterfaces->testRunner()->shouldDumpAsText();568 400 bool shouldDumpAsAudio = m_testInterfaces->testRunner()->shouldDumpAsAudio(); 569 401 bool shouldGeneratePixelResults = m_testInterfaces->testRunner()->shouldGeneratePixelResults(); 570 bool shouldDumpAsPrinted = m_testInterfaces->testRunner()->isPrinting();571 402 bool dumpedAnything = false; 572 403 … … 585 416 dumpedAnything = true; 586 417 m_printer.handleTextHeader(); 587 // Text output: the test page can request different types of output 588 // which we handle here. 589 if (!shouldDumpAsText) { 590 // Plain text pages should be dumped as text 591 string mimeType = frame->dataSource()->response().mimeType().utf8(); 592 if (mimeType == "text/plain") { 593 shouldDumpAsText = true; 594 shouldGeneratePixelResults = false; 595 } 596 } 597 if (shouldDumpAsText) { 598 bool recursive = m_testInterfaces->testRunner()->shouldDumpChildFramesAsText(); 599 string dataUtf8 = shouldDumpAsPrinted ? dumpFramesAsPrintedText(frame, recursive) : dumpFramesAsText(frame, recursive); 600 if (fwrite(dataUtf8.c_str(), 1, dataUtf8.size(), stdout) != dataUtf8.size()) 601 FATAL("Short write to stdout, disk full?\n"); 602 } else { 603 WebFrame::RenderAsTextControls renderTextBehavior = WebFrame::RenderAsTextNormal; 604 if (shouldDumpAsPrinted) 605 renderTextBehavior |= WebFrame::RenderAsTextPrinting; 606 if (m_params.debugRenderTree) 607 renderTextBehavior |= WebFrame::RenderAsTextDebug; 608 printf("%s", frame->renderTreeAsText(renderTextBehavior).utf8().data()); 609 bool recursive = m_testInterfaces->testRunner()->shouldDumpChildFrameScrollPositions(); 610 dumpFrameScrollPosition(frame, recursive); 611 } 612 if (m_testInterfaces->testRunner()->shouldDumpBackForwardList()) 613 printf("%s", dumpAllBackForwardLists().c_str()); 418 string dataUtf8 = m_webViewHost->proxy()->captureTree(m_params.debugRenderTree); 419 if (fwrite(dataUtf8.c_str(), 1, dataUtf8.size(), stdout) != dataUtf8.size()) 420 FATAL("Short write to stdout, disk full?\n"); 614 421 } 615 422 if (dumpedAnything && m_params.printSeparators) … … 811 618 return m_windowList.size(); 812 619 } 620 621 void TestShell::captureHistoryForWindow(size_t windowIndex, WebVector<WebHistoryItem>* history, size_t* currentEntryIndex) 622 { 623 ASSERT(history); 624 ASSERT(currentEntryIndex); 625 if (windowIndex >= m_windowList.size()) 626 return; 627 TestNavigationController& navigationController = *m_windowList[windowIndex]->navigationController(); 628 size_t entryCount = navigationController.entryCount(); 629 WebVector<WebHistoryItem> result(entryCount); 630 *currentEntryIndex = navigationController.lastCommittedEntryIndex(); 631 for (size_t index = 0; index < entryCount; ++index) { 632 WebHistoryItem historyItem = navigationController.entryAtIndex(index)->contentState(); 633 if (historyItem.isNull()) { 634 historyItem.initialize(); 635 historyItem.setURLString(navigationController.entryAtIndex(index)->URL().spec().utf16()); 636 } 637 result[index] = historyItem; 638 } 639 history->swap(result); 640 } -
trunk/Tools/DumpRenderTree/chromium/TestShell.h
r142593 r142643 166 166 void closeRemainingWindows(); 167 167 int windowCount(); 168 void captureHistoryForWindow(size_t windowIndex, WebKit::WebVector<WebKit::WebHistoryItem>*, size_t* currentEntryIndex); 168 169 static void resizeWindowForTest(WebViewHost*, const WebKit::WebURL&); 169 170 -
trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp
r142593 r142643 924 924 } 925 925 926 void WebViewHost::captureHistoryForWindow(size_t windowIndex, WebVector<WebHistoryItem>* history, size_t* currentEntryIndex) 927 { 928 m_shell->captureHistoryForWindow(windowIndex, history, currentEntryIndex); 929 } 930 926 931 // Public functions ----------------------------------------------------------- 927 932 -
trunk/Tools/DumpRenderTree/chromium/WebViewHost.h
r142593 r142643 171 171 virtual void loadURLForFrame(const WebKit::WebURL&, const std::string& frameName) OVERRIDE; 172 172 virtual bool allowExternalPages() OVERRIDE; 173 virtual void captureHistoryForWindow(size_t windowIndex, WebKit::WebVector<WebKit::WebHistoryItem>*, size_t* currentEntryIndex) OVERRIDE; 173 174 174 175 // NavigationHost
Note: See TracChangeset
for help on using the changeset viewer.