michael@0: /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 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: var gParser = new DOMParser; michael@0: var gTimeout; michael@0: michael@0: function Test(aTitle, aSourceURL, aStyleURL, aNumber, aObserver) michael@0: { michael@0: this.mTitle = aTitle; michael@0: this.mObserver = aObserver; michael@0: this.mTotal = aNumber; michael@0: this.mDone = 0; michael@0: var xmlcontent = loadFile(aSourceURL); michael@0: var xslcontent = loadFile(aStyleURL); michael@0: this.mSource = gParser.parseFromString(xmlcontent, 'application/xml'); michael@0: this.mStyle = gParser.parseFromString(xslcontent, 'application/xml'); michael@0: } michael@0: michael@0: function runTest(aTitle, aSourceURL, aStyleURL, aNumber, aObserver) michael@0: { michael@0: test = new Test(aTitle, aSourceURL, aStyleURL, aNumber, michael@0: aObserver); michael@0: gTimeout = setTimeout(onNextTransform, 100, test, 0); michael@0: } michael@0: michael@0: function onNextTransform(aTest, aNumber) michael@0: { michael@0: var proc = new XSLTProcessor; michael@0: var startTime = Date.now(); michael@0: proc.importStylesheet(aTest.mStyle); michael@0: var res = proc.transformToDocument(aTest.mSource); michael@0: var endTime = Date.now(); michael@0: aNumber++; michael@0: var progress = aNumber / aTest.mTotal * 100; michael@0: if (aTest.mObserver) { michael@0: aTest.mObserver.progress(aTest.mTitle, endTime - startTime, michael@0: progress); michael@0: } michael@0: if (aNumber < aTest.mTotal) { michael@0: gTimeout = setTimeout(onNextTransform, 100, aTest, aNumber); michael@0: } else if (aTest.mObserver) { michael@0: aTest.mObserver.done(aTest.mTitle); michael@0: } michael@0: }