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.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@100862
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2011-11-19 Ojan Vafai <ojan@chromium.org>
+
+ 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 <ojan@chromium.org>
Allow json NRWT downloads to be pure json and not jsonp
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,
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
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)
class JsonResults(object):
@classmethod
def _strip_prefix_suffix(cls, data):
- assert(data.startswith(JSON_RESULTS_PREFIX))
- assert(data.endswith(JSON_RESULTS_SUFFIX))
-
- return data[len(JSON_RESULTS_PREFIX):len(data) - len(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
@classmethod
def _generate_file_data(cls, json, sort_keys=False):
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
else
resultsFilename = 'results-small.json';
- appendScript(pathToBuilderResultsFile(builderName) + resultsFilename,
+ appendScript(pathToBuilderResultsFile(builderName) + resultsFilename + '&callback=ADD_RESULTS',
partial(handleResourceLoadError, builderName),
partial(handleScriptLoaded, builderName));
}