4 <title>Test for User Timing APIs on dying globals
</title>
5 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
6 <script type=
"text/javascript">
7 // We must wait for the iframe to load.
8 SimpleTest
.waitForExplicitFinish();
9 window
.addEventListener('load', () => {
10 const dyingWindow
= initTest();
11 ok(true, 'Initialization complete');
13 testDoesNotCrash(dyingWindow
);
18 // We create a dying global by creating an iframe, keeping a
19 // reference to it, and removing it.
20 const iframe
= document
.querySelector('iframe');
21 const iframeWindow
= iframe
.contentWindow
;
23 // We want to call the User Timing functions in the context of
24 // the dying global. However, we can't call constructors
25 // directly on a reference to a window so we have to wrap it.
26 iframeWindow
.newPerformanceMark
= () => {
27 new PerformanceMark('constructor', {detail
: 'constructorDetail'});
30 // Send the global to a dying state.
36 function testDoesNotCrash(dyingWindow
) {
37 ok(true, 'Running testDoesNotCrash');
39 dyingWindow
.newPerformanceMark();
40 ok(true, 'new PerformanceMark() on dying global did not crash');
43 dyingWindow
.performance
.mark('markMethod', {detail
: 'markMethodDetail'});
45 is(e
.code
, e
.INVALID_STATE_ERR
, 'performance.mark on dying global threw expected exception');
47 ok(true, 'performance.mark on dying global did not crash');
50 dyingWindow
.performance
.measure('measureMethod');
52 is(e
.code
, e
.INVALID_STATE_ERR
, 'performance.measure on dying global threw expected exception');
54 ok(true, 'performance.measure on dying global did not crash');
59 <iframe width=
"200" height=
"200" src=
"about:blank"></iframe>