Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / webaudio / onstatechange.html
blobaae444847868c95c17944bc3beb58d885ab8d445
1 <!doctype html>
2 <html>
3 <head>
4 <title>Test statechange event</title>
5 <script src="../resources/js-test.js"></script>
6 <script src="resources/audio-testing.js"/>
7 <script src="resources/compatibility.js"></script>
8 </head>
10 <body>
11 <script>
12 description("Test statechange event is properly signaled")
14 window.jsTestIsAsync = true;
16 var secondsToRender = 2;
17 var sampleRate = 48000;
19 var stateChangeCount = 0;
20 var context;
21 var contextState;
23 function checkStateChange (e) {
24 contextState = e.currentTarget.state;
26 switch (stateChangeCount) {
27 case 0:
28 shouldBeEqualToString("contextState", "running");
29 break;
30 case 1:
31 shouldBeEqualToString("contextState", "closed");
32 break;
33 default:
34 testFailed("Expected only two state changes but got " + stateChangeCount);
36 ++stateChangeCount;
39 function finalCheck() {
40 // Final check that we got the right number of state changes and the correct final state.
41 shouldBeEqualToNumber("stateChangeCount", 2);
42 shouldBeEqualToString("context.state", "closed");
43 finishJSTest();
46 function runTest() {
47 // Create an offline context with a source passing through a convolver. The convolver is
48 // just to waste some time.
49 context = new OfflineAudioContext(1, secondsToRender * sampleRate, sampleRate);
50 var buffer = createImpulseBuffer(context, sampleRate);
51 var source = context.createBufferSource();
52 var conv = context.createConvolver();
54 source.buffer = buffer;
55 conv.normalize = false;
56 conv.buffer = buffer;
58 source.connect(conv);
59 conv.connect(context.destination);
61 source.start();
63 context.onstatechange = checkStateChange;
65 context.startRendering().then(function () {
66 testPassed("context finished rendering")
67 });
69 // Don't want to set an oncomplete for the context and don't want to use the promise because
70 // the order of the state change event and resolving the promise is not specified. Thus,
71 // just wait for a bit and then finish the test. We assume the offline context runs faster
72 // than realtime.
73 setTimeout(finalCheck, secondsToRender * 1000);
76 runTest();
77 </script>
78 </body>
79 </html>