<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[214008] trunk/Websites/perf.webkit.org</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/214008">214008</a></dd>
<dt>Author</dt> <dd>rniwa@webkit.org</dd>
<dt>Date</dt> <dd>2017-03-15 14:59:12 -0700 (Wed, 15 Mar 2017)</dd>
</dl>
<h3>Log Message</h3>
<pre>In-browser and node.js implementations of RemoteAPI should share some code
https://bugs.webkit.org/show_bug.cgi?id=169695
Rubber-stamped by Antti Koivisto.
Extracted CommonRemoteAPI out of RemoteAPI implementations for node.js and browser.
* public/shared/common-remote.js: Added.
(CommonRemoteAPI): Added.
(CommonRemoteAPI.prototype.postJSON): Extracted from RemoteAPI.
(CommonRemoteAPI.prototype.postJSONWithStatus): Ditto.
(CommonRemoteAPI.prototype.getJSON): Ditto.
(CommonRemoteAPI.prototype.getJSONWithStatus): Ditto.
(CommonRemoteAPI.prototype.sendHttpRequest): Added. Needs to implemented by a subclass.
(CommonRemoteAPI.prototype._asJSON): Added.
(CommonRemoteAPI.prototype._checkStatus): Added.
* public/v3/index.html: Include common-remote.js.
* public/v3/privileged-api.js:
(PrivilegedAPI): Use class now that we don't include data.js.
(PrivilegedAPI.sendRequest): Modernized the code.
(PrivilegedAPI.requestCSRFToken): Ditto.
* public/v3/remote.js:
(BrowserRemoteAPI): Renamed from RemoteAPI. window.RemoteAPI is now an instance of this class.
(BrowserRemoteAPI.prototype.sendHttpRequest): Moved from RemoteAPI.sendHttpRequest.
(BrowserRemoteAPI.prototype.sendHttpRequest):
* server-tests/privileged-api-create-analysis-task-tests.js: Updated tests since NodeJSRemoteAPI
now throws the JSON status as an error to be consistent with BrowserRemoteAPI.
* server-tests/privileged-api-create-test-group-tests.js: Ditto.
* server-tests/privileged-api-upate-run-status.js: Ditto.
* tools/js/buildbot-triggerable.js:
(BuildbotTriggerable.prototype.syncOnce): Just use postJSONWithStatus instead of manually
checking the status.
* tools/js/remote.js:
(NodeRemoteAPI): Renamed from RemoteAPI. Still exported as RemoteAPI.
(NodeRemoteAPI.prototype.constructor):
(NodeRemoteAPI.prototype.sendHttpRequest): Modernized the code.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkWebsitesperfwebkitorgChangeLog">trunk/Websites/perf.webkit.org/ChangeLog</a></li>
<li><a href="#trunkWebsitesperfwebkitorgpublicv3indexhtml">trunk/Websites/perf.webkit.org/public/v3/index.html</a></li>
<li><a href="#trunkWebsitesperfwebkitorgpublicv3privilegedapijs">trunk/Websites/perf.webkit.org/public/v3/privileged-api.js</a></li>
<li><a href="#trunkWebsitesperfwebkitorgpublicv3remotejs">trunk/Websites/perf.webkit.org/public/v3/remote.js</a></li>
<li><a href="#trunkWebsitesperfwebkitorgservertestsprivilegedapicreateanalysistasktestsjs">trunk/Websites/perf.webkit.org/server-tests/privileged-api-create-analysis-task-tests.js</a></li>
<li><a href="#trunkWebsitesperfwebkitorgservertestsprivilegedapicreatetestgrouptestsjs">trunk/Websites/perf.webkit.org/server-tests/privileged-api-create-test-group-tests.js</a></li>
<li><a href="#trunkWebsitesperfwebkitorgservertestsprivilegedapiupaterunstatusjs">trunk/Websites/perf.webkit.org/server-tests/privileged-api-upate-run-status.js</a></li>
<li><a href="#trunkWebsitesperfwebkitorgtoolsjsbuildbottriggerablejs">trunk/Websites/perf.webkit.org/tools/js/buildbot-triggerable.js</a></li>
<li><a href="#trunkWebsitesperfwebkitorgtoolsjsremotejs">trunk/Websites/perf.webkit.org/tools/js/remote.js</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkWebsitesperfwebkitorgpublicsharedcommonremotejs">trunk/Websites/perf.webkit.org/public/shared/common-remote.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkWebsitesperfwebkitorgChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Websites/perf.webkit.org/ChangeLog (214007 => 214008)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/ChangeLog        2017-03-15 21:47:11 UTC (rev 214007)
+++ trunk/Websites/perf.webkit.org/ChangeLog        2017-03-15 21:59:12 UTC (rev 214008)
</span><span class="lines">@@ -1,5 +1,50 @@
</span><span class="cx"> 2017-03-15 Ryosuke Niwa <rniwa@webkit.org>
</span><span class="cx">
</span><ins>+ In-browser and node.js implementations of RemoteAPI should share some code
+ https://bugs.webkit.org/show_bug.cgi?id=169695
+
+ Rubber-stamped by Antti Koivisto.
+
+ Extracted CommonRemoteAPI out of RemoteAPI implementations for node.js and browser.
+
+ * public/shared/common-remote.js: Added.
+ (CommonRemoteAPI): Added.
+ (CommonRemoteAPI.prototype.postJSON): Extracted from RemoteAPI.
+ (CommonRemoteAPI.prototype.postJSONWithStatus): Ditto.
+ (CommonRemoteAPI.prototype.getJSON): Ditto.
+ (CommonRemoteAPI.prototype.getJSONWithStatus): Ditto.
+ (CommonRemoteAPI.prototype.sendHttpRequest): Added. Needs to implemented by a subclass.
+ (CommonRemoteAPI.prototype._asJSON): Added.
+ (CommonRemoteAPI.prototype._checkStatus): Added.
+
+ * public/v3/index.html: Include common-remote.js.
+
+ * public/v3/privileged-api.js:
+ (PrivilegedAPI): Use class now that we don't include data.js.
+ (PrivilegedAPI.sendRequest): Modernized the code.
+ (PrivilegedAPI.requestCSRFToken): Ditto.
+
+ * public/v3/remote.js:
+ (BrowserRemoteAPI): Renamed from RemoteAPI. window.RemoteAPI is now an instance of this class.
+ (BrowserRemoteAPI.prototype.sendHttpRequest): Moved from RemoteAPI.sendHttpRequest.
+ (BrowserRemoteAPI.prototype.sendHttpRequest):
+
+ * server-tests/privileged-api-create-analysis-task-tests.js: Updated tests since NodeJSRemoteAPI
+ now throws the JSON status as an error to be consistent with BrowserRemoteAPI.
+ * server-tests/privileged-api-create-test-group-tests.js: Ditto.
+ * server-tests/privileged-api-upate-run-status.js: Ditto.
+
+ * tools/js/buildbot-triggerable.js:
+ (BuildbotTriggerable.prototype.syncOnce): Just use postJSONWithStatus instead of manually
+ checking the status.
+
+ * tools/js/remote.js:
+ (NodeRemoteAPI): Renamed from RemoteAPI. Still exported as RemoteAPI.
+ (NodeRemoteAPI.prototype.constructor):
+ (NodeRemoteAPI.prototype.sendHttpRequest): Modernized the code.
+
+2017-03-15 Ryosuke Niwa <rniwa@webkit.org>
+
</ins><span class="cx"> Fix server tests after r213998 and r213969
</span><span class="cx"> https://bugs.webkit.org/show_bug.cgi?id=169690
</span><span class="cx">
</span></span></pre></div>
<a id="trunkWebsitesperfwebkitorgpublicsharedcommonremotejs"></a>
<div class="addfile"><h4>Added: trunk/Websites/perf.webkit.org/public/shared/common-remote.js (0 => 214008)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/public/shared/common-remote.js         (rev 0)
+++ trunk/Websites/perf.webkit.org/public/shared/common-remote.js        2017-03-15 21:59:12 UTC (rev 214008)
</span><span class="lines">@@ -0,0 +1,52 @@
</span><ins>+"use strict";
+
+class CommonRemoteAPI {
+ postJSON(path, data)
+ {
+ return this._asJSON(this.sendHttpRequest(path, 'POST', 'application/json', JSON.stringify(data || {})));
+ }
+
+ postJSONWithStatus(path, data)
+ {
+ return this._checkStatus(this.postJSON(path, data));
+ }
+
+ getJSON(path)
+ {
+ return this._asJSON(this.sendHttpRequest(path, 'GET', null, null));
+ }
+
+ getJSONWithStatus(path)
+ {
+ return this._checkStatus(this.getJSON(path));
+ }
+
+ sendHttpRequest(path, method, contentType, content)
+ {
+ throw 'NotImplemented';
+ }
+
+ _asJSON(promise)
+ {
+ return promise.then((result) => {
+ try {
+ return JSON.parse(result.responseText);
+ } catch (error) {
+ console.error(result.responseText);
+ reject(result.statusCode + ', ' + error);
+ }
+ });
+ }
+
+ _checkStatus(promise)
+ {
+ return promise.then(function (content) {
+ if (content['status'] != 'OK')
+ throw content['status'];
+ return content;
+ });
+ }
+}
+
+if (typeof module != 'undefined')
+ module.exports.CommonRemoteAPI = CommonRemoteAPI;
</ins></span></pre></div>
<a id="trunkWebsitesperfwebkitorgpublicv3indexhtml"></a>
<div class="modfile"><h4>Modified: trunk/Websites/perf.webkit.org/public/v3/index.html (214007 => 214008)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/public/v3/index.html        2017-03-15 21:47:11 UTC (rev 214007)
+++ trunk/Websites/perf.webkit.org/public/v3/index.html        2017-03-15 21:59:12 UTC (rev 214008)
</span><span class="lines">@@ -38,6 +38,7 @@
</span><span class="cx">
</span><span class="cx"> <template id="unbundled-scripts">
</span><span class="cx"> <script src="../shared/statistics.js"></script>
</span><ins>+ <script src="../shared/common-remote.js"></script>
</ins><span class="cx">
</span><span class="cx"> <script src="instrumentation.js"></script>
</span><span class="cx"> <script src="remote.js"></script>
</span><span class="lines">@@ -89,6 +90,7 @@
</span><span class="cx"> <script src="components/chart-pane-base.js"></script>
</span><span class="cx"> <script src="components/mutable-list-view.js"></script>
</span><span class="cx"> <script src="components/ratio-bar-graph.js"></script>
</span><ins>+
</ins><span class="cx"> <script src="pages/page.js"></script>
</span><span class="cx"> <script src="pages/page-router.js"></script>
</span><span class="cx"> <script src="pages/heading.js"></script>
</span></span></pre></div>
<a id="trunkWebsitesperfwebkitorgpublicv3privilegedapijs"></a>
<div class="modfile"><h4>Modified: trunk/Websites/perf.webkit.org/public/v3/privileged-api.js (214007 => 214008)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/public/v3/privileged-api.js        2017-03-15 21:47:11 UTC (rev 214007)
+++ trunk/Websites/perf.webkit.org/public/v3/privileged-api.js        2017-03-15 21:59:12 UTC (rev 214008)
</span><span class="lines">@@ -1,23 +1,25 @@
</span><span class="cx"> "use strict";
</span><span class="cx">
</span><del>-// FIXME: Use real class syntax once the dependency on data.js has been removed.
-var PrivilegedAPI = class {
</del><ins>+class PrivilegedAPI {
</ins><span class="cx">
</span><span class="cx"> static sendRequest(path, data)
</span><span class="cx"> {
</span><del>- var clonedData = {};
- for (var key in data)
</del><ins>+ const clonedData = {};
+ for (let key in data)
</ins><span class="cx"> clonedData[key] = data[key];
</span><span class="cx">
</span><del>- return this.requestCSRFToken().then(function (token) {
</del><ins>+ const fullPath = '/privileged-api/' + path;
+ const post = () => RemoteAPI.postJSONWithStatus(fullPath, clonedData);
+
+ return this.requestCSRFToken().then((token) => {
</ins><span class="cx"> clonedData['token'] = token;
</span><del>- return RemoteAPI.postJSONWithStatus('/privileged-api/' + path, clonedData).catch(function (status) {
</del><ins>+ return post().catch((status) => {
</ins><span class="cx"> if (status != 'InvalidToken')
</span><span class="cx"> return Promise.reject(status);
</span><del>- PrivilegedAPI._token = null;
- return PrivilegedAPI.requestCSRFToken().then(function (token) {
</del><ins>+ this._token = null;
+ return this.requestCSRFToken().then((token) => {
</ins><span class="cx"> clonedData['token'] = token;
</span><del>- return RemoteAPI.postJSONWithStatus('/privileged-api/' + path, clonedData);
</del><ins>+ return post();
</ins><span class="cx"> });
</span><span class="cx"> });
</span><span class="cx"> });
</span><span class="lines">@@ -25,14 +27,14 @@
</span><span class="cx">
</span><span class="cx"> static requestCSRFToken()
</span><span class="cx"> {
</span><del>- var maxNetworkLatency = 3 * 60 * 1000; /* 3 minutes */
</del><ins>+ const maxNetworkLatency = 3 * 60 * 1000; /* 3 minutes */
</ins><span class="cx"> if (this._token && this._expiration > Date.now() + maxNetworkLatency)
</span><span class="cx"> return Promise.resolve(this._token);
</span><span class="cx">
</span><del>- return RemoteAPI.postJSONWithStatus('/privileged-api/generate-csrf-token').then(function (result) {
- PrivilegedAPI._token = result['token'];
- PrivilegedAPI._expiration = new Date(result['expiration']);
- return PrivilegedAPI._token;
</del><ins>+ return RemoteAPI.postJSONWithStatus('/privileged-api/generate-csrf-token').then((result) => {
+ this._token = result['token'];
+ this._expiration = new Date(result['expiration']);
+ return this._token;
</ins><span class="cx"> });
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkWebsitesperfwebkitorgpublicv3remotejs"></a>
<div class="modfile"><h4>Modified: trunk/Websites/perf.webkit.org/public/v3/remote.js (214007 => 214008)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/public/v3/remote.js        2017-03-15 21:47:11 UTC (rev 214007)
+++ trunk/Websites/perf.webkit.org/public/v3/remote.js        2017-03-15 21:59:12 UTC (rev 214008)
</span><span class="lines">@@ -1,66 +1,41 @@
</span><span class="cx"> "use strict";
</span><span class="cx">
</span><del>-var RemoteAPI = {};
</del><ins>+class BrowserRemoteAPI extends CommonRemoteAPI {
</ins><span class="cx">
</span><del>-RemoteAPI.postJSON = function (path, data)
-{
- return this.getJSON(path, data || {});
-}
</del><ins>+ sendHttpRequest(path, method, contentType, content)
+ {
+ console.assert(!path.startsWith('http:') && !path.startsWith('https:') && !path.startsWith('file:'));
</ins><span class="cx">
</span><del>-RemoteAPI.postJSONWithStatus = function (path, data)
-{
- return this.getJSONWithStatus(path, data || {});
-}
</del><ins>+ return new Promise((resolve, reject) => {
+ Instrumentation.startMeasuringTime('Remote', 'sendHttpRequest');
</ins><span class="cx">
</span><del>-RemoteAPI.getJSON = function(path, data)
-{
- console.assert(!path.startsWith('http:') && !path.startsWith('https:') && !path.startsWith('file:'));
</del><ins>+ function onload() {
+ Instrumentation.endMeasuringTime('Remote', 'sendHttpRequest');
+ if (xhr.status != 200)
+ return resject(xhr.status);
+ resolve({statusCode: xhr.status, responseText: xhr.responseText});
+ };
</ins><span class="cx">
</span><del>- return new Promise(function (resolve, reject) {
- Instrumentation.startMeasuringTime('Remote', 'getJSON');
-
- var xhr = new XMLHttpRequest;
- xhr.onload = function () {
- Instrumentation.endMeasuringTime('Remote', 'getJSON');
-
- if (xhr.status != 200) {
</del><ins>+ function onerror() {
+ Instrumentation.endMeasuringTime('Remote', 'sendHttpRequest');
</ins><span class="cx"> reject(xhr.status);
</span><del>- return;
</del><span class="cx"> }
</span><span class="cx">
</span><del>- try {
- var parsed = JSON.parse(xhr.responseText);
- resolve(parsed);
- } catch (error) {
- console.error(xhr.responseText);
- reject(xhr.status + ', ' + error);
- }
- };
</del><ins>+ const xhr = new XMLHttpRequest;
+ xhr.onload = onload;
+ xhr.onabort = onerror;
+ xhr.onerror = onerror;
</ins><span class="cx">
</span><del>- function onerror() {
- Instrumentation.endMeasuringTime('Remote', 'getJSON');
- reject(xhr.status);
- }
</del><ins>+ xhr.open(method, path, true);
+ if (contentType)
+ xhr.setRequestHeader('Content-Type', contentType);
+ if (content)
+ xhr.send(content);
+ else
+ xhr.send();
+ });
+ }
</ins><span class="cx">
</span><del>- xhr.onabort = onerror;
- xhr.onerror = onerror;
-
- if (data) {
- xhr.open('POST', path, true);
- xhr.setRequestHeader('Content-Type', 'application/json');
- xhr.send(JSON.stringify(data));
- } else {
- xhr.open('GET', path, true);
- xhr.send();
- }
- });
</del><span class="cx"> }
</span><span class="cx">
</span><del>-RemoteAPI.getJSONWithStatus = function(path, data)
-{
- return this.getJSON(path, data).then(function (content) {
- if (content['status'] != 'OK')
- return Promise.reject(content['status']);
- return content;
- });
-}
</del><ins>+const RemoteAPI = new BrowserRemoteAPI;
</ins></span></pre></div>
<a id="trunkWebsitesperfwebkitorgservertestsprivilegedapicreateanalysistasktestsjs"></a>
<div class="modfile"><h4>Modified: trunk/Websites/perf.webkit.org/server-tests/privileged-api-create-analysis-task-tests.js (214007 => 214008)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/server-tests/privileged-api-create-analysis-task-tests.js        2017-03-15 21:47:11 UTC (rev 214007)
+++ trunk/Websites/perf.webkit.org/server-tests/privileged-api-create-analysis-task-tests.js        2017-03-15 21:59:12 UTC (rev 214008)
</span><span class="lines">@@ -63,8 +63,8 @@
</span><span class="cx"> it('should return "MissingName" on an empty request', () => {
</span><span class="cx"> return PrivilegedAPI.sendRequest('create-analysis-task', {}).then((content) => {
</span><span class="cx"> assert(false, 'should never be reached');
</span><del>- }, (response) => {
- assert.equal(response['status'], 'MissingName');
</del><ins>+ }, (error) => {
+ assert.equal(error, 'MissingName');
</ins><span class="cx"> });
</span><span class="cx"> });
</span><span class="cx">
</span><span class="lines">@@ -71,8 +71,8 @@
</span><span class="cx"> it('should return "InvalidStartRun" when startRun is missing but endRun is set', () => {
</span><span class="cx"> return PrivilegedAPI.sendRequest('create-analysis-task', {name: 'hi', endRun: 1}).then((content) => {
</span><span class="cx"> assert(false, 'should never be reached');
</span><del>- }, (response) => {
- assert.equal(response['status'], 'InvalidStartRun');
</del><ins>+ }, (error) => {
+ assert.equal(error, 'InvalidStartRun');
</ins><span class="cx"> });
</span><span class="cx"> });
</span><span class="cx">
</span><span class="lines">@@ -79,8 +79,8 @@
</span><span class="cx"> it('should return "InvalidEndRun" when endRun is missing but startRun is set', () => {
</span><span class="cx"> return PrivilegedAPI.sendRequest('create-analysis-task', {name: 'hi', startRun: 1}).then((content) => {
</span><span class="cx"> assert(false, 'should never be reached');
</span><del>- }, (response) => {
- assert.equal(response['status'], 'InvalidEndRun');
</del><ins>+ }, (error) => {
+ assert.equal(error, 'InvalidEndRun');
</ins><span class="cx"> });
</span><span class="cx"> });
</span><span class="cx">
</span><span class="lines">@@ -87,8 +87,8 @@
</span><span class="cx"> it('should return "InvalidStartRun" when startRun is not a valid integer', () => {
</span><span class="cx"> return PrivilegedAPI.sendRequest('create-analysis-task', {name: 'hi', startRun: "foo", endRun: 1}).then((content) => {
</span><span class="cx"> assert(false, 'should never be reached');
</span><del>- }, (response) => {
- assert.equal(response['status'], 'InvalidStartRun');
</del><ins>+ }, (error) => {
+ assert.equal(error, 'InvalidStartRun');
</ins><span class="cx"> });
</span><span class="cx"> });
</span><span class="cx">
</span><span class="lines">@@ -95,8 +95,8 @@
</span><span class="cx"> it('should return "InvalidEndRun" when endRun is not a valid integer', () => {
</span><span class="cx"> return PrivilegedAPI.sendRequest('create-analysis-task', {name: 'hi', startRun: 1, endRun: "foo"}).then((content) => {
</span><span class="cx"> assert(false, 'should never be reached');
</span><del>- }, (response) => {
- assert.equal(response['status'], 'InvalidEndRun');
</del><ins>+ }, (error) => {
+ assert.equal(error, 'InvalidEndRun');
</ins><span class="cx"> });
</span><span class="cx"> });
</span><span class="cx">
</span><span class="lines">@@ -106,8 +106,8 @@
</span><span class="cx"> }).then(() => {
</span><span class="cx"> return PrivilegedAPI.sendRequest('create-analysis-task', {name: 'hi', startRun: 100, endRun: 1}).then((content) => {
</span><span class="cx"> assert(false, 'should never be reached');
</span><del>- }, (response) => {
- assert.equal(response['status'], 'InvalidStartRun');
</del><ins>+ }, (error) => {
+ assert.equal(error, 'InvalidStartRun');
</ins><span class="cx"> });
</span><span class="cx"> });
</span><span class="cx"> });
</span><span class="lines">@@ -118,8 +118,8 @@
</span><span class="cx"> }).then(() => {
</span><span class="cx"> return PrivilegedAPI.sendRequest('create-analysis-task', {name: 'hi', startRun: 1, endRun: 100}).then((content) => {
</span><span class="cx"> assert(false, 'should never be reached');
</span><del>- }, (response) => {
- assert.equal(response['status'], 'InvalidEndRun');
</del><ins>+ }, (error) => {
+ assert.equal(error, 'InvalidEndRun');
</ins><span class="cx"> });
</span><span class="cx"> });
</span><span class="cx"> });
</span><span class="lines">@@ -130,8 +130,8 @@
</span><span class="cx"> }).then(() => {
</span><span class="cx"> return PrivilegedAPI.sendRequest('create-analysis-task', {name: 'hi', startRun: 1, endRun: 1}).then((content) => {
</span><span class="cx"> assert(false, 'should never be reached');
</span><del>- }, (response) => {
- assert.equal(response['status'], 'InvalidTimeRange');
</del><ins>+ }, (error) => {
+ assert.equal(error, 'InvalidTimeRange');
</ins><span class="cx"> });
</span><span class="cx"> });
</span><span class="cx"> });
</span><span class="lines">@@ -142,8 +142,8 @@
</span><span class="cx"> }).then(() => {
</span><span class="cx"> return PrivilegedAPI.sendRequest('create-analysis-task', {name: 'hi', startRun: 1, endRun: 2}).then((content) => {
</span><span class="cx"> assert(false, 'should never be reached');
</span><del>- }, (response) => {
- assert.equal(response['status'], 'RunConfigMismatch');
</del><ins>+ }, (error) => {
+ assert.equal(error, 'RunConfigMismatch');
</ins><span class="cx"> });
</span><span class="cx"> });
</span><span class="cx"> });
</span><span class="lines">@@ -204,8 +204,8 @@
</span><span class="cx"> }).then((content) => {
</span><span class="cx"> return PrivilegedAPI.sendRequest('create-analysis-task', {name: 'hi', startRun: startId, endRun: endId}).then(() => {
</span><span class="cx"> assert(false, 'should never be reached');
</span><del>- }, (response) => {
- assert.equal(response['status'], 'DuplicateAnalysisTask');
</del><ins>+ }, (error) => {
+ assert.equal(error, 'DuplicateAnalysisTask');
</ins><span class="cx"> });
</span><span class="cx"> }).then(() => {
</span><span class="cx"> return db.selectAll('analysis_tasks');
</span></span></pre></div>
<a id="trunkWebsitesperfwebkitorgservertestsprivilegedapicreatetestgrouptestsjs"></a>
<div class="modfile"><h4>Modified: trunk/Websites/perf.webkit.org/server-tests/privileged-api-create-test-group-tests.js (214007 => 214008)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/server-tests/privileged-api-create-test-group-tests.js        2017-03-15 21:47:11 UTC (rev 214007)
+++ trunk/Websites/perf.webkit.org/server-tests/privileged-api-create-test-group-tests.js        2017-03-15 21:59:12 UTC (rev 214008)
</span><span class="lines">@@ -116,8 +116,8 @@
</span><span class="cx"> it('should return "InvalidName" on an empty request', () => {
</span><span class="cx"> return PrivilegedAPI.sendRequest('create-test-group', {}).then((content) => {
</span><span class="cx"> assert(false, 'should never be reached');
</span><del>- }, (response) => {
- assert.equal(response['status'], 'InvalidName');
</del><ins>+ }, (error) => {
+ assert.equal(error, 'InvalidName');
</ins><span class="cx"> });
</span><span class="cx"> });
</span><span class="cx">
</span><span class="lines">@@ -124,8 +124,8 @@
</span><span class="cx"> it('should return "InvalidTask" when task is not specified', () => {
</span><span class="cx"> return PrivilegedAPI.sendRequest('create-test-group', {name: 'test', commitSets: [[1]]}).then((content) => {
</span><span class="cx"> assert(false, 'should never be reached');
</span><del>- }, (response) => {
- assert.equal(response['status'], 'InvalidTask');
</del><ins>+ }, (error) => {
+ assert.equal(error, 'InvalidTask');
</ins><span class="cx"> });
</span><span class="cx"> });
</span><span class="cx">
</span><span class="lines">@@ -132,8 +132,8 @@
</span><span class="cx"> it('should return "InvalidTask" when task is not a valid integer', () => {
</span><span class="cx"> return PrivilegedAPI.sendRequest('create-test-group', {name: 'test', task: 'foo', commitSets: [[1]]}).then((content) => {
</span><span class="cx"> assert(false, 'should never be reached');
</span><del>- }, (response) => {
- assert.equal(response['status'], 'InvalidTask');
</del><ins>+ }, (error) => {
+ assert.equal(error, 'InvalidTask');
</ins><span class="cx"> });
</span><span class="cx"> });
</span><span class="cx">
</span><span class="lines">@@ -140,8 +140,8 @@
</span><span class="cx"> it('should return "InvalidCommitSets" when commit sets are not specified', () => {
</span><span class="cx"> return PrivilegedAPI.sendRequest('create-test-group', {name: 'test', task: 1, repetitionCount: 1}).then((content) => {
</span><span class="cx"> assert(false, 'should never be reached');
</span><del>- }, (response) => {
- assert.equal(response['status'], 'InvalidCommitSets');
</del><ins>+ }, (error) => {
+ assert.equal(error, 'InvalidCommitSets');
</ins><span class="cx"> });
</span><span class="cx"> });
</span><span class="cx">
</span><span class="lines">@@ -148,8 +148,8 @@
</span><span class="cx"> it('should return "InvalidCommitSets" when commit sets is empty', () => {
</span><span class="cx"> return PrivilegedAPI.sendRequest('create-test-group', {name: 'test', task: 1, repetitionCount: 1, commitSets: {}}).then((content) => {
</span><span class="cx"> assert(false, 'should never be reached');
</span><del>- }, (response) => {
- assert.equal(response['status'], 'InvalidCommitSets');
</del><ins>+ }, (error) => {
+ assert.equal(error, 'InvalidCommitSets');
</ins><span class="cx"> });
</span><span class="cx"> });
</span><span class="cx">
</span><span class="lines">@@ -156,8 +156,8 @@
</span><span class="cx"> it('should return "InvalidTask" when there is no matching task', () => {
</span><span class="cx"> return PrivilegedAPI.sendRequest('create-test-group', {name: 'test', task: 1, repetitionCount: 1, commitSets: {'WebKit': []}}).then((content) => {
</span><span class="cx"> assert(false, 'should never be reached');
</span><del>- }, (response) => {
- assert.equal(response['status'], 'InvalidTask');
</del><ins>+ }, (error) => {
+ assert.equal(error, 'InvalidTask');
</ins><span class="cx"> });
</span><span class="cx"> });
</span><span class="cx">
</span><span class="lines">@@ -164,8 +164,8 @@
</span><span class="cx"> it('should return "InvalidRepetitionCount" when repetitionCount is not a valid integer', () => {
</span><span class="cx"> return PrivilegedAPI.sendRequest('create-test-group', {name: 'test', task: 1, repetitionCount: 'foo', commitSets: {'WebKit': []}}).then((content) => {
</span><span class="cx"> assert(false, 'should never be reached');
</span><del>- }, (response) => {
- assert.equal(response['status'], 'InvalidRepetitionCount');
</del><ins>+ }, (error) => {
+ assert.equal(error, 'InvalidRepetitionCount');
</ins><span class="cx"> });
</span><span class="cx"> });
</span><span class="cx">
</span><span class="lines">@@ -172,8 +172,8 @@
</span><span class="cx"> it('should return "InvalidRepetitionCount" when repetitionCount is a negative integer', () => {
</span><span class="cx"> return PrivilegedAPI.sendRequest('create-test-group', {name: 'test', task: 1, repetitionCount: -5, commitSets: {'WebKit': []}}).then((content) => {
</span><span class="cx"> assert(false, 'should never be reached');
</span><del>- }, (response) => {
- assert.equal(response['status'], 'InvalidRepetitionCount');
</del><ins>+ }, (error) => {
+ assert.equal(error, 'InvalidRepetitionCount');
</ins><span class="cx"> });
</span><span class="cx"> });
</span><span class="cx">
</span><span class="lines">@@ -180,8 +180,8 @@
</span><span class="cx"> it('should return "InvalidTask" when there is no matching task', () => {
</span><span class="cx"> return PrivilegedAPI.sendRequest('create-test-group', {name: 'test', task: 1, commitSets: {'WebKit': []}}).then((content) => {
</span><span class="cx"> assert(false, 'should never be reached');
</span><del>- }, (response) => {
- assert.equal(response['status'], 'InvalidTask');
</del><ins>+ }, (error) => {
+ assert.equal(error, 'InvalidTask');
</ins><span class="cx"> });
</span><span class="cx"> });
</span><span class="cx">
</span><span class="lines">@@ -189,8 +189,8 @@
</span><span class="cx"> return createAnalysisTask('some task').then((taskId) => {
</span><span class="cx"> return PrivilegedAPI.sendRequest('create-test-group', {name: 'test', task: taskId, commitSets: {'WebKit': []}}).then((content) => {
</span><span class="cx"> assert(false, 'should never be reached');
</span><del>- }, (response) => {
- assert.equal(response['status'], 'TriggerableNotFoundForTask');
</del><ins>+ }, (error) => {
+ assert.equal(error, 'TriggerableNotFoundForTask');
</ins><span class="cx"> });
</span><span class="cx"> });
</span><span class="cx"> });
</span><span class="lines">@@ -199,8 +199,8 @@
</span><span class="cx"> return addTriggerableAndCreateTask('some task').then((taskId) => {
</span><span class="cx"> return PrivilegedAPI.sendRequest('create-test-group', {name: 'test', task: taskId, commitSets: {'WebKit': []}}).then((content) => {
</span><span class="cx"> assert(false, 'should never be reached');
</span><del>- }, (response) => {
- assert.equal(response['status'], 'InvalidCommitSets');
</del><ins>+ }, (error) => {
+ assert.equal(error, 'InvalidCommitSets');
</ins><span class="cx"> });
</span><span class="cx"> });
</span><span class="cx"> });
</span><span class="lines">@@ -209,8 +209,8 @@
</span><span class="cx"> return addTriggerableAndCreateTask('some task').then((taskId) => {
</span><span class="cx"> return PrivilegedAPI.sendRequest('create-test-group', {name: 'test', task: taskId, commitSets: {'Foo': []}}).then((content) => {
</span><span class="cx"> assert(false, 'should never be reached');
</span><del>- }, (response) => {
- assert.equal(response['status'], 'RepositoryNotFound');
</del><ins>+ }, (error) => {
+ assert.equal(error, 'RepositoryNotFound');
</ins><span class="cx"> });
</span><span class="cx"> });
</span><span class="cx"> });
</span><span class="lines">@@ -219,8 +219,8 @@
</span><span class="cx"> return addTriggerableAndCreateTask('some task').then((taskId) => {
</span><span class="cx"> return PrivilegedAPI.sendRequest('create-test-group', {name: 'test', task: taskId, commitSets: {'WebKit': ['1']}}).then((content) => {
</span><span class="cx"> assert(false, 'should never be reached');
</span><del>- }, (response) => {
- assert.equal(response['status'], 'RevisionNotFound');
</del><ins>+ }, (error) => {
+ assert.equal(error, 'RevisionNotFound');
</ins><span class="cx"> });
</span><span class="cx"> });
</span><span class="cx"> });
</span><span class="lines">@@ -229,8 +229,8 @@
</span><span class="cx"> return addTriggerableAndCreateTask('some task').then((taskId) => {
</span><span class="cx"> return PrivilegedAPI.sendRequest('create-test-group', {name: 'test', task: taskId, commitSets: {'WebKit': ['191622', '191623'], 'macOS': ['15A284']}}).then((content) => {
</span><span class="cx"> assert(false, 'should never be reached');
</span><del>- }, (response) => {
- assert.equal(response['status'], 'InvalidCommitSets');
</del><ins>+ }, (error) => {
+ assert.equal(error, 'InvalidCommitSets');
</ins><span class="cx"> });
</span><span class="cx"> });
</span><span class="cx"> });
</span></span></pre></div>
<a id="trunkWebsitesperfwebkitorgservertestsprivilegedapiupaterunstatusjs"></a>
<div class="modfile"><h4>Modified: trunk/Websites/perf.webkit.org/server-tests/privileged-api-upate-run-status.js (214007 => 214008)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/server-tests/privileged-api-upate-run-status.js        2017-03-15 21:47:11 UTC (rev 214007)
+++ trunk/Websites/perf.webkit.org/server-tests/privileged-api-upate-run-status.js        2017-03-15 21:59:12 UTC (rev 214008)
</span><span class="lines">@@ -75,9 +75,9 @@
</span><span class="cx"> RemoteAPI.clearCookies();
</span><span class="cx"> return RemoteAPI.postJSONWithStatus('/privileged-api/update-run-status', {token: PrivilegedAPI._token});
</span><span class="cx"> }).then(() => {
</span><del>- assert(false, 'PrivilegedAPI.sendRequest should reject');
- }, (response) => {
- assert.equal(response['status'], 'InvalidToken');
</del><ins>+ assert(false, 'should never be reached');
+ }, (error) => {
+ assert.equal(error, 'InvalidToken');
</ins><span class="cx"> });
</span><span class="cx"> });
</span><span class="cx">
</span><span class="lines">@@ -94,9 +94,9 @@
</span><span class="cx"> }).then(() => {
</span><span class="cx"> return RemoteAPI.postJSONWithStatus('/privileged-api/update-run-status', {token: 'bad'});
</span><span class="cx"> }).then(() => {
</span><del>- assert(false, 'PrivilegedAPI.sendRequest should reject');
- }, (response) => {
- assert.equal(response['status'], 'InvalidToken');
</del><ins>+ assert(false, 'should never be reached');
+ }, (error) => {
+ assert.equal(error, 'InvalidToken');
</ins><span class="cx"> });
</span><span class="cx"> });
</span><span class="cx">
</span></span></pre></div>
<a id="trunkWebsitesperfwebkitorgtoolsjsbuildbottriggerablejs"></a>
<div class="modfile"><h4>Modified: trunk/Websites/perf.webkit.org/tools/js/buildbot-triggerable.js (214007 => 214008)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/tools/js/buildbot-triggerable.js        2017-03-15 21:47:11 UTC (rev 214007)
+++ trunk/Websites/perf.webkit.org/tools/js/buildbot-triggerable.js        2017-03-15 21:59:12 UTC (rev 214008)
</span><span class="lines">@@ -69,14 +69,11 @@
</span><span class="cx"> return self._pullBuildbotOnAllSyncers(buildReqeustsByGroup);
</span><span class="cx"> }).then(function (updates) {
</span><span class="cx"> // FIXME: Add a new API that just updates the requests.
</span><del>- return self._remote.postJSON(`/api/build-requests/${self._name}`, {
</del><ins>+ return self._remote.postJSONWithStatus(`/api/build-requests/${self._name}`, {
</ins><span class="cx"> 'slaveName': self._slaveInfo.name,
</span><span class="cx"> 'slavePassword': self._slaveInfo.password,
</span><span class="cx"> 'buildRequestUpdates': updates});
</span><del>- }).then(function (response) {
- if (response['status'] != 'OK')
- self._logger.log('Failed to update the build requests status: ' + response['status']);
- })
</del><ins>+ });
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> _validateRequests(buildRequests)
</span></span></pre></div>
<a id="trunkWebsitesperfwebkitorgtoolsjsremotejs"></a>
<div class="modfile"><h4>Modified: trunk/Websites/perf.webkit.org/tools/js/remote.js (214007 => 214008)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/tools/js/remote.js        2017-03-15 21:47:11 UTC (rev 214007)
+++ trunk/Websites/perf.webkit.org/tools/js/remote.js        2017-03-15 21:59:12 UTC (rev 214008)
</span><span class="lines">@@ -4,10 +4,12 @@
</span><span class="cx"> let http = require('http');
</span><span class="cx"> let https = require('https');
</span><span class="cx"> let querystring = require('querystring');
</span><ins>+let CommonRemoteAPI = require('../../public/shared/common-remote.js').CommonRemoteAPI;
</ins><span class="cx">
</span><del>-class RemoteAPI {
</del><ins>+class NodeRemoteAPI extends CommonRemoteAPI {
</ins><span class="cx"> constructor(server)
</span><span class="cx"> {
</span><ins>+ super();
</ins><span class="cx"> this._server = null;
</span><span class="cx"> this._cookies = new Map;
</span><span class="cx"> if (server)
</span><span class="lines">@@ -53,50 +55,6 @@
</span><span class="cx">
</span><span class="cx"> clearCookies() { this._cookies = new Map; }
</span><span class="cx">
</span><del>- getJSON(path)
- {
- return this.sendHttpRequest(path, 'GET', null, null).then(function (result) {
- try {
- return JSON.parse(result.responseText);
- } catch (error) {
- console.error(result.responseText);
- throw error;
- }
- });
- }
-
- getJSONWithStatus(path)
- {
- return this.getJSON(path).then(function (result) {
- if (result['status'] != 'OK')
- return Promise.reject(result);
- return result;
- });
- }
-
- postJSON(path, data)
- {
- const contentType = 'application/json';
- const payload = JSON.stringify(data || {});
- return this.sendHttpRequest(path, 'POST', 'application/json', payload).then(function (result) {
- try {
- return JSON.parse(result.responseText);
- } catch (error) {
- console.error(result.responseText);
- throw error;
- }
- });
- }
-
- postJSONWithStatus(path, data)
- {
- return this.postJSON(path, data).then(function (result) {
- if (result['status'] != 'OK')
- return Promise.reject(result);
- return result;
- });
- }
-
</del><span class="cx"> postFormUrlencodedData(path, data)
</span><span class="cx"> {
</span><span class="cx"> const contentType = 'application/x-www-form-urlencoded';
</span><span class="lines">@@ -109,8 +67,7 @@
</span><span class="cx"> sendHttpRequest(path, method, contentType, content)
</span><span class="cx"> {
</span><span class="cx"> let server = this._server;
</span><del>- const self = this;
- return new Promise(function (resolve, reject) {
</del><ins>+ return new Promise((resolve, reject) => {
</ins><span class="cx"> let options = {
</span><span class="cx"> hostname: server.host,
</span><span class="cx"> port: server.port,
</span><span class="lines">@@ -119,20 +76,18 @@
</span><span class="cx"> path: path,
</span><span class="cx"> };
</span><span class="cx">
</span><del>- let request = (server.scheme == 'http' ? http : https).request(options, function (response) {
</del><ins>+ let request = (server.scheme == 'http' ? http : https).request(options, (response) => {
</ins><span class="cx"> let responseText = '';
</span><span class="cx"> response.setEncoding('utf8');
</span><del>- response.on('data', function (chunk) { responseText += chunk; });
- response.on('end', function () {
- if (response.statusCode != 200) {
- reject(response.statusCode);
- return;
- }
</del><ins>+ response.on('data', (chunk) => { responseText += chunk; });
+ response.on('end', () => {
+ if (response.statusCode != 200)
+ return reject(response.statusCode);
</ins><span class="cx">
</span><span class="cx"> if ('set-cookie' in response.headers) {
</span><del>- for (const cookie of response.headers['set-cookie']) {
- var nameValue = cookie.split('=')
- self._cookies.set(nameValue[0], nameValue[1]);
</del><ins>+ for (let cookie of response.headers['set-cookie']) {
+ const nameValue = cookie.split('=');
+ this._cookies.set(nameValue[0], nameValue[1]);
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> resolve({statusCode: response.statusCode, responseText: responseText});
</span><span class="lines">@@ -144,11 +99,8 @@
</span><span class="cx"> if (contentType)
</span><span class="cx"> request.setHeader('Content-Type', contentType);
</span><span class="cx">
</span><del>- if (self._cookies.size) {
- request.setHeader('Cookie', Array.from(self._cookies.keys()).map(function (key) {
- return `${key}=${self._cookies.get(key)}`;
- }).join('; '));
- }
</del><ins>+ if (this._cookies.size)
+ request.setHeader('Cookie', Array.from(this._cookies.keys()).map((key) => `${key}=${this._cookies.get(key)}`).join('; '));
</ins><span class="cx">
</span><span class="cx"> if (content)
</span><span class="cx"> request.write(content);
</span><span class="lines">@@ -159,4 +111,4 @@
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> if (typeof module != 'undefined')
</span><del>- module.exports.RemoteAPI = RemoteAPI;
</del><ins>+ module.exports.RemoteAPI = NodeRemoteAPI;
</ins></span></pre>
</div>
</div>
</body>
</html>