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

Unified Diff: chrome/test/data/extensions/api_test/tabs/basics/sinewave.js

Issue 987583004: Add audible, muted to Tab, c.t.query, c.t.update, and c.t.onUpdated where relevant (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@patch1
Patch Set: followups through message #33 Created 5 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 side-by-side diff with in-line comments
Download patch
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..7895012c09fa4dbefb9439df5c96cc84141019f8
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/tabs/basics/sinewave.js
@@ -0,0 +1,33 @@
+// 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.
+
+function enableSineWave() {
+ var freqs = [200, 500, 1800];
+ var curTestIdx = 0;
not at google - send to devlin 2015/06/01 20:33:57 am I missing something, or is curTestIdx never act
Jared Sohn 2015/06/02 08:54:38 Just a note on this: I didn't write most of this c
+ if (!this.audioContext) {
+ this.audioContext = new AudioContext();
not at google - send to devlin 2015/06/01 20:33:56 I'd rather not use |this| here. Trivia: it actuall
Jared Sohn 2015/06/02 08:54:38 Done.
+ 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();
+ }
+}
+
+function disableSineWave() {
+ this.oscillator.stop();
+}

Powered by Google App Engine
This is Rietveld 408576698