<!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>[200449] 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/200449">200449</a></dd>
<dt>Author</dt> <dd>dewei_zhu@apple.com</dd>
<dt>Date</dt> <dd>2016-05-04 22:27:18 -0700 (Wed, 04 May 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Summary page should show warnings when current or baseline data is missing.
https://bugs.webkit.org/show_bug.cgi?id=157339

Reviewed by Ryosuke Niwa.

Set summary page to be the default page of v3 UI.
Show warning icon when either baseline or current data is missing.
Make fetchBetween returns a promise.
Update unit tests for MeasurementSet.fetchBetween since it returns a promise now.
Add a workaround to skip some platform and metric configurations.

* public/v3/components/ratio-bar-graph.js:
(RatioBarGraph):
(RatioBarGraph.prototype.update): Add showWarningIcon flag to indicate whether we should show warning icon.
(RatioBarGraph.prototype.render): Show warning icon when showWarningIcon is true.
(RatioBarGraph.cssTemplate): Add style for warning icon.
* public/v3/components/warning-icon.js: Add warning icon.
(WarningIcon):
(WarningIcon.cssTemplate):
* public/v3/index.html:
* public/v3/main.js:
(main): Set summary page to be the default page of v3 UI.
* public/v3/models/measurement-set.js:
(MeasurementSet):
(MeasurementSet.prototype.fetchBetween): Returns a promise. Fix the bug in previous implementation that we miss
some callbacks sometimes. Basically, we will fetch primary cluster first, then secondary clusters. For each
secondary cluster fetch, we will always invoke callback even when it fails.
(MeasurementSet.prototype._fetchSecondaryClusters): Deleted.
(MeasurementSet.prototype._fetch.else.url.api.measurement.set platform): Deleted.
* public/v3/pages/summary-page.js:
(SummaryPage): Add a variable for excluded configurations.
(SummaryPage.prototype._createConfigurationGroup): Pass excluded configurations while building config groups.
(SummaryPage.prototype._constructTable): Remove the logic for unified header since it breaks consistency of the table appearance.
(SummaryPage.prototype.this._renderQueue.push): Show warning message when baseline/current data is missing.
(SummaryPageConfigurationGroup): Add a variable to keep track of the warnings while computing summary.
(SummaryPageConfigurationGroup.prototype.warnings): A getter for warnings.
(SummaryPageConfigurationGroup._computeSummary): Fix a bug in calculating ratios. We should always use
current/baseline for ratio and present the difference between ratio and 1 in the summary page.
(SummaryPageConfigurationGroup.set then): Deleted.
(SummaryPageConfigurationGroup.set var): Deleted.
* unit-tests/measurement-set-tests.js: Add a helper function to wait for fetchBetween. Update unit tests since fetchBetween returns a promise now.
(promise.set fetchBetween):
(set MeasurementSet):
(set fetchBetween): Deleted.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkWebsitesperfwebkitorgChangeLog">trunk/Websites/perf.webkit.org/ChangeLog</a></li>
<li><a href="#trunkWebsitesperfwebkitorgpublicv3componentsratiobargraphjs">trunk/Websites/perf.webkit.org/public/v3/components/ratio-bar-graph.js</a></li>
<li><a href="#trunkWebsitesperfwebkitorgpublicv3indexhtml">trunk/Websites/perf.webkit.org/public/v3/index.html</a></li>
<li><a href="#trunkWebsitesperfwebkitorgpublicv3mainjs">trunk/Websites/perf.webkit.org/public/v3/main.js</a></li>
<li><a href="#trunkWebsitesperfwebkitorgpublicv3modelsmeasurementsetjs">trunk/Websites/perf.webkit.org/public/v3/models/measurement-set.js</a></li>
<li><a href="#trunkWebsitesperfwebkitorgpublicv3pagessummarypagejs">trunk/Websites/perf.webkit.org/public/v3/pages/summary-page.js</a></li>
<li><a href="#trunkWebsitesperfwebkitorgunittestsmeasurementsettestsjs">trunk/Websites/perf.webkit.org/unit-tests/measurement-set-tests.js</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkWebsitesperfwebkitorgpublicv3componentswarningiconjs">trunk/Websites/perf.webkit.org/public/v3/components/warning-icon.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 (200448 => 200449)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/ChangeLog        2016-05-05 03:09:41 UTC (rev 200448)
+++ trunk/Websites/perf.webkit.org/ChangeLog        2016-05-05 05:27:18 UTC (rev 200449)
</span><span class="lines">@@ -1,3 +1,50 @@
</span><ins>+2016-05-04  Dewei Zhu  &lt;dewei_zhu@apple.com&gt;
+
+        Summary page should show warnings when current or baseline data is missing.
+        https://bugs.webkit.org/show_bug.cgi?id=157339
+
+        Reviewed by Ryosuke Niwa.
+
+        Set summary page to be the default page of v3 UI.
+        Show warning icon when either baseline or current data is missing.
+        Make fetchBetween returns a promise.
+        Update unit tests for MeasurementSet.fetchBetween since it returns a promise now.
+        Add a workaround to skip some platform and metric configurations.
+
+        * public/v3/components/ratio-bar-graph.js:
+        (RatioBarGraph):
+        (RatioBarGraph.prototype.update): Add showWarningIcon flag to indicate whether we should show warning icon.
+        (RatioBarGraph.prototype.render): Show warning icon when showWarningIcon is true.
+        (RatioBarGraph.cssTemplate): Add style for warning icon.
+        * public/v3/components/warning-icon.js: Add warning icon.
+        (WarningIcon):
+        (WarningIcon.cssTemplate):
+        * public/v3/index.html:
+        * public/v3/main.js:
+        (main): Set summary page to be the default page of v3 UI.
+        * public/v3/models/measurement-set.js:
+        (MeasurementSet):
+        (MeasurementSet.prototype.fetchBetween): Returns a promise. Fix the bug in previous implementation that we miss
+        some callbacks sometimes. Basically, we will fetch primary cluster first, then secondary clusters. For each
+        secondary cluster fetch, we will always invoke callback even when it fails.
+        (MeasurementSet.prototype._fetchSecondaryClusters): Deleted.
+        (MeasurementSet.prototype._fetch.else.url.api.measurement.set platform): Deleted.
+        * public/v3/pages/summary-page.js:
+        (SummaryPage): Add a variable for excluded configurations.
+        (SummaryPage.prototype._createConfigurationGroup): Pass excluded configurations while building config groups.
+        (SummaryPage.prototype._constructTable): Remove the logic for unified header since it breaks consistency of the table appearance.
+        (SummaryPage.prototype.this._renderQueue.push): Show warning message when baseline/current data is missing.
+        (SummaryPageConfigurationGroup): Add a variable to keep track of the warnings while computing summary.
+        (SummaryPageConfigurationGroup.prototype.warnings): A getter for warnings.
+        (SummaryPageConfigurationGroup._computeSummary): Fix a bug in calculating ratios. We should always use
+        current/baseline for ratio and present the difference between ratio and 1 in the summary page.
+        (SummaryPageConfigurationGroup.set then): Deleted.
+        (SummaryPageConfigurationGroup.set var): Deleted.
+        * unit-tests/measurement-set-tests.js: Add a helper function to wait for fetchBetween. Update unit tests since fetchBetween returns a promise now.
+        (promise.set fetchBetween):
+        (set MeasurementSet):
+        (set fetchBetween): Deleted.
+
</ins><span class="cx"> 2016-04-26  Ryosuke Niwa  &lt;rniwa@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Chart status should always be computed against prior values
</span></span></pre></div>
<a id="trunkWebsitesperfwebkitorgpublicv3componentsratiobargraphjs"></a>
<div class="modfile"><h4>Modified: trunk/Websites/perf.webkit.org/public/v3/components/ratio-bar-graph.js (200448 => 200449)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/public/v3/components/ratio-bar-graph.js        2016-05-05 03:09:41 UTC (rev 200448)
+++ trunk/Websites/perf.webkit.org/public/v3/components/ratio-bar-graph.js        2016-05-05 05:27:18 UTC (rev 200449)
</span><span class="lines">@@ -3,18 +3,18 @@
</span><span class="cx">     constructor()
</span><span class="cx">     {
</span><span class="cx">         super('ratio-bar-graph');
</span><del>-        this._ratio = 0;
</del><ins>+        this._ratio = null;
</ins><span class="cx">         this._label = null;
</span><span class="cx">         this._shouldRender = true;
</span><del>-        this._bar = this.content().querySelector('.bar');
-        this._labelContainer = this.content().querySelector('.label');
</del><ins>+        this._ratioBarGraph = this.content().querySelector('.ratio-bar-graph');
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    update(ratio, label)
</del><ins>+    update(ratio, label, showWarningIcon)
</ins><span class="cx">     {
</span><del>-        console.assert(ratio &gt;= -1 &amp;&amp; ratio &lt;= 1);
</del><ins>+        console.assert(isNaN(ratio) || (ratio &gt;= -1 &amp;&amp; ratio &lt;= 1));
</ins><span class="cx">         this._ratio = ratio;
</span><span class="cx">         this._label = label;
</span><ins>+        this._showWarningIcon = showWarningIcon;
</ins><span class="cx">         this._shouldRender = true;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -22,18 +22,35 @@
</span><span class="cx">     {
</span><span class="cx">         if (!this._shouldRender)
</span><span class="cx">             return;
</span><ins>+        this._shouldRender = false;
+        var element = ComponentBase.createElement;
</ins><span class="cx"> 
</span><del>-        var percent = Math.abs(this._ratio * 100);
-        this._labelContainer.textContent = this._label;
-        this._bar.style.width = Math.min(percent, 50) + '%';
-        this._bar.parentNode.className = 'ratio-bar-graph ' + (this._ratio &gt; 0 ? 'better' : 'worse');
</del><ins>+        var children = [element('div', {class: 'separator'})];
+        if (this._showWarningIcon) {
+            if (this._ratio &amp;&amp; this._ratio &lt; -0.4)
+                this._ratioBarGraph.classList.add('warning-on-right');
+            else
+                this._ratioBarGraph.classList.remove('warning-on-right');
+            children.push(new WarningIcon);
+        }
</ins><span class="cx"> 
</span><del>-        this._shouldRender = false;
</del><ins>+        var barClassName = 'bar';
+        var labelClassName = 'label';
+        if (this._ratio) {
+            var ratioType = this._ratio &gt; 0 ? 'better' : 'worse';
+            barClassName = [barClassName, ratioType].join(' ');
+            labelClassName = [labelClassName, ratioType].join(' ');
+            children.push(element('div', {class: barClassName, style: 'width:' + Math.min(Math.abs(this._ratio * 100), 50) + '%'}));
+        }
+        if (this._label)
+            children.push(element('div', {class: labelClassName}, this._label));
+
+        this.renderReplace(this._ratioBarGraph, children);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     static htmlTemplate()
</span><span class="cx">     {
</span><del>-        return `&lt;div class=&quot;ratio-bar-graph&quot;&gt;&lt;div class=&quot;seperator&quot;&gt;&lt;/div&gt;&lt;div class=&quot;bar&quot;&gt;&lt;/div&gt;&lt;div class=&quot;label&quot;&gt;&lt;/div&gt;&lt;/div&gt;`;
</del><ins>+        return `&lt;div class=&quot;ratio-bar-graph&quot;&gt;&lt;/div&gt;`;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     static cssTemplate()
</span><span class="lines">@@ -50,8 +67,20 @@
</span><span class="cx">                 text-decoration: none;
</span><span class="cx">                 color: black;
</span><span class="cx">             }
</span><del>-            .ratio-bar-graph .seperator {
</del><ins>+            .ratio-bar-graph warning-icon {
</ins><span class="cx">                 position: absolute;
</span><ins>+                display: block;
+                top: 0;
+            }
+            .ratio-bar-graph:not(.warning-on-right) warning-icon {
+                left: 0;
+            }
+            .ratio-bar-graph.warning-on-right warning-icon {
+                transform: scaleX(-1);
+                right: 0;
+            }
+            .ratio-bar-graph .separator {
+                position: absolute;
</ins><span class="cx">                 left: 50%;
</span><span class="cx">                 width: 0px;
</span><span class="cx">                 height: 100%;
</span><span class="lines">@@ -64,22 +93,22 @@
</span><span class="cx">                 height: calc(100% - 1rem);
</span><span class="cx">                 background: #ccc;
</span><span class="cx">             }
</span><del>-            .ratio-bar-graph.worse .bar {
</del><ins>+            .ratio-bar-graph .bar.worse {
</ins><span class="cx">                 transform: translateX(-100%);
</span><span class="cx">                 background: #c33;
</span><span class="cx">             }
</span><del>-            .ratio-bar-graph.better .bar {
</del><ins>+            .ratio-bar-graph .bar.better {
</ins><span class="cx">                 background: #3c3;
</span><span class="cx">             }
</span><span class="cx">             .ratio-bar-graph .label {
</span><span class="cx">                 position: absolute;
</span><span class="cx">                 line-height: 2.5rem;
</span><span class="cx">             }
</span><del>-            .ratio-bar-graph.worse .label {
</del><ins>+            .ratio-bar-graph .label.worse {
</ins><span class="cx">                 text-align: left;
</span><span class="cx">                 left: calc(50% + 0.2rem);
</span><span class="cx">             }
</span><del>-            .ratio-bar-graph.better .label {
</del><ins>+            .ratio-bar-graph .label.better {
</ins><span class="cx">                 text-align: right;
</span><span class="cx">                 right: calc(50% + 0.2rem);
</span><span class="cx">             }
</span></span></pre></div>
<a id="trunkWebsitesperfwebkitorgpublicv3componentswarningiconjs"></a>
<div class="addfile"><h4>Added: trunk/Websites/perf.webkit.org/public/v3/components/warning-icon.js (0 => 200449)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/public/v3/components/warning-icon.js                                (rev 0)
+++ trunk/Websites/perf.webkit.org/public/v3/components/warning-icon.js        2016-05-05 05:27:18 UTC (rev 200449)
</span><span class="lines">@@ -0,0 +1,33 @@
</span><ins>+
+class WarningIcon extends ButtonBase {
+    constructor()
+    {
+        super('warning-icon');
+    }
+
+    static cssTemplate()
+    {
+        return super.cssTemplate() + `
+            .button {
+                display: block;
+                width: 0.7rem;
+                height: 0.7rem;
+            }
+            .button svg {
+                display: block;
+            }
+        `;
+    }
+
+    static htmlTemplate()
+    {
+        return `&lt;a class=&quot;button&quot; href=&quot;#&quot;&gt;&lt;svg viewBox=&quot;0 0 100 100&quot;&gt;
+            &lt;g stroke=&quot;#9f6000&quot; fill=&quot;#9f6000&quot; stroke-width=&quot;7&quot;&gt;
+                &lt;polygon points=&quot;0,0, 100,0, 0,100&quot; /&gt;
+            &lt;/g&gt;
+        &lt;/svg&gt;&lt;/a&gt;`;
+    }
+
+}
+
+ComponentBase.defineElement('warning-icon', WarningIcon);
</ins></span></pre></div>
<a id="trunkWebsitesperfwebkitorgpublicv3indexhtml"></a>
<div class="modfile"><h4>Modified: trunk/Websites/perf.webkit.org/public/v3/index.html (200448 => 200449)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/public/v3/index.html        2016-05-05 03:09:41 UTC (rev 200448)
+++ trunk/Websites/perf.webkit.org/public/v3/index.html        2016-05-05 05:27:18 UTC (rev 200449)
</span><span class="lines">@@ -66,6 +66,7 @@
</span><span class="cx">         &lt;script src=&quot;components/base.js&quot;&gt;&lt;/script&gt;
</span><span class="cx">         &lt;script src=&quot;components/spinner-icon.js&quot;&gt;&lt;/script&gt;
</span><span class="cx">         &lt;script src=&quot;components/button-base.js&quot;&gt;&lt;/script&gt;
</span><ins>+        &lt;script src=&quot;components/warning-icon.js&quot;&gt;&lt;/script&gt;
</ins><span class="cx">         &lt;script src=&quot;components/close-button.js&quot;&gt;&lt;/script&gt;
</span><span class="cx">         &lt;script src=&quot;components/commit-log-viewer.js&quot;&gt;&lt;/script&gt;
</span><span class="cx">         &lt;script src=&quot;components/editable-text.js&quot;&gt;&lt;/script&gt;
</span></span></pre></div>
<a id="trunkWebsitesperfwebkitorgpublicv3mainjs"></a>
<div class="modfile"><h4>Modified: trunk/Websites/perf.webkit.org/public/v3/main.js (200448 => 200449)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/public/v3/main.js        2016-05-05 03:09:41 UTC (rev 200448)
+++ trunk/Websites/perf.webkit.org/public/v3/main.js        2016-05-05 05:27:18 UTC (rev 200449)
</span><span class="lines">@@ -20,7 +20,7 @@
</span><span class="cx">         var router = new PageRouter();
</span><span class="cx">         var chartsToolbar = new ChartsToolbar;
</span><span class="cx"> 
</span><del>-        var summaryPage = new SummaryPage(manifest.summary);
</del><ins>+        var summaryPage = manifest.summary ? new SummaryPage(manifest.summary) : null;
</ins><span class="cx">         var chartsPage = new ChartsPage(chartsToolbar);
</span><span class="cx">         var analysisCategoryPage = new AnalysisCategoryPage();
</span><span class="cx"> 
</span><span class="lines">@@ -31,13 +31,14 @@
</span><span class="cx">         analysisTaskPage.setParentPage(analysisCategoryPage);
</span><span class="cx"> 
</span><span class="cx">         var heading = new Heading(manifest.siteTitle);
</span><del>-        heading.addPageGroup([summaryPage, chartsPage, analysisCategoryPage]);
</del><ins>+        heading.addPageGroup([summaryPage, chartsPage, analysisCategoryPage].filter(function (page) { return page; }));
</ins><span class="cx"> 
</span><span class="cx">         heading.setTitle(manifest.siteTitle);
</span><span class="cx">         heading.addPageGroup(dashboardPages);
</span><span class="cx"> 
</span><span class="cx">         var router = new PageRouter();
</span><del>-        router.addPage(summaryPage);
</del><ins>+        if(summaryPage)
+            router.addPage(summaryPage);
</ins><span class="cx">         router.addPage(chartsPage);
</span><span class="cx">         router.addPage(createAnalysisTaskPage);
</span><span class="cx">         router.addPage(analysisTaskPage);
</span><span class="lines">@@ -45,7 +46,9 @@
</span><span class="cx">         for (var page of dashboardPages)
</span><span class="cx">             router.addPage(page);
</span><span class="cx"> 
</span><del>-        if (dashboardPages)
</del><ins>+        if (summaryPage)
+            router.setDefaultPage(summaryPage);
+        else if (dashboardPages)
</ins><span class="cx">             router.setDefaultPage(dashboardPages[0]);
</span><span class="cx">         else
</span><span class="cx">             router.setDefaultPage(chartsPage);
</span></span></pre></div>
<a id="trunkWebsitesperfwebkitorgpublicv3modelsmeasurementsetjs"></a>
<div class="modfile"><h4>Modified: trunk/Websites/perf.webkit.org/public/v3/models/measurement-set.js (200448 => 200449)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/public/v3/models/measurement-set.js        2016-05-05 03:09:41 UTC (rev 200448)
+++ trunk/Websites/perf.webkit.org/public/v3/models/measurement-set.js        2016-05-05 05:27:18 UTC (rev 200449)
</span><span class="lines">@@ -10,17 +10,17 @@
</span><span class="cx">         this._metricId = metricId;
</span><span class="cx">         this._lastModified = +lastModified;
</span><span class="cx"> 
</span><del>-        this._waitingForPrimaryCluster = null;
-        this._fetchedPrimary = false;
-        this._endTimeToCallback = {};
-
</del><span class="cx">         this._sortedClusters = [];
</span><span class="cx">         this._primaryClusterEndTime = null;
</span><span class="cx">         this._clusterCount = null;
</span><span class="cx">         this._clusterStart = null;
</span><span class="cx">         this._clusterSize = null;
</span><ins>+        this._allFetches = {};
+        this._primaryClusterPromise = null;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    platformId() { return this._platformId; }
+
</ins><span class="cx">     static findSet(platformId, metricId, lastModified)
</span><span class="cx">     {
</span><span class="cx">         if (!this._set)
</span><span class="lines">@@ -35,7 +35,6 @@
</span><span class="cx">     {
</span><span class="cx">         var clusterStart = this._clusterStart;
</span><span class="cx">         var clusterSize = this._clusterSize;
</span><del>-        console.assert(clusterStart &amp;&amp; clusterSize);
</del><span class="cx"> 
</span><span class="cx">         function computeClusterStart(time) {
</span><span class="cx">             var diff = time - clusterStart;
</span><span class="lines">@@ -58,87 +57,61 @@
</span><span class="cx"> 
</span><span class="cx">     fetchBetween(startTime, endTime, callback)
</span><span class="cx">     {
</span><del>-        if (!this._fetchedPrimary) {
-            var primaryFetchHadFailed = this._waitingForPrimaryCluster === false;
-            if (primaryFetchHadFailed) {
-                callback();
-                return;
-            }
-
-            var shouldStartPrimaryFetch = !this._waitingForPrimaryCluster;
-            if (shouldStartPrimaryFetch)
-                this._waitingForPrimaryCluster = [];
-
-            this._waitingForPrimaryCluster.push({startTime: startTime, endTime: endTime, callback: callback});
-
-            if (shouldStartPrimaryFetch)
-                this._fetch(null, true);
-
-            return;
-        }
-
-        this._fetchSecondaryClusters(startTime, endTime, callback);
</del><ins>+        if (!this._primaryClusterPromise)
+            this._primaryClusterPromise = this._fetchPrimaryCluster();
+        var self = this;
+        this._primaryClusterPromise.catch(callback);
+        return this._primaryClusterPromise.then(function () {
+            var promiseList = [];
+            self.findClusters(startTime, endTime).map(function (clusterEndTime) {
+                if(!self._allFetches[clusterEndTime])
+                    self._allFetches[clusterEndTime] = self._fetchSecondaryCluster(clusterEndTime);
+                self._allFetches[clusterEndTime].then(callback, callback);
+                promiseList.push(self._allFetches[clusterEndTime]);
+            });
+            return Promise.all(promiseList);
+        });
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    _fetchSecondaryClusters(startTime, endTime, callback)
</del><ins>+    _constructUrl(useCache, clusterEndTime)
</ins><span class="cx">     {
</span><del>-        console.assert(this._fetchedPrimary);
-        console.assert(this._clusterStart &amp;&amp; this._clusterSize);
-        console.assert(this._sortedClusters.length);
-
-        var clusters = this.findClusters(startTime, endTime);
-        var shouldInvokeCallackNow = false;
-        for (var endTime of clusters) {
-            var isPrimaryCluster = endTime == this._primaryClusterEndTime;
-            var shouldStartFetch = !isPrimaryCluster &amp;&amp; !(endTime in this._endTimeToCallback);
-            if (shouldStartFetch)
-                this._endTimeToCallback[endTime] = [];
-
-            var callbackList = this._endTimeToCallback[endTime];
-            if (isPrimaryCluster || callbackList === true)
-                shouldInvokeCallackNow = true;
-            else if (!callbackList.includes(callback))
-                callbackList.push(callback);
-
-            if (shouldStartFetch)
-                this._fetch(endTime, true);
</del><ins>+        if (!useCache) {
+            return `../api/measurement-set?platform=${this._platformId}&amp;metric=${this._metricId}`;
</ins><span class="cx">         }
</span><del>-
-        if (shouldInvokeCallackNow)
-            callback();
</del><ins>+        var url;
+        url = `../data/measurement-set-${this._platformId}-${this._metricId}`;
+        if (clusterEndTime)
+            url += '-' + +clusterEndTime;
+        url += '.json';
+        return url;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    _fetch(clusterEndTime, useCache)
-    {
-        console.assert(!clusterEndTime || useCache);
-
-        var url;
-        if (useCache) {
-            url = `../data/measurement-set-${this._platformId}-${this._metricId}`;
-            if (clusterEndTime)
-                url += '-' + +clusterEndTime;
-            url += '.json';
-        } else
-            url = `../api/measurement-set?platform=${this._platformId}&amp;metric=${this._metricId}`;
-
</del><ins>+    _fetchPrimaryCluster() {
</ins><span class="cx">         var self = this;
</span><ins>+        return RemoteAPI.getJSONWithStatus(self._constructUrl(true, null)).then(function (data) {
+            if (+data['lastModified'] &lt; self._lastModified)
+                return RemoteAPI.getJSONWithStatus(self._constructUrl(false, null));
+            return data;
+        }).catch(function (error) {
+            if(error == 404)
+                return RemoteAPI.getJSONWithStatus(self._constructUrl(false, null));
+            return Promise.reject(error);
+        }).then(function (data) {
+            self._didFetchJSON(true, data);
+            self._allFetches[self._primaryClusterEndTime] = self._primaryClusterPromise;
+        });
+    }
</ins><span class="cx"> 
</span><del>-        return RemoteAPI.getJSONWithStatus(url).then(function (data) {
-            if (!clusterEndTime &amp;&amp; useCache &amp;&amp; +data['lastModified'] &lt; self._lastModified)
-                self._fetch(clusterEndTime, false);
-            else
-                self._didFetchJSON(!clusterEndTime, data);
-        }, function (error, xhr) {
-            if (!clusterEndTime &amp;&amp; error == 404 &amp;&amp; useCache)
-                self._fetch(clusterEndTime, false);
-            else
-                self._failedToFetchJSON(clusterEndTime, error);
</del><ins>+    _fetchSecondaryCluster(endTime) {
+        var self = this;
+        return RemoteAPI.getJSONWithStatus(self._constructUrl(true, endTime)).then(function (data) {
+            self._didFetchJSON(false, data);
</ins><span class="cx">         });
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     _didFetchJSON(isPrimaryCluster, response, clusterEndTime)
</span><span class="cx">     {
</span><del>-        console.assert(isPrimaryCluster || this._fetchedPrimary);
</del><ins>+        console.assert(isPrimaryCluster);
</ins><span class="cx"> 
</span><span class="cx">         if (isPrimaryCluster) {
</span><span class="cx">             this._primaryClusterEndTime = response['endTime'];
</span><span class="lines">@@ -149,42 +122,8 @@
</span><span class="cx">             console.assert(this._primaryClusterEndTime);
</span><span class="cx"> 
</span><span class="cx">         this._addFetchedCluster(new MeasurementCluster(response));
</span><del>-
-        console.assert(this._waitingForPrimaryCluster);
-        if (!isPrimaryCluster) {
-            this._invokeCallbacks(response.endTime);
-            return;
-        }
-        console.assert(this._waitingForPrimaryCluster instanceof Array);
-
-        this._fetchedPrimary = true;
-        for (var entry of this._waitingForPrimaryCluster)
-            this._fetchSecondaryClusters(entry.startTime, entry.endTime, entry.callback);
-        this._waitingForPrimaryCluster = true;
</del><span class="cx">     }
</span><span class="cx"> 
</span><del>-    _failedToFetchJSON(clusterEndTime, error)
-    {
-        if (clusterEndTime) {
-            this._invokeCallbacks(clusterEndTime, error || true);
-            return;
-        }
-
-        console.assert(!this._fetchedPrimary);
-        console.assert(this._waitingForPrimaryCluster instanceof Array);
-        for (var entry of this._waitingForPrimaryCluster)
-            entry.callback(error || true);
-        this._waitingForPrimaryCluster = false;
-    }
-
-    _invokeCallbacks(clusterEndTime, error)
-    {
-        var callbackList = this._endTimeToCallback[clusterEndTime];
-        for (var callback of callbackList)
-            callback(error);
-        this._endTimeToCallback[clusterEndTime] = true;
-    }
-
</del><span class="cx">     _addFetchedCluster(cluster)
</span><span class="cx">     {
</span><span class="cx">         this._sortedClusters.push(cluster);
</span></span></pre></div>
<a id="trunkWebsitesperfwebkitorgpublicv3pagessummarypagejs"></a>
<div class="modfile"><h4>Modified: trunk/Websites/perf.webkit.org/public/v3/pages/summary-page.js (200448 => 200449)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/public/v3/pages/summary-page.js        2016-05-05 03:09:41 UTC (rev 200448)
+++ trunk/Websites/perf.webkit.org/public/v3/pages/summary-page.js        2016-05-05 05:27:18 UTC (rev 200449)
</span><span class="lines">@@ -12,6 +12,7 @@
</span><span class="cx">         this._shouldConstructTable = true;
</span><span class="cx">         this._renderQueue = [];
</span><span class="cx">         this._configGroups = [];
</span><ins>+        this._excludedConfigurations = summarySettings.excludedConfigurations;
</ins><span class="cx"> 
</span><span class="cx">         for (var metricGroup of summarySettings.metricGroups) {
</span><span class="cx">             var group = {name: metricGroup.name, rows: []};
</span><span class="lines">@@ -52,7 +53,7 @@
</span><span class="cx">     {
</span><span class="cx">         var platforms = platformIdList.map(function (id) { return Platform.findById(id); }).filter(function (obj) { return !!obj; });
</span><span class="cx">         var metrics = metricIdList.map(function (id) { return Metric.findById(id); }).filter(function (obj) { return !!obj; });
</span><del>-        var configGroup = new SummaryPageConfigurationGroup(platforms, metrics);
</del><ins>+        var configGroup = new SummaryPageConfigurationGroup(platforms, metrics, this._excludedConfigurations);
</ins><span class="cx">         this._configGroups.push(configGroup);
</span><span class="cx">         return configGroup;
</span><span class="cx">     }
</span><span class="lines">@@ -75,13 +76,9 @@
</span><span class="cx">             this._table.groups.map(function (rowGroup) {
</span><span class="cx">                 return rowGroup.rows.map(function (row, rowIndex) {
</span><span class="cx">                     var headings;
</span><del>-                    if (rowGroup.rows.length == 1)
-                        headings = [element('th', {class: 'unifiedHeader', colspan: 2}, row.name)];
-                    else {
-                        headings = [element('th', {class: 'minorHeader'}, row.name)];
-                        if (!rowIndex)
-                            headings.unshift(element('th', {class: 'majorHeader', rowspan: rowGroup.rows.length}, rowGroup.name));
-                    }
</del><ins>+                    headings = [element('th', {class: 'minorHeader'}, row.name)];
+                    if (!rowIndex)
+                        headings.unshift(element('th', {class: 'majorHeader', rowspan: rowGroup.rows.length}, rowGroup.name));
</ins><span class="cx">                     return element('tr', [headings, row.cells.map(self._constructRatioGraph.bind(self))]);
</span><span class="cx">                 });
</span><span class="cx">             }),
</span><span class="lines">@@ -92,16 +89,28 @@
</span><span class="cx">     {
</span><span class="cx">         var element = ComponentBase.createElement;
</span><span class="cx">         var link = ComponentBase.createLink;
</span><ins>+        var configurationList = configurationGroup.configurationList();
</ins><span class="cx"> 
</span><span class="cx">         var ratioGraph = new RatioBarGraph();
</span><span class="cx"> 
</span><ins>+        var state = ChartsPage.createStateForConfigurationList(configurationList);
+        var anchor = link(ratioGraph, this.router().url('charts', state));
</ins><span class="cx">         this._renderQueue.push(function () {
</span><del>-            ratioGraph.update(configurationGroup.ratio(), configurationGroup.label());
</del><ins>+            var warnings = configurationGroup.warnings();
+            var warningText = '';
+            for (var type in warnings) {
+                var platformString = Array.from(warnings[type]).map(function (platform) { return platform.name(); }).join(', ');
+                warningText += `Missing ${type} for following platform(s): ${platformString}`;
+            }
+
+            anchor.title = warningText || 'Open charts';
+            ratioGraph.update(configurationGroup.ratio(), configurationGroup.label(), !!warningText);
</ins><span class="cx">             ratioGraph.render();
</span><span class="cx">         });
</span><ins>+        if (configurationList.length == 0)
+            return element('td', ratioGraph);
</ins><span class="cx"> 
</span><del>-        var state = ChartsPage.createStateForConfigurationList(configurationGroup.configurationList());
-        return element('td', link(ratioGraph, 'Open charts', this.router().url('charts', state)));
</del><ins>+        return element('td', anchor);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     static htmlTemplate()
</span><span class="lines">@@ -167,14 +176,14 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> class SummaryPageConfigurationGroup {
</span><del>-    constructor(platforms, metrics)
</del><ins>+    constructor(platforms, metrics, excludedConfigurations)
</ins><span class="cx">     {
</span><span class="cx">         this._measurementSets = [];
</span><span class="cx">         this._configurationList = [];
</span><span class="cx">         this._setToRatio = new Map;
</span><span class="cx">         this._ratio = null;
</span><span class="cx">         this._label = null;
</span><del>-        this._changeType = null;
</del><ins>+        this._warnings = {};
</ins><span class="cx">         this._smallerIsBetter = metrics.length ? metrics[0].isSmallerBetter() : null;
</span><span class="cx"> 
</span><span class="cx">         for (var platform of platforms) {
</span><span class="lines">@@ -183,6 +192,9 @@
</span><span class="cx">                 console.assert(metric instanceof Metric);
</span><span class="cx">                 console.assert(this._smallerIsBetter == metric.isSmallerBetter());
</span><span class="cx">                 metric.isSmallerBetter();
</span><ins>+
+                if (excludedConfigurations &amp;&amp; platform.id() in excludedConfigurations &amp;&amp; excludedConfigurations[platform.id()].includes(+metric.id()))
+                    continue;
</ins><span class="cx">                 if (platform.hasMetric(metric)) {
</span><span class="cx">                     this._measurementSets.push(MeasurementSet.findSet(platform.id(), metric.id(), platform.lastModified(metric)));
</span><span class="cx">                     this._configurationList.push([platform.id(), metric.id()]);
</span><span class="lines">@@ -193,6 +205,7 @@
</span><span class="cx"> 
</span><span class="cx">     ratio() { return this._ratio; }
</span><span class="cx">     label() { return this._label; }
</span><ins>+    warnings() { return this._warnings; }
</ins><span class="cx">     changeType() { return this._changeType; }
</span><span class="cx">     configurationList() { return this._configurationList; }
</span><span class="cx"> 
</span><span class="lines">@@ -219,37 +232,40 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         var averageRatio = Statistics.mean(ratios);
</span><del>-        if (isNaN(averageRatio)) {
-            this._summary = '-';
-            this._changeType = null;
</del><ins>+        if (isNaN(averageRatio))
</ins><span class="cx">             return;
</span><del>-        }
</del><span class="cx"> 
</span><del>-        if (Math.abs(averageRatio - 1) &lt; 0.001) { // Less than 0.1% difference.
-            this._summary = 'No change';
-            this._changeType = null;
-            return;
-        }
-
</del><span class="cx">         var currentIsSmallerThanBaseline = averageRatio &lt; 1;
</span><span class="cx">         var changeType = this._smallerIsBetter == currentIsSmallerThanBaseline ? 'better' : 'worse';
</span><del>-        if (currentIsSmallerThanBaseline)
-            averageRatio = 1 / averageRatio;
</del><ins>+        averageRatio = Math.abs(averageRatio - 1);
</ins><span class="cx"> 
</span><del>-        this._ratio = (averageRatio - 1) * (changeType == 'better' ? 1 : -1);
-        this._label = ((averageRatio - 1) * 100).toFixed(1) + '%';
</del><ins>+        this._ratio = averageRatio * (changeType == 'better' ? 1 : -1);
+        this._label = (averageRatio * 100).toFixed(1) + '%';
</ins><span class="cx">         this._changeType = changeType;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     _fetchAndComputeRatio(set, timeRange)
</span><span class="cx">     {
</span><span class="cx">         var setToRatio = this._setToRatio;
</span><del>-        return SummaryPageConfigurationGroup._fetchData(set, timeRange).then(function () {
</del><ins>+        var self = this;
+        return set.fetchBetween(timeRange[0], timeRange[1]).then(function () {
</ins><span class="cx">             var baselineTimeSeries = set.fetchedTimeSeries('baseline', false, false);
</span><span class="cx">             var currentTimeSeries = set.fetchedTimeSeries('current', false, false);
</span><span class="cx"> 
</span><span class="cx">             var baselineMedian = SummaryPageConfigurationGroup._medianForTimeRange(baselineTimeSeries, timeRange);
</span><span class="cx">             var currentMedian = SummaryPageConfigurationGroup._medianForTimeRange(currentTimeSeries, timeRange);
</span><ins>+            var platform = Platform.findById(set.platformId());
+            if (!baselineMedian) {
+                if(!('baseline' in self._warnings))
+                    self._warnings['baseline'] = new Set;
+                self._warnings['baseline'].add(platform);
+            }
+            if (!currentMedian) {
+                if(!('current' in self._warnings))
+                    self._warnings['current'] = new Set;
+                self._warnings['current'].add(platform);
+            }
+
</ins><span class="cx">             setToRatio.set(set, currentMedian / baselineMedian);
</span><span class="cx">         }).catch(function () {
</span><span class="cx">             setToRatio.set(set, NaN);
</span><span class="lines">@@ -270,21 +286,4 @@
</span><span class="cx">         var points = timeSeries.dataBetweenPoints(startPoint, endPoint).map(function (point) { return point.value; });
</span><span class="cx">         return Statistics.median(points);
</span><span class="cx">     }
</span><del>-
-    static _fetchData(set, timeRange)
-    {
-        // FIXME: Make fetchBetween return a promise.
-        var done = false;
-        return new Promise(function (resolve, reject) {
-            set.fetchBetween(timeRange[0], timeRange[1], function (error) {
-                if (done)
-                    return;
-                if (error)
-                    reject(null);
-                else if (set.hasFetchedRange(timeRange[0], timeRange[1]))
-                    resolve();
-                done = true;
-            });
-        });
-    }
</del><span class="cx"> }
</span></span></pre></div>
<a id="trunkWebsitesperfwebkitorgunittestsmeasurementsettestsjs"></a>
<div class="modfile"><h4>Modified: trunk/Websites/perf.webkit.org/unit-tests/measurement-set-tests.js (200448 => 200449)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/unit-tests/measurement-set-tests.js        2016-05-05 03:09:41 UTC (rev 200448)
+++ trunk/Websites/perf.webkit.org/unit-tests/measurement-set-tests.js        2016-05-05 05:27:18 UTC (rev 200449)
</span><span class="lines">@@ -45,7 +45,7 @@
</span><span class="cx">         it('should invoke the callback when the up-to-date cached primary cluster is fetched and it matches the requested range', function (done) {
</span><span class="cx">             var set = MeasurementSet.findSet(1, 1, 3000);
</span><span class="cx">             var callCount = 0;
</span><del>-            set.fetchBetween(2000, 3000, function () {
</del><ins>+            var promise = set.fetchBetween(2000, 3000, function () {
</ins><span class="cx">                 callCount++;
</span><span class="cx">             });
</span><span class="cx">             assert.equal(requests.length, 1);
</span><span class="lines">@@ -62,7 +62,7 @@
</span><span class="cx">                 'clusterCount': 2,
</span><span class="cx">                 'status': 'OK'});
</span><span class="cx"> 
</span><del>-            requests[0].promise.then(function () {
</del><ins>+            promise.then(function () {
</ins><span class="cx">                 assert.equal(callCount, 1);
</span><span class="cx">                 assert.equal(requests.length, 1);
</span><span class="cx">                 done();
</span><span class="lines">@@ -71,11 +71,19 @@
</span><span class="cx">             });
</span><span class="cx">         });
</span><span class="cx"> 
</span><del>-        it('should invoke the callback and fetch a secondary cluster'
-            + 'when the cached primary cluster is up-to-date and within in the requested range', function (done) {
</del><ins>+        function waitForMeasurementSet()
+        {
+            return Promise.resolve().then(function () {
+                return Promise.resolve();
+            }).then(function () {
+                return Promise.resolve();
+            });
+        }
+
+        it('should invoke the callback and fetch a secondary cluster when the cached primary cluster is up-to-date and within in the requested range', function (done) {
</ins><span class="cx">             var set = MeasurementSet.findSet(1, 1, 3000);
</span><span class="cx">             var callCount = 0;
</span><del>-            set.fetchBetween(1000, 3000, function () {
</del><ins>+            var promise = set.fetchBetween(1000, 3000, function () {
</ins><span class="cx">                 callCount++;
</span><span class="cx">             });
</span><span class="cx">             assert.equal(requests.length, 1);
</span><span class="lines">@@ -92,7 +100,7 @@
</span><span class="cx">                 'clusterCount': 2,
</span><span class="cx">                 'status': 'OK'});
</span><span class="cx"> 
</span><del>-            Promise.resolve().then(function () {
</del><ins>+            waitForMeasurementSet().then(function () {
</ins><span class="cx">                 assert.equal(callCount, 1);
</span><span class="cx">                 assert.equal(requests.length, 2);
</span><span class="cx">                 assert.equal(requests[1].url, '../data/measurement-set-1-1-2000.json');
</span><span class="lines">@@ -121,13 +129,15 @@
</span><span class="cx">                 'clusterCount': 3,
</span><span class="cx">                 'status': 'OK'});
</span><span class="cx"> 
</span><del>-            Promise.resolve().then(function () {
</del><ins>+            var callCount = 0;
+            waitForMeasurementSet().then(function () {
</ins><span class="cx">                 assert.equal(requests.length, 2);
</span><span class="cx">                 assert.equal(requests[1].url, '../data/measurement-set-1-1-3000.json');
</span><span class="cx"> 
</span><del>-                var callCount = 0;
</del><span class="cx">                 set.fetchBetween(0, 7000, function () { callCount++; });
</span><span class="cx"> 
</span><ins>+                return waitForMeasurementSet();
+            }).then(function () {
</ins><span class="cx">                 assert.equal(callCount, 1);
</span><span class="cx">                 assert.equal(requests.length, 4);
</span><span class="cx">                 assert.equal(requests[2].url, '../data/measurement-set-1-1-2000.json');
</span><span class="lines">@@ -158,7 +168,7 @@
</span><span class="cx">                 'clusterCount': 3,
</span><span class="cx">                 'status': 'OK'});
</span><span class="cx"> 
</span><del>-            Promise.resolve().then(function () {
</del><ins>+            waitForMeasurementSet().then(function () {
</ins><span class="cx">                 assert.equal(requests.length, 3);
</span><span class="cx">                 assert.equal(requests[1].url, '../data/measurement-set-1-1-3000.json');
</span><span class="cx">                 assert.equal(requests[2].url, '../data/measurement-set-1-1-4000.json');
</span><span class="lines">@@ -187,23 +197,22 @@
</span><span class="cx">                 'clusterCount': 3,
</span><span class="cx">                 'status': 'OK'});
</span><span class="cx"> 
</span><del>-            Promise.resolve().then(function () {
</del><ins>+            var callCount = 0;
+            waitForMeasurementSet().then(function () {
</ins><span class="cx">                 assert.equal(requests.length, 2);
</span><span class="cx">                 assert.equal(requests[1].url, '../data/measurement-set-1-1-4000.json');
</span><del>-
-                var callCount = 0;
</del><span class="cx">                 set.fetchBetween(1207, 1293, function () { callCount++; });
</span><del>-
</del><ins>+                return waitForMeasurementSet();
+            }).then(function () {
</ins><span class="cx">                 assert.equal(callCount, 0);
</span><span class="cx">                 assert.equal(requests.length, 3);
</span><span class="cx">                 assert.equal(requests[2].url, '../data/measurement-set-1-1-2000.json');
</span><del>-
</del><span class="cx">                 set.fetchBetween(1964, 3401, function () { callCount++; });
</span><del>-
</del><ins>+                return waitForMeasurementSet();
+            }).then(function () {
</ins><span class="cx">                 assert.equal(callCount, 0);
</span><span class="cx">                 assert.equal(requests.length, 4);
</span><span class="cx">                 assert.equal(requests[3].url, '../data/measurement-set-1-1-3000.json');
</span><del>-
</del><span class="cx">                 done();
</span><span class="cx">             }).catch(function (error) {
</span><span class="cx">                 done(error);
</span><span class="lines">@@ -221,7 +230,7 @@
</span><span class="cx"> 
</span><span class="cx">             requests[0].reject(500);
</span><span class="cx"> 
</span><del>-            Promise.resolve().then(function () {
</del><ins>+            waitForMeasurementSet().then(function () {
</ins><span class="cx">                 assert.equal(callCount, 1);
</span><span class="cx">                 assert.equal(requests.length, 1);
</span><span class="cx">                 done();
</span><span class="lines">@@ -271,7 +280,7 @@
</span><span class="cx"> 
</span><span class="cx">             requests[0].reject(404);
</span><span class="cx"> 
</span><del>-            Promise.resolve().then(function () {
</del><ins>+            waitForMeasurementSet().then(function () {
</ins><span class="cx">                 assert.equal(callCount, 0);
</span><span class="cx">                 assert.equal(requests.length, 2);
</span><span class="cx">                 assert.equal(requests[1].url, '../api/measurement-set?platform=1&amp;metric=1');
</span><span class="lines">@@ -306,7 +315,7 @@
</span><span class="cx">                 'clusterCount': 2,
</span><span class="cx">                 'status': 'OK'});
</span><span class="cx"> 
</span><del>-            Promise.resolve().then(function () {
</del><ins>+            waitForMeasurementSet().then(function () {
</ins><span class="cx">                 assert.equal(callCount, 1);
</span><span class="cx">                 assert.equal(alternativeCallCount, 1);
</span><span class="cx">                 assert.equal(requests.length, 1);
</span><span class="lines">@@ -337,16 +346,20 @@
</span><span class="cx">             var callCountFor4000To5000 = 0;
</span><span class="cx">             var callCountFor2000 = 0;
</span><span class="cx">             var callCountFor2000To4000 = 0;
</span><del>-            Promise.resolve().then(function () {
</del><ins>+            waitForMeasurementSet().then(function () {
</ins><span class="cx">                 assert.equal(callCountFor4000, 0);
</span><span class="cx">                 assert.equal(requests.length, 2);
</span><span class="cx">                 assert.equal(requests[1].url, '../data/measurement-set-1-1-4000.json');
</span><span class="cx"> 
</span><span class="cx">                 set.fetchBetween(3708, 4800, function () { callCountFor4000To5000++; });
</span><ins>+                return waitForMeasurementSet();
+            }).then(function () {
</ins><span class="cx">                 assert.equal(callCountFor4000To5000, 1);
</span><span class="cx">                 assert.equal(requests.length, 2);
</span><span class="cx"> 
</span><span class="cx">                 set.fetchBetween(1207, 1293, function () { callCountFor2000++; });
</span><ins>+                return waitForMeasurementSet();
+            }).then(function () {
</ins><span class="cx">                 assert.equal(callCountFor2000, 0);
</span><span class="cx">                 assert.equal(requests.length, 3);
</span><span class="cx">                 assert.equal(requests[2].url, '../data/measurement-set-1-1-2000.json');
</span><span class="lines">@@ -358,6 +371,7 @@
</span><span class="cx">                     'endTime': 2000,
</span><span class="cx">                     'lastModified': 5000,
</span><span class="cx">                     'status': 'OK'});
</span><ins>+                return waitForMeasurementSet();
</ins><span class="cx">             }).then(function () {
</span><span class="cx">                 assert.equal(requests.length, 3);
</span><span class="cx">                 assert.equal(callCountFor4000, 0);
</span><span class="lines">@@ -365,7 +379,8 @@
</span><span class="cx">                 assert.equal(callCountFor2000, 1);
</span><span class="cx"> 
</span><span class="cx">                 set.fetchBetween(1964, 3401, function () { callCountFor2000To4000++; });
</span><del>-
</del><ins>+                return waitForMeasurementSet();
+            }).then(function () {
</ins><span class="cx">                 assert.equal(callCountFor2000To4000, 1);
</span><span class="cx">                 assert.equal(requests.length, 4);
</span><span class="cx">                 assert.equal(requests[3].url, '../data/measurement-set-1-1-3000.json');
</span><span class="lines">@@ -377,6 +392,7 @@
</span><span class="cx">                     'endTime': 3000,
</span><span class="cx">                     'lastModified': 5000,
</span><span class="cx">                     'status': 'OK'});
</span><ins>+                return waitForMeasurementSet();
</ins><span class="cx">             }).then(function () {
</span><span class="cx">                 assert.equal(callCountFor4000, 0);
</span><span class="cx">                 assert.equal(callCountFor4000To5000, 1);
</span><span class="lines">@@ -391,6 +407,7 @@
</span><span class="cx">                     'endTime': 4000,
</span><span class="cx">                     'lastModified': 5000,
</span><span class="cx">                     'status': 'OK'});
</span><ins>+                return waitForMeasurementSet();
</ins><span class="cx">             }).then(function () {
</span><span class="cx">                 assert.equal(callCountFor4000, 1);
</span><span class="cx">                 assert.equal(callCountFor4000To5000, 2);
</span><span class="lines">@@ -406,4 +423,4 @@
</span><span class="cx"> 
</span><span class="cx">     });
</span><span class="cx"> 
</span><del>-});
</del><span class="cx">\ No newline at end of file
</span><ins>+});
</ins></span></pre>
</div>
</div>

</body>
</html>