michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: let doc; michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: Task.spawn(function(){ michael@0: info(chromeRoot + "browser_progress_indicator.xul"); michael@0: yield addTab(chromeRoot + "browser_progress_indicator.xul"); michael@0: doc = Browser.selectedTab.browser.contentWindow.document; michael@0: }).then(runTests); michael@0: } michael@0: michael@0: gTests.push({ michael@0: desc: "circular progress indicator binding is applied.", michael@0: run: function() { michael@0: ok(doc, "doc got defined"); michael@0: michael@0: let progressIndicator = doc.querySelector("#progress-indicator"); michael@0: ok(progressIndicator, "progress-indicator is found"); michael@0: is(typeof progressIndicator.reset, "function", "#progress-indicator has a reset() function"); michael@0: is(typeof progressIndicator.updateProgress, "function", "#progress-indicator has a updateProgress() function"); michael@0: } michael@0: }); michael@0: michael@0: gTests.push({ michael@0: desc: "start and end angles are correct for various percents complete", michael@0: run: function() { michael@0: let progressIndicator = doc.querySelector("#progress-indicator"); michael@0: ok(progressIndicator, "progress-indicator is found"); michael@0: is(typeof progressIndicator.updateProgress, "function", "#progress-indicator has a updateProgress() function"); michael@0: michael@0: let expectedStartAngle = 1.5 * Math.PI; michael@0: michael@0: let percentComplete = 0; michael@0: let [startAngle, endAngle] = progressIndicator.updateProgress(percentComplete); michael@0: is(startAngle, expectedStartAngle, "start angle is correct"); michael@0: is(endAngle, startAngle + (2 * Math.PI * (percentComplete / 100)), "end angle is correct"); michael@0: michael@0: percentComplete = 0.05; michael@0: [startAngle, endAngle] = progressIndicator.updateProgress(percentComplete); michael@0: is(startAngle, expectedStartAngle, "start angle is correct"); michael@0: is(endAngle, startAngle + (2 * Math.PI * (percentComplete / 100)), "end angle is correct"); michael@0: michael@0: percentComplete = 0.5; michael@0: [startAngle, endAngle] = progressIndicator.updateProgress(percentComplete); michael@0: is(startAngle, expectedStartAngle, "start angle is correct"); michael@0: is(endAngle, startAngle + (2 * Math.PI * (percentComplete / 100)), "end angle is correct"); michael@0: michael@0: percentComplete = 1; michael@0: [startAngle, endAngle] = progressIndicator.updateProgress(percentComplete); michael@0: is(startAngle, expectedStartAngle, "start angle is correct"); michael@0: is(endAngle, startAngle + (2 * Math.PI * (percentComplete / 100)), "end angle is correct"); michael@0: } michael@0: });