Add sanity check for source origin in WebLoaderStrategy::startPingLoad()
[WebKit-https.git] / Websites / perf.webkit.org / browser-tests / chart-revision-range-tests.js
1
2 describe('ChartRevisionRange', () => {
3
4     function importRevisionList(context)
5     {
6         return ChartTest.importChartScripts(context).then(() => {
7             ChartTest.makeModelObjectsForSampleCluster(context);
8             return context.importScripts(['lazily-evaluated-function.js', 'components/chart-revision-range.js'], 'ChartRevisionRange');
9         });
10     }
11
12     describe('revisionList on a non-interactive chart', () => {
13         it('should report the list of revision for the latest point', () => {
14             const context = new BrowsingContext();
15             let evaluator;
16             return importRevisionList(context).then((ChartRevisionRange) => {
17                 const chart = ChartTest.createChartWithSampleCluster(context);
18                 chart.setDomain(ChartTest.sampleCluster.startTime, ChartTest.sampleCluster.endTime);
19                 chart.fetchMeasurementSets();
20
21                 const requests = context.symbols.MockRemoteAPI.requests;
22                 expect(requests.length).to.be(1);
23                 ChartTest.respondWithSampleCluster(requests[0]);
24
25                 evaluator = new ChartRevisionRange(chart);
26                 expect(evaluator.revisionList()).to.be(null);
27
28                 return waitForComponentsToRender(context);
29             }).then(() => {
30                 const revisionList = evaluator.revisionList();
31                 expect(revisionList).to.not.be(null);
32                 expect(revisionList.length).to.be(2);
33
34                 expect(revisionList[0].repository.label()).to.be('SomeApp');
35                 expect(revisionList[0].label).to.be('r4006');
36
37                 expect(revisionList[1].repository.label()).to.be('macOS');
38                 expect(revisionList[1].label).to.be('15C50');
39             })
40         });
41     });
42
43
44     describe('revisionList on an interactive chart', () => {
45
46         it('should not report the list of revision for the latest point when there is no selection or indicator', () => {
47             const context = new BrowsingContext();
48             let evaluator;
49             return importRevisionList(context).then((ChartRevisionRange) => {
50                 const chart = ChartTest.createInteractiveChartWithSampleCluster(context);
51                 chart.setDomain(ChartTest.sampleCluster.startTime, ChartTest.sampleCluster.endTime);
52                 chart.fetchMeasurementSets();
53
54                 const requests = context.symbols.MockRemoteAPI.requests;
55                 expect(requests.length).to.be(1);
56                 ChartTest.respondWithSampleCluster(requests[0]);
57
58                 evaluator = new ChartRevisionRange(chart);
59                 expect(evaluator.revisionList()).to.be(null);
60
61                 return waitForComponentsToRender(context);
62             }).then(() => {
63                 expect(evaluator.revisionList()).to.be(null);
64             })
65         });
66
67         it('should report the list of revision for the locked indicator with differences to the previous point', () => {
68             const context = new BrowsingContext();
69             let chart;
70             let evaluator;
71             return importRevisionList(context).then((ChartRevisionRange) => {
72                 chart = ChartTest.createInteractiveChartWithSampleCluster(context);
73                 chart.setDomain(ChartTest.sampleCluster.startTime, ChartTest.sampleCluster.endTime);
74                 chart.fetchMeasurementSets();
75
76                 const requests = context.symbols.MockRemoteAPI.requests;
77                 expect(requests.length).to.be(1);
78                 ChartTest.respondWithSampleCluster(requests[0]);
79
80                 evaluator = new ChartRevisionRange(chart);
81                 expect(evaluator.revisionList()).to.be(null);
82
83                 return waitForComponentsToRender(context);
84             }).then(() => {
85                 expect(evaluator.revisionList()).to.be(null);
86
87                 const currentView = chart.sampledTimeSeriesData('current');
88                 chart.setIndicator(currentView.lastPoint().id, true);
89
90                 let revisionList = evaluator.revisionList();
91                 expect(revisionList).to.not.be(null);
92                 expect(revisionList.length).to.be(2);
93
94                 expect(revisionList[0].repository.label()).to.be('SomeApp');
95                 expect(revisionList[0].label).to.be('r4004-r4006');
96
97                 expect(revisionList[1].repository.label()).to.be('macOS');
98                 expect(revisionList[1].label).to.be('15C50');
99
100                 chart.setIndicator(1004, true); // Across macOS change.
101
102                 revisionList = evaluator.revisionList();
103                 expect(revisionList.length).to.be(2);
104
105                 expect(revisionList[0].repository.label()).to.be('SomeApp');
106                 expect(revisionList[0].label).to.be('r4003-r4004');
107
108                 expect(revisionList[1].repository.label()).to.be('macOS');
109                 expect(revisionList[1].label).to.be('15B42 - 15C50');
110             });
111         });
112
113         it('should report the list of revision for the selected range', () => {
114             const context = new BrowsingContext();
115             let chart;
116             let evaluator;
117             return importRevisionList(context).then((ChartRevisionRange) => {
118                 chart = ChartTest.createInteractiveChartWithSampleCluster(context);
119                 chart.setDomain(ChartTest.sampleCluster.startTime, ChartTest.sampleCluster.endTime);
120                 chart.fetchMeasurementSets();
121
122                 const requests = context.symbols.MockRemoteAPI.requests;
123                 expect(requests.length).to.be(1);
124                 ChartTest.respondWithSampleCluster(requests[0]);
125
126                 evaluator = new ChartRevisionRange(chart);
127                 expect(evaluator.revisionList()).to.be(null);
128
129                 return waitForComponentsToRender(context);
130             }).then(() => {
131                 expect(evaluator.revisionList()).to.be(null);
132
133                 const currentView = chart.sampledTimeSeriesData('current');
134                 chart.setSelection([currentView.firstPoint().time + 1, currentView.lastPoint().time - 1]);
135
136                 let revisionList = evaluator.revisionList();
137                 expect(revisionList).to.not.be(null);
138                 expect(revisionList.length).to.be(2);
139
140                 expect(revisionList[0].repository.label()).to.be('SomeApp');
141                 expect(revisionList[0].label).to.be('r4002-r4004'); // 4001 and 4005 are outliers and skipped.
142
143                 expect(revisionList[1].repository.label()).to.be('macOS');
144                 expect(revisionList[1].label).to.be('15B42 - 15C50');
145             });
146         });
147     });
148
149 });