Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2587)

Side by Side Diff: third_party/WebKit/LayoutTests/webaudio/AudioContext/audiocontext-close-basic.html

Issue 2895963003: Apply layout-test-tidy to LayoutTests/webaudio (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!doctype html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <title>Test AudioContext.close() closes many contexts</title> 4 <title>
5 Test AudioContext.close() closes many contexts
6 </title>
5 <script src="../../resources/testharness.js"></script> 7 <script src="../../resources/testharness.js"></script>
6 <script src="../../resources/testharnessreport.js"></script> 8 <script src="../../resources/testharnessreport.js"></script>
7 <script src="../resources/audit-util.js"></script> 9 <script src="../resources/audit-util.js"></script>
8 <script src="../resources/audit.js"></script> 10 <script src="../resources/audit.js"></script>
9 </head> 11 </head>
12 <body>
13 <script id="layout-test-code">
14 let audit = Audit.createTaskRunner();
10 15
11 <body>
12 <script>
13 let audit = Audit.createTaskRunner();
14
15 let context = null; 16 let context = null;
16 17
17 // The number of contexts we want to create and close. 18 // The number of contexts we want to create and close.
18 let MAX_ITERATION = 100; 19 let MAX_ITERATION = 100;
19 let counter = 0; 20 let counter = 0;
20 21
21 function createContextAndClose(task, should) { 22 function createContextAndClose(task, should) {
22 // Bypass the first iteration. 23 // Bypass the first iteration.
23 if (context) { 24 if (context) {
24 should(context.state, "context.state for closed context " + counter) 25 should(context.state, 'context.state for closed context ' + counter)
25 .beEqualTo("closed"); 26 .beEqualTo('closed');
26 context = null; 27 context = null;
27 } 28 }
28 // Create new context and close. 29 // Create new context and close.
29 context = new AudioContext(); 30 context = new AudioContext();
30 if (counter++ < MAX_ITERATION) { 31 if (counter++ < MAX_ITERATION) {
31 // Recursive promise resolution. 32 // Recursive promise resolution.
32 context.close().then(function () { 33 context.close().then(
33 createContextAndClose(task, should); 34 function() {
34 }, function () { 35 createContextAndClose(task, should);
35 onFailure(should); 36 },
37 function() {
38 onFailure(should);
39 task.done();
40 });
41 } else {
42 context.close().then(function() {
43 // |counter| is one more than MAX_ITERATION if we
44 // succeeded.
45 should(
46 counter - 1,
47 'Number of contexts successfully created and closed')
48 .beEqualTo(MAX_ITERATION);
36 task.done(); 49 task.done();
37 }); 50 });
38 } else {
39 context.close()
40 .then(function () {
41 // |counter| is one more than MAX_ITERATION if we
42 // succeeded.
43 should(counter - 1,
44 "Number of contexts successfully created and closed")
45 .beEqualTo(MAX_ITERATION);
46 task.done();
47 });
48 } 51 }
49 } 52 }
50 53
51 function onFailure(should) { 54 function onFailure(should) {
52 should(context.state, "Context " + counter + "failed to close") 55 should(context.state, 'Context ' + counter + 'failed to close')
53 .beEqualTo("closed"); 56 .beEqualTo('closed');
54 } 57 }
55 58
56 audit.define({ 59 audit.define(
57 label: "test", 60 {
58 description: "Test that closing a context releases the audio HW context" 61 label: 'test',
59 }, function (task, should) { 62 description:
60 createContextAndClose(task, should); 63 'Test that closing a context releases the audio HW context'
61 }); 64 },
65 function(task, should) {
66 createContextAndClose(task, should);
67 });
62 68
63 audit.run(); 69 audit.run();
64 </script> 70 </script>
65 </body> 71 </body>
66 </html> 72 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698