Fix regressions in replay performance tests
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Jul 2012 18:30:00 +0000 (18:30 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Jul 2012 18:30:00 +0000 (18:30 +0000)
https://bugs.webkit.org/show_bug.cgi?id=92052

Reviewed by Dirk Pranke.

Fix regression that accumulated over time to make replay tests work again.

* DumpRenderTree/chromium/WebViewHost.cpp:
(WebViewHost::willSendRequest): Use the main document URL in the request since the main frame's
URL hadn't been updated yet When requesting a new URL on the main frame.
* Scripts/webkitpy/performance_tests/perftest.py:
(ReplayServer.wait_until_ready): Waiting for 6 seconds (3 tries) seems enough.
(ReplayPerfTest.prepare): Pass self._archive_path to run_signle as that is the current contract.
(ReplayPerfTest.run_single): Use the archive path to generate -expected.png path.
* Scripts/webkitpy/performance_tests/perftest_unittest.py:
(TestReplayPerfTest.test_run_single):
(TestReplayPerfTest.test_prepare):
(TestReplayPerfTest.test_prepare_calls_run_single.run_single):
(TestReplayPerfTest):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@123498 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/DumpRenderTree/chromium/WebViewHost.cpp
Tools/Scripts/webkitpy/performance_tests/perftest.py
Tools/Scripts/webkitpy/performance_tests/perftest_unittest.py

index c124a3e..9dedc8c 100644 (file)
@@ -1,3 +1,25 @@
+2012-07-23  Ryosuke Niwa  <rniwa@webkit.org>
+
+        Fix regressions in replay performance tests
+        https://bugs.webkit.org/show_bug.cgi?id=92052
+
+        Reviewed by Dirk Pranke.
+
+        Fix regression that accumulated over time to make replay tests work again.
+
+        * DumpRenderTree/chromium/WebViewHost.cpp:
+        (WebViewHost::willSendRequest): Use the main document URL in the request since the main frame's
+        URL hadn't been updated yet When requesting a new URL on the main frame.
+        * Scripts/webkitpy/performance_tests/perftest.py:
+        (ReplayServer.wait_until_ready): Waiting for 6 seconds (3 tries) seems enough.
+        (ReplayPerfTest.prepare): Pass self._archive_path to run_signle as that is the current contract.
+        (ReplayPerfTest.run_single): Use the archive path to generate -expected.png path.
+        * Scripts/webkitpy/performance_tests/perftest_unittest.py:
+        (TestReplayPerfTest.test_run_single):
+        (TestReplayPerfTest.test_prepare):
+        (TestReplayPerfTest.test_prepare_calls_run_single.run_single):
+        (TestReplayPerfTest):
+
 2012-07-24  Simon Hausmann  <simon.hausmann@nokia.com>
 
         [Qt] MSVC: unresolved external symbol __DllMainCRTStartup@12
index 1dca460..54edb8d 100644 (file)
@@ -1279,8 +1279,8 @@ void WebViewHost::willSendRequest(WebFrame* frame, unsigned identifier, WebURLRe
     GURL url = request.url();
     string requestURL = url.possibly_invalid_spec();
 
+    GURL mainDocumentURL = request.firstPartyForCookies();
     if (layoutTestController()->shouldDumpResourceLoadCallbacks()) {
-        GURL mainDocumentURL = request.firstPartyForCookies();
         printResourceDescription(identifier);
         printf(" - willSendRequest <NSURLRequest URL %s, main document URL %s,"
                " http method %s> redirectResponse ",
@@ -1306,9 +1306,8 @@ void WebViewHost::willSendRequest(WebFrame* frame, unsigned identifier, WebURLRe
 
     string host = url.host();
     if (!host.empty() && (url.SchemeIs("http") || url.SchemeIs("https"))) {
-        GURL testURL = webView()->mainFrame()->document().url();
-        const string& testHost = testURL.host();
-        if (!isLocalhost(host) && !hostIsUsedBySomeTestsToGenerateError(host) && ((!testURL.SchemeIs("http") && !testURL.SchemeIs("https")) || isLocalhost(testHost))
+        if (!isLocalhost(host) && !hostIsUsedBySomeTestsToGenerateError(host)
+            && ((!mainDocumentURL.SchemeIs("http") && !mainDocumentURL.SchemeIs("https")) || isLocalhost(mainDocumentURL.host()))
             && !m_shell->allowExternalPages()) {
             printf("Blocked access to external URL %s\n", requestURL.c_str());
             blockRequest(request);
index 8623c0a..8aac78f 100644 (file)
@@ -232,7 +232,7 @@ class ReplayServer(object):
         self._process = subprocess.Popen(args)
 
     def wait_until_ready(self):
-        for i in range(0, 10):
+        for i in range(0, 3):
             try:
                 connection = socket.create_connection(('localhost', '8080'), timeout=1)
                 connection.close()
@@ -281,7 +281,7 @@ class ReplayPerfTest(PageLoadingPerfTest):
 
         driver = self._port.create_driver(worker_number=1, no_timeout=True)
         try:
-            output = self.run_single(driver, self._url, time_out_ms, record=True)
+            output = self.run_single(driver, self._archive_path, time_out_ms, record=True)
         finally:
             driver.stop()
 
@@ -300,6 +300,7 @@ class ReplayPerfTest(PageLoadingPerfTest):
             return None
 
         try:
+            _log.debug("Waiting for Web page replay to start.")
             if not server.wait_until_ready():
                 _log.error("Web page replay didn't start.")
                 return None
@@ -317,8 +318,8 @@ class ReplayPerfTest(PageLoadingPerfTest):
                 return None
 
             filesystem = self._port.host.filesystem
-            dirname = filesystem.dirname(url)
-            filename = filesystem.split(url)[1]
+            dirname = filesystem.dirname(self._archive_path)
+            filename = filesystem.split(self._archive_path)[1]
             writer = TestResultWriter(filesystem, self._port, dirname, filename)
             if record:
                 writer.write_image_files(actual_image=None, expected_image=output.image)
index 078f08a..4fca894 100755 (executable)
@@ -156,7 +156,7 @@ class TestReplayPerfTest(unittest.TestCase):
 
     def _add_file(self, port, dirname, filename, content=True):
         port.host.filesystem.maybe_make_directory(dirname)
-        port.host.filesystem.files[port.host.filesystem.join(dirname, filename)] = content
+        port.host.filesystem.write_binary_file(port.host.filesystem.join(dirname, filename), content)
 
     def _setup_test(self, run_test=None):
         test_port = self.ReplayTestPort(run_test)
@@ -195,6 +195,7 @@ class TestReplayPerfTest(unittest.TestCase):
         self.assertEqual(actual_stdout, '')
         self.assertEqual(actual_stderr, '')
         self.assertEqual(actual_logs, '')
+        self.assertEqual(port.host.filesystem.read_binary_file('/path/some-dir/some-test-actual.png'), 'actual image')
 
     def test_run_single_fails_without_webpagereplay(self):
         output_capture = OutputCapture()
@@ -281,6 +282,7 @@ class TestReplayPerfTest(unittest.TestCase):
         self.assertEqual(actual_stdout, '')
         self.assertEqual(actual_stderr, '')
         self.assertEqual(actual_logs, 'Preparing replay for some-test.replay\nPrepared replay for some-test.replay\n')
+        self.assertEqual(port.host.filesystem.read_binary_file('/path/some-dir/some-test-expected.png'), 'actual image')
 
     def test_prepare_calls_run_single(self):
         output_capture = OutputCapture()
@@ -289,7 +291,7 @@ class TestReplayPerfTest(unittest.TestCase):
 
         def run_single(driver, url, time_out_ms, record):
             self.assertTrue(record)
-            self.assertEqual(url, 'http://some-test/')
+            self.assertEqual(url, '/path/some-dir/some-test.wpr')
             called[0] = True
             return False