diff -r 000000000000 -r 6474c204b198 toolkit/components/feeds/test/test.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/toolkit/components/feeds/test/test.js Wed Dec 31 06:09:35 2014 +0100 @@ -0,0 +1,88 @@ +/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +var passed = 0; +var ran = 0; +if(tests.length < 1){ + dump("FAILED! tests.length was " + tests.length + "\n"); +} + +function logResult(didPass, testcase, extra) { + var start = didPass ? "PASS | " : "FAIL | "; + print(start + testcase.path + " | Test was: \"" + + testcase.desc + "\" | " + testcase.expect + " |"); + if (extra) { + print(extra); + } +} + + +function isIID(a,iid){ + var rv = false; + try{ + a.QueryInterface(iid); + rv = true; + }catch(e){} + return rv; +} +function TestListener(){} + +TestListener.prototype = { + handleResult: function(result){ + var feed = result.doc; + // QI to something + (isIID(feed, Components.interfaces.nsIFeed)); + try { + if(!eval(testcase.expect)){ + logResult(false, testcase); + + }else{ + logResult(true, testcase); + passed += 1; + } + } + catch(e) { + logResult(false, testcase, "ex: " + e.message); + } + + ran += 1; + result = null; + } +} + +var startDate = new Date(); + +for(var i=0; i