Title: [100862] trunk/Tools
Revision
100862
Author
[email protected]
Date
2011-11-19 17:13:19 -0800 (Sat, 19 Nov 2011)

Log Message

Remove the dependence on jsonp from more of new-run-webkit-tests and the test results server
https://bugs.webkit.org/show_bug.cgi?id=72813

Reviewed by Adam Barth.

Once this lands, we can start storing pure json in the test results server and then
we can delete the code with all the FIXMEs added here.

* Scripts/webkitpy/layout_tests/controllers/manager.py:
* Scripts/webkitpy/layout_tests/layout_package/json_results_generator.py:
Only add jsonp for full_results.json.
* TestResultServer/model/jsonresults.py:
* TestResultServer/model/jsonresults_unittest.py:
Accept pure json uploads.
* TestResultServer/static-dashboards/dashboard_base.js:
(appendJSONScriptElementFor):
Use the callback parameter so that the server can start returning pure json if it's left out.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (100861 => 100862)


--- trunk/Tools/ChangeLog	2011-11-20 00:04:53 UTC (rev 100861)
+++ trunk/Tools/ChangeLog	2011-11-20 01:13:19 UTC (rev 100862)
@@ -1,5 +1,25 @@
 2011-11-19  Ojan Vafai  <[email protected]>
 
+        Remove the dependence on jsonp from more of new-run-webkit-tests and the test results server
+        https://bugs.webkit.org/show_bug.cgi?id=72813
+
+        Reviewed by Adam Barth.
+
+        Once this lands, we can start storing pure json in the test results server and then
+        we can delete the code with all the FIXMEs added here.
+
+        * Scripts/webkitpy/layout_tests/controllers/manager.py:
+        * Scripts/webkitpy/layout_tests/layout_package/json_results_generator.py:
+        Only add jsonp for full_results.json.
+        * TestResultServer/model/jsonresults.py:
+        * TestResultServer/model/jsonresults_unittest.py:
+        Accept pure json uploads.
+        * TestResultServer/static-dashboards/dashboard_base.js:
+        (appendJSONScriptElementFor):
+        Use the callback parameter so that the server can start returning pure json if it's left out.
+
+2011-11-19  Ojan Vafai  <[email protected]>
+
         Allow json NRWT downloads to be pure json and not jsonp
         https://bugs.webkit.org/show_bug.cgi?id=72809
 

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py (100861 => 100862)


--- trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py	2011-11-20 00:04:53 UTC (rev 100861)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py	2011-11-20 01:13:19 UTC (rev 100862)
@@ -1081,7 +1081,8 @@
         json_results_generator.write_json(self._fs, times_trie, times_json_path)
 
         full_results_path = self._fs.join(self._results_directory, "full_results.json")
-        json_results_generator.write_json(self._fs, summarized_results, full_results_path)
+        # We write full_results.json out as jsonp because we need to load it from a file url and Chromium doesn't allow that.
+        json_results_generator.write_json(self._fs, summarized_results, full_results_path, callback="ADD_RESULTS")
 
         generator = json_layout_results_generator.JSONLayoutResultsGenerator(
             self._port, self._options.builder_name, self._options.build_name,

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/layout_package/json_results_generator.py (100861 => 100862)


--- trunk/Tools/Scripts/webkitpy/layout_tests/layout_package/json_results_generator.py	2011-11-20 00:04:53 UTC (rev 100861)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/layout_package/json_results_generator.py	2011-11-20 01:13:19 UTC (rev 100862)
@@ -56,6 +56,7 @@
 
 
 def strip_json_wrapper(json_content):
+    # FIXME: Kill this code once the server returns json instead of jsonp.
     if has_json_wrapper(json_content):
         return json_content[len(_JSON_PREFIX):len(json_content) - len(_JSON_SUFFIX)]
     return json_content
@@ -67,10 +68,11 @@
     return json.loads(content)
 
 
-def write_json(filesystem, json_object, file_path):
+def write_json(filesystem, json_object, file_path, callback=None):
     # Specify separators in order to get compact encoding.
-    json_data = json.dumps(json_object, separators=(',', ':'))
-    json_string = _JSON_PREFIX + json_data + _JSON_SUFFIX
+    json_string = json.dumps(json_object, separators=(',', ':'))
+    if callback:
+        json_string = callback + "(" + json_string + ");"
     filesystem.write_text_file(file_path, json_string)
 
 

Modified: trunk/Tools/TestResultServer/model/jsonresults.py (100861 => 100862)


--- trunk/Tools/TestResultServer/model/jsonresults.py	2011-11-20 00:04:53 UTC (rev 100861)
+++ trunk/Tools/TestResultServer/model/jsonresults.py	2011-11-20 01:13:19 UTC (rev 100862)
@@ -53,11 +53,11 @@
 class JsonResults(object):
     @classmethod
     def _strip_prefix_suffix(cls, data):
-        assert(data.startswith(JSON_RESULTS_PREFIX))
-        assert(data.endswith(JSON_RESULTS_SUFFIX))
+        # FIXME: Stop stripping jsonp callback once we upload pure json everywhere.
+        if data.startswith(JSON_RESULTS_PREFIX) and data.endswith(JSON_RESULTS_SUFFIX):
+            return data[len(JSON_RESULTS_PREFIX):len(data) - len(JSON_RESULTS_SUFFIX)]
+        return data
 
-        return data[len(JSON_RESULTS_PREFIX):len(data) - len(JSON_RESULTS_SUFFIX)]
-
     @classmethod
     def _generate_file_data(cls, json, sort_keys=False):
         data = "" separators=(',', ':'), sort_keys=sort_keys)

Modified: trunk/Tools/TestResultServer/model/jsonresults_unittest.py (100861 => 100862)


--- trunk/Tools/TestResultServer/model/jsonresults_unittest.py	2011-11-20 00:04:53 UTC (rev 100861)
+++ trunk/Tools/TestResultServer/model/jsonresults_unittest.py	2011-11-20 01:13:19 UTC (rev 100862)
@@ -81,6 +81,11 @@
     def setUp(self):
         self._builder = "Webkit"
 
+    def test_strip_prefix_suffix(self):
+        json = "['contents']"
+        self.assertEqual(JsonResults._strip_prefix_suffix(JSON_RESULTS_PREFIX + json + JSON_RESULTS_SUFFIX), json)
+        self.assertEqual(JsonResults._strip_prefix_suffix(json), json)
+
     def _make_test_json(self, test_data):
         if not test_data:
             return JSON_RESULTS_PREFIX + JSON_RESULTS_SUFFIX

Modified: trunk/Tools/TestResultServer/static-dashboards/dashboard_base.js (100861 => 100862)


--- trunk/Tools/TestResultServer/static-dashboards/dashboard_base.js	2011-11-20 00:04:53 UTC (rev 100861)
+++ trunk/Tools/TestResultServer/static-dashboards/dashboard_base.js	2011-11-20 01:13:19 UTC (rev 100862)
@@ -526,7 +526,7 @@
     else
         resultsFilename = 'results-small.json';
 
-    appendScript(pathToBuilderResultsFile(builderName) + resultsFilename,
+    appendScript(pathToBuilderResultsFile(builderName) + resultsFilename + '&callback=ADD_RESULTS',
             partial(handleResourceLoadError, builderName),
             partial(handleScriptLoaded, builderName));
 }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to