michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: MARIONETTE_TIMEOUT = 30000; michael@0: michael@0: SpecialPowers.addPermission("fmradio", true, document); michael@0: michael@0: let FMRadio = window.navigator.mozFMRadio; michael@0: michael@0: function verifyInitialState() { michael@0: log("Verifying initial state."); michael@0: ok(FMRadio); michael@0: is(FMRadio.enabled, false); michael@0: setUp(); michael@0: } michael@0: michael@0: function setUp() { michael@0: let frequency = FMRadio.frequencyLowerBound + FMRadio.channelWidth; michael@0: FMRadio.enable(frequency); michael@0: FMRadio.onenabled = seekUp; michael@0: } michael@0: michael@0: function seekUp() { michael@0: log("Seek up"); michael@0: var request = FMRadio.seekUp(); michael@0: ok(request); michael@0: michael@0: request.onsuccess = function() { michael@0: seekDown(); michael@0: }; michael@0: michael@0: request.onerror = function() { michael@0: ok(false, "Seekup request should not fail."); michael@0: }; michael@0: } michael@0: michael@0: function seekDown() { michael@0: log("Seek down"); michael@0: var request = FMRadio.seekDown(); michael@0: ok(request); michael@0: michael@0: request.onsuccess = function() { michael@0: cleanUp(); michael@0: }; michael@0: michael@0: request.onerror = function() { michael@0: ok(false, "Seekdown request should not fail."); michael@0: }; michael@0: } michael@0: michael@0: function cleanUp() { michael@0: FMRadio.disable(); michael@0: FMRadio.ondisabled = function() { michael@0: FMRadio.ondisabled = null; michael@0: ok(!FMRadio.enabled); michael@0: finish(); michael@0: }; michael@0: } michael@0: michael@0: verifyInitialState(); michael@0: