|
1 | | -test(function(){ |
2 | | -assert_throws_js(TypeError,function(){self.performance.mark("mark1",123);},"Number passed as a dict argument should cause type-error.") |
3 | | -},"Number should be rejected as the mark-options.") |
| 1 | +// If you're testing an API that constructs a PerformanceMark, add your test here. |
| 2 | +// See the for loop below for details. |
| 3 | +constmarkConstructionTests=[ |
| 4 | +{ |
| 5 | +testName: "Number should be rejected as the mark-options.", |
| 6 | +testFunction: function(newMarkFunction){ |
| 7 | +assert_throws_js(TypeError,function(){newMarkFunction("mark1",123);},"Number passed as a dict argument should cause type-error."); |
| 8 | +}, |
| 9 | +}, |
4 | 10 |
|
5 | | -test(function(){ |
6 | | -assert_throws_js(TypeError,function(){self.performance.mark("mark1",NaN);},"NaN passed as a dict argument should cause type-error.") |
7 | | -},"NaN should be rejected as the mark-options.") |
| 11 | +{ |
| 12 | +testName: "NaN should be rejected as the mark-options.", |
| 13 | +testFunction: function(newMarkFunction){ |
| 14 | +assert_throws_js(TypeError,function(){newMarkFunction("mark1",NaN);},"NaN passed as a dict argument should cause type-error."); |
| 15 | +}, |
| 16 | +}, |
8 | 17 |
|
9 | | -test(function(){ |
10 | | -assert_throws_js(TypeError,function(){self.performance.mark("mark1",Infinity);},"Infinity passed as a dict argument should cause type-error.") |
11 | | -},"Infinity should be rejected as the mark-options.") |
| 18 | +{ |
| 19 | +testName: "Infinity should be rejected as the mark-options.", |
| 20 | +testFunction: function(newMarkFunction){ |
| 21 | +assert_throws_js(TypeError,function(){newMarkFunction("mark1",Infinity);},"Infinity passed as a dict argument should cause type-error."); |
| 22 | +}, |
| 23 | +}, |
12 | 24 |
|
13 | | -test(function(){ |
14 | | -assert_throws_js(TypeError,function(){self.performance.mark("mark1","string");},"String passed as a dict argument should cause type-error.") |
15 | | -},"String should be rejected as the mark-options.") |
| 25 | +{ |
| 26 | +testName: "String should be rejected as the mark-options.", |
| 27 | +testFunction: function(newMarkFunction){ |
| 28 | +assert_throws_js(TypeError,function(){newMarkFunction("mark1","string");},"String passed as a dict argument should cause type-error.") |
| 29 | +}, |
| 30 | +}, |
| 31 | + |
| 32 | +{ |
| 33 | +testName: "Negative startTime in mark-options should be rejected", |
| 34 | +testFunction: function(newMarkFunction){ |
| 35 | +assert_throws_js(TypeError,function(){newMarkFunction("mark1",{startTime: -1});},"Negative startTime should cause type-error.") |
| 36 | +}, |
| 37 | +}, |
| 38 | +]; |
| 39 | + |
| 40 | +// There are multiple function calls that can construct a mark using the same arguments so we run |
| 41 | +// each test on each construction method here, avoiding duplication. |
| 42 | +for(lettestInfoofmarkConstructionTests){ |
| 43 | +test(function(){ |
| 44 | +testInfo.testFunction(self.performance.mark); |
| 45 | +},`[performance.mark]: ${testInfo.testName}`); |
| 46 | + |
| 47 | +test(function(){ |
| 48 | +testInfo.testFunction((markName,obj)=>newPerformanceMark(markName,obj)); |
| 49 | +},`[new PerformanceMark]: ${testInfo.testName}`); |
| 50 | +} |
0 commit comments