| Index: chrome/test/data/extensions/api_test/tabs/basics/sinewave.js
|
| diff --git a/chrome/test/data/extensions/api_test/tabs/basics/sinewave.js b/chrome/test/data/extensions/api_test/tabs/basics/sinewave.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..232a9e0980961fd2f162f39c30af9b66a71acba1
|
| --- /dev/null
|
| +++ b/chrome/test/data/extensions/api_test/tabs/basics/sinewave.js
|
| @@ -0,0 +1,27 @@
|
| +// Copyright (c) 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +var freqs = [200, 500, 1800];
|
| +var curTestIdx = 0;
|
| +if (!this.audioContext) {
|
| + this.audioContext = new AudioContext();
|
| + this.gainNode = this.audioContext.createGain();
|
| + this.gainNode.gain.value = 0.5;
|
| + this.gainNode.connect(this.audioContext.destination);
|
| +}
|
| +if (!this.oscillator ||
|
| + this.oscillator.frequency.value != freqs[curTestIdx]) {
|
| + // Note: We recreate the oscillator each time because this switches the
|
| + // audio frequency immediately. Re-using the same oscillator tends to take
|
| + // several hundred milliseconds to ramp-up/down the frequency.
|
| + if (this.oscillator) {
|
| + this.oscillator.stop();
|
| + this.oscillator.disconnect();
|
| + }
|
| + this.oscillator = this.audioContext.createOscillator();
|
| + this.oscillator.type = OscillatorNode.SINE;
|
| + this.oscillator.frequency.value = freqs[curTestIdx];
|
| + this.oscillator.connect(this.gainNode);
|
| + this.oscillator.start();
|
| +}
|
|
|