jasmine-html.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688
  1. jasmine.HtmlReporterHelpers = {};
  2. jasmine.HtmlReporterHelpers.createDom = function(type, attrs, childrenVarArgs) {
  3. var el = document.createElement(type);
  4. for (var i = 2; i < arguments.length; i++) {
  5. var child = arguments[i];
  6. if (typeof child === 'string') {
  7. el.appendChild(document.createTextNode(child));
  8. } else {
  9. if (child) {
  10. el.appendChild(child);
  11. }
  12. }
  13. }
  14. for (var attr in attrs) {
  15. if (attr == "className") {
  16. el[attr] = attrs[attr];
  17. } else {
  18. el.setAttribute(attr, attrs[attr]);
  19. }
  20. }
  21. return el;
  22. };
  23. jasmine.HtmlReporterHelpers.getSpecStatus = function(child) {
  24. var results = child.results();
  25. var status = results.passed() ? 'passed' : 'failed';
  26. if (results.skipped) {
  27. status = 'skipped';
  28. }
  29. return status;
  30. };
  31. jasmine.HtmlReporterHelpers.appendToSummary = function(child, childElement) {
  32. var parentDiv = this.dom.summary;
  33. var parentSuite = (typeof child.parentSuite == 'undefined') ? 'suite' : 'parentSuite';
  34. var parent = child[parentSuite];
  35. if (parent) {
  36. if (typeof this.views.suites[parent.id] == 'undefined') {
  37. this.views.suites[parent.id] = new jasmine.HtmlReporter.SuiteView(parent, this.dom, this.views);
  38. }
  39. parentDiv = this.views.suites[parent.id].element;
  40. }
  41. parentDiv.appendChild(childElement);
  42. };
  43. jasmine.HtmlReporterHelpers.addHelpers = function(ctor) {
  44. for(var fn in jasmine.HtmlReporterHelpers) {
  45. ctor.prototype[fn] = jasmine.HtmlReporterHelpers[fn];
  46. }
  47. };
  48. jasmine.HtmlReporter = function(_doc) {
  49. var self = this;
  50. var doc = _doc || window.document;
  51. var reporterView;
  52. var dom = {};
  53. // Jasmine Reporter Public Interface
  54. self.logRunningSpecs = false;
  55. self.reportRunnerStarting = function(runner) {
  56. var specs = runner.specs() || [];
  57. if (specs.length == 0) {
  58. return;
  59. }
  60. createReporterDom(runner.env.versionString());
  61. doc.body.appendChild(dom.reporter);
  62. setExceptionHandling();
  63. reporterView = new jasmine.HtmlReporter.ReporterView(dom);
  64. reporterView.addSpecs(specs, self.specFilter);
  65. };
  66. self.reportRunnerResults = function(runner) {
  67. reporterView && reporterView.complete();
  68. };
  69. self.reportSuiteResults = function(suite) {
  70. reporterView.suiteComplete(suite);
  71. };
  72. self.reportSpecStarting = function(spec) {
  73. if (self.logRunningSpecs) {
  74. self.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
  75. }
  76. };
  77. self.reportSpecResults = function(spec) {
  78. reporterView.specComplete(spec);
  79. };
  80. self.log = function() {
  81. var console = jasmine.getGlobal().console;
  82. if (console && console.log) {
  83. if (console.log.apply) {
  84. console.log.apply(console, arguments);
  85. } else {
  86. console.log(arguments); // ie fix: console.log.apply doesn't exist on ie
  87. }
  88. }
  89. };
  90. self.specFilter = function(spec) {
  91. if (!focusedSpecName()) {
  92. return true;
  93. }
  94. return spec.getFullName().indexOf(focusedSpecName()) === 0;
  95. };
  96. /*
  97. * add by dongyancen for rewrite finishCallback in ext_jasmine to record the runner result
  98. * 10/17/2013
  99. * */
  100. // self.getReporterView = function(){
  101. // return reporterView ;
  102. // };
  103. return self;
  104. function focusedSpecName() {
  105. var specName;
  106. (function memoizeFocusedSpec() {
  107. if (specName) {
  108. return;
  109. }
  110. var paramMap = [];
  111. var params = jasmine.HtmlReporter.parameters(doc);
  112. for (var i = 0; i < params.length; i++) {
  113. var p = params[i].split('=');
  114. paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
  115. }
  116. specName = paramMap.spec;
  117. })();
  118. return specName;
  119. }
  120. function createReporterDom(version) {
  121. dom.reporter = self.createDom('div', { id: 'HTMLReporter', className: 'jasmine_reporter' },
  122. dom.banner = self.createDom('div', { className: 'banner' },
  123. self.createDom('span', { className: 'title' }, "Jasmine "),
  124. self.createDom('span', { className: 'version' }, version)),
  125. dom.symbolSummary = self.createDom('ul', {className: 'symbolSummary'}),
  126. dom.alert = self.createDom('div', {className: 'alert'},
  127. self.createDom('span', { className: 'exceptions' },
  128. self.createDom('label', { className: 'label', for: 'no_try_catch' }, 'No try/catch'),
  129. self.createDom('input', { id: 'no_try_catch', type: 'checkbox' }))),
  130. dom.results = self.createDom('div', {className: 'results'},
  131. dom.summary = self.createDom('div', { className: 'summary' }),
  132. dom.details = self.createDom('div', { id: 'details' }))
  133. );
  134. }
  135. function noTryCatch() {
  136. return window.location.search.match(/catch=false/);
  137. }
  138. function searchWithCatch() {
  139. var params = jasmine.HtmlReporter.parameters(window.document);
  140. var removed = false;
  141. var i = 0;
  142. while (!removed && i < params.length) {
  143. if (params[i].match(/catch=/)) {
  144. params.splice(i, 1);
  145. removed = true;
  146. }
  147. i++;
  148. }
  149. if (jasmine.CATCH_EXCEPTIONS) {
  150. params.push("catch=false");
  151. }
  152. return params.join("&");
  153. }
  154. function setExceptionHandling() {
  155. var chxCatch = document.getElementById('no_try_catch');
  156. if (noTryCatch()) {
  157. chxCatch.setAttribute('checked', true);
  158. jasmine.CATCH_EXCEPTIONS = false;
  159. }
  160. chxCatch.onclick = function() {
  161. window.location.search = searchWithCatch();
  162. };
  163. }
  164. };
  165. jasmine.HtmlReporter.parameters = function(doc) {
  166. var paramStr = doc.location.search.substring(1);
  167. var params = [];
  168. if (paramStr.length > 0) {
  169. params = paramStr.split('&');
  170. }
  171. return params;
  172. }
  173. jasmine.HtmlReporter.sectionLink = function(sectionName) {
  174. var link = '?';
  175. var params = [];
  176. if (sectionName) {
  177. params.push('spec=' + encodeURIComponent(sectionName));
  178. }
  179. if (!jasmine.CATCH_EXCEPTIONS) {
  180. params.push("catch=false");
  181. }
  182. if (params.length > 0) {
  183. link += params.join("&");
  184. }
  185. return link;
  186. };
  187. jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter);
  188. jasmine.HtmlReporter.ReporterView = function(dom) {
  189. this.startedAt = new Date();
  190. this.runningSpecCount = 0;
  191. this.completeSpecCount = 0;
  192. this.passedCount = 0;
  193. this.failedCount = 0;
  194. this.skippedCount = 0;
  195. this.createResultsMenu = function() {
  196. this.resultsMenu = this.createDom('span', {className: 'resultsMenu bar'},
  197. this.summaryMenuItem = this.createDom('a', {className: 'summaryMenuItem', href: "#"}, '0 specs'),
  198. ' | ',
  199. this.detailsMenuItem = this.createDom('a', {className: 'detailsMenuItem', href: "#"}, '0 failing'));
  200. this.summaryMenuItem.onclick = function() {
  201. dom.reporter.className = dom.reporter.className.replace(/ showDetails/g, '');
  202. };
  203. this.detailsMenuItem.onclick = function() {
  204. showDetails();
  205. };
  206. };
  207. this.addSpecs = function(specs, specFilter) {
  208. this.totalSpecCount = specs.length;
  209. this.views = {
  210. specs: {},
  211. suites: {}
  212. };
  213. for (var i = 0; i < specs.length; i++) {
  214. var spec = specs[i];
  215. this.views.specs[spec.id] = new jasmine.HtmlReporter.SpecView(spec, dom, this.views);
  216. if (specFilter(spec)) {
  217. this.runningSpecCount++;
  218. }
  219. }
  220. };
  221. this.specComplete = function(spec) {
  222. this.completeSpecCount++;
  223. if (isUndefined(this.views.specs[spec.id])) {
  224. this.views.specs[spec.id] = new jasmine.HtmlReporter.SpecView(spec, dom);
  225. }
  226. var specView = this.views.specs[spec.id];
  227. switch (specView.status()) {
  228. case 'passed':
  229. this.passedCount++;
  230. break;
  231. case 'failed':
  232. this.failedCount++;
  233. break;
  234. case 'skipped':
  235. this.skippedCount++;
  236. break;
  237. }
  238. specView.refresh();
  239. this.refresh();
  240. };
  241. this.suiteComplete = function(suite) {
  242. var suiteView = this.views.suites[suite.id];
  243. if (isUndefined(suiteView)) {
  244. return;
  245. }
  246. suiteView.refresh();
  247. };
  248. this.refresh = function() {
  249. if (isUndefined(this.resultsMenu)) {
  250. this.createResultsMenu();
  251. }
  252. // currently running UI
  253. if (isUndefined(this.runningAlert)) {
  254. this.runningAlert = this.createDom('a', { href: jasmine.HtmlReporter.sectionLink(), className: "runningAlert bar" });
  255. dom.alert.appendChild(this.runningAlert);
  256. }
  257. this.runningAlert.innerHTML = "Running " + this.completeSpecCount + " of " + specPluralizedFor(this.totalSpecCount);
  258. // skipped specs UI
  259. if (isUndefined(this.skippedAlert)) {
  260. this.skippedAlert = this.createDom('a', { href: jasmine.HtmlReporter.sectionLink(), className: "skippedAlert bar" });
  261. }
  262. this.skippedAlert.innerHTML = "Skipping " + this.skippedCount + " of " + specPluralizedFor(this.totalSpecCount) + " - run all";
  263. if (this.skippedCount === 1 && isDefined(dom.alert)) {
  264. dom.alert.appendChild(this.skippedAlert);
  265. }
  266. // passing specs UI
  267. if (isUndefined(this.passedAlert)) {
  268. this.passedAlert = this.createDom('span', { href: jasmine.HtmlReporter.sectionLink(), className: "passingAlert bar" });
  269. }
  270. this.passedAlert.innerHTML = "Passing " + specPluralizedFor(this.passedCount);
  271. // failing specs UI
  272. if (isUndefined(this.failedAlert)) {
  273. this.failedAlert = this.createDom('span', {href: "?", className: "failingAlert bar"});
  274. }
  275. this.failedAlert.innerHTML = "Failing " + specPluralizedFor(this.failedCount);
  276. if (this.failedCount === 1 && isDefined(dom.alert)) {
  277. dom.alert.appendChild(this.failedAlert);
  278. dom.alert.appendChild(this.resultsMenu);
  279. }
  280. // summary info
  281. this.summaryMenuItem.innerHTML = "" + specPluralizedFor(this.runningSpecCount);
  282. this.detailsMenuItem.innerHTML = "" + this.failedCount + " failing";
  283. };
  284. this.complete = function() {
  285. dom.alert.removeChild(this.runningAlert);
  286. this.skippedAlert.innerHTML = "Ran " + this.runningSpecCount + " of " + specPluralizedFor(this.totalSpecCount) + " - run all";
  287. if (this.failedCount === 0) {
  288. dom.alert.appendChild(this.createDom('span', {className: 'passingAlert bar'}, "Passing " + specPluralizedFor(this.passedCount)));
  289. } else {
  290. showDetails();
  291. }
  292. dom.banner.appendChild(this.createDom('span', {className: 'duration'}, "finished in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s"));
  293. };
  294. return this;
  295. function showDetails() {
  296. if (dom.reporter.className.search(/showDetails/) === -1) {
  297. dom.reporter.className += " showDetails";
  298. }
  299. }
  300. function isUndefined(obj) {
  301. return typeof obj === 'undefined';
  302. }
  303. function isDefined(obj) {
  304. return !isUndefined(obj);
  305. }
  306. function specPluralizedFor(count) {
  307. var str = count + " spec";
  308. if (count > 1) {
  309. str += "s"
  310. }
  311. return str;
  312. }
  313. };
  314. jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.ReporterView);
  315. jasmine.HtmlReporter.SpecView = function(spec, dom, views) {
  316. this.spec = spec;
  317. this.dom = dom;
  318. this.views = views;
  319. this.symbol = this.createDom('li', { className: 'pending' });
  320. this.dom.symbolSummary.appendChild(this.symbol);
  321. this.summary = this.createDom('div', { className: 'specSummary' },
  322. this.createDom('a', {
  323. className: 'description',
  324. href: jasmine.HtmlReporter.sectionLink(this.spec.getFullName()),
  325. title: this.spec.getFullName()
  326. }, this.spec.description)
  327. );
  328. this.detail = this.createDom('div', { className: 'specDetail' },
  329. this.createDom('a', {
  330. className: 'description',
  331. href: '?spec=' + encodeURIComponent(this.spec.getFullName()),
  332. title: this.spec.getFullName()
  333. }, this.spec.getFullName())
  334. );
  335. };
  336. jasmine.HtmlReporter.SpecView.prototype.status = function() {
  337. return this.getSpecStatus(this.spec);
  338. };
  339. jasmine.HtmlReporter.SpecView.prototype.refresh = function() {
  340. this.symbol.className = this.status();
  341. switch (this.status()) {
  342. case 'skipped':
  343. break;
  344. case 'passed':
  345. this.appendSummaryToSuiteDiv();
  346. break;
  347. case 'failed':
  348. this.appendSummaryToSuiteDiv();
  349. this.appendFailureDetail();
  350. break;
  351. }
  352. };
  353. jasmine.HtmlReporter.SpecView.prototype.appendSummaryToSuiteDiv = function() {
  354. this.summary.className += ' ' + this.status();
  355. this.appendToSummary(this.spec, this.summary);
  356. };
  357. jasmine.HtmlReporter.SpecView.prototype.appendFailureDetail = function() {
  358. this.detail.className += ' ' + this.status();
  359. var resultItems = this.spec.results().getItems();
  360. var messagesDiv = this.createDom('div', { className: 'messages' });
  361. for (var i = 0; i < resultItems.length; i++) {
  362. var result = resultItems[i];
  363. if (result.type == 'log') {
  364. messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString()));
  365. } else if (result.type == 'expect' && result.passed && !result.passed()) {
  366. messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
  367. if (result.trace.stack) {
  368. messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
  369. }
  370. }
  371. }
  372. if (messagesDiv.childNodes.length > 0) {
  373. this.detail.appendChild(messagesDiv);
  374. this.dom.details.appendChild(this.detail);
  375. }
  376. };
  377. jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.SpecView);jasmine.HtmlReporter.SuiteView = function(suite, dom, views) {
  378. this.suite = suite;
  379. this.dom = dom;
  380. this.views = views;
  381. this.element = this.createDom('div', { className: 'suite' },
  382. this.createDom('a', { className: 'description', href: jasmine.HtmlReporter.sectionLink(this.suite.getFullName()) }, this.suite.description)
  383. );
  384. this.appendToSummary(this.suite, this.element);
  385. };
  386. jasmine.HtmlReporter.SuiteView.prototype.status = function() {
  387. return this.getSpecStatus(this.suite);
  388. };
  389. jasmine.HtmlReporter.SuiteView.prototype.refresh = function() {
  390. this.element.className += " " + this.status();
  391. };
  392. jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.SuiteView);
  393. /* @deprecated Use jasmine.HtmlReporter instead
  394. */
  395. jasmine.TrivialReporter = function(doc) {
  396. this.document = doc || document;
  397. this.suiteDivs = {};
  398. this.logRunningSpecs = false;
  399. };
  400. jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarArgs) {
  401. var el = document.createElement(type);
  402. for (var i = 2; i < arguments.length; i++) {
  403. var child = arguments[i];
  404. if (typeof child === 'string') {
  405. el.appendChild(document.createTextNode(child));
  406. } else {
  407. if (child) { el.appendChild(child); }
  408. }
  409. }
  410. for (var attr in attrs) {
  411. if (attr == "className") {
  412. el[attr] = attrs[attr];
  413. } else {
  414. el.setAttribute(attr, attrs[attr]);
  415. }
  416. }
  417. return el;
  418. };
  419. jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
  420. var showPassed, showSkipped;
  421. this.outerDiv = this.createDom('div', { id: 'TrivialReporter', className: 'jasmine_reporter' },
  422. this.createDom('div', { className: 'banner' },
  423. this.createDom('div', { className: 'logo' },
  424. this.createDom('span', { className: 'title' }, "Jasmine"),
  425. this.createDom('span', { className: 'version' }, runner.env.versionString())),
  426. this.createDom('div', { className: 'options' },
  427. "Show ",
  428. showPassed = this.createDom('input', { id: "__jasmine_TrivialReporter_showPassed__", type: 'checkbox' }),
  429. this.createDom('label', { "for": "__jasmine_TrivialReporter_showPassed__" }, " passed "),
  430. showSkipped = this.createDom('input', { id: "__jasmine_TrivialReporter_showSkipped__", type: 'checkbox' }),
  431. this.createDom('label', { "for": "__jasmine_TrivialReporter_showSkipped__" }, " skipped")
  432. )
  433. ),
  434. this.runnerDiv = this.createDom('div', { className: 'runner running' },
  435. this.createDom('a', { className: 'run_spec', href: '?' }, "run all"),
  436. this.runnerMessageSpan = this.createDom('span', {}, "Running..."),
  437. this.finishedAtSpan = this.createDom('span', { className: 'finished-at' }, ""))
  438. );
  439. this.document.body.appendChild(this.outerDiv);
  440. var suites = runner.suites();
  441. for (var i = 0; i < suites.length; i++) {
  442. var suite = suites[i];
  443. var suiteDiv = this.createDom('div', { className: 'suite' },
  444. this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, "run"),
  445. this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, suite.description));
  446. this.suiteDivs[suite.id] = suiteDiv;
  447. var parentDiv = this.outerDiv;
  448. if (suite.parentSuite) {
  449. parentDiv = this.suiteDivs[suite.parentSuite.id];
  450. }
  451. parentDiv.appendChild(suiteDiv);
  452. }
  453. this.startedAt = new Date();
  454. var self = this;
  455. showPassed.onclick = function(evt) {
  456. if (showPassed.checked) {
  457. self.outerDiv.className += ' show-passed';
  458. } else {
  459. self.outerDiv.className = self.outerDiv.className.replace(/ show-passed/, '');
  460. }
  461. };
  462. showSkipped.onclick = function(evt) {
  463. if (showSkipped.checked) {
  464. self.outerDiv.className += ' show-skipped';
  465. } else {
  466. self.outerDiv.className = self.outerDiv.className.replace(/ show-skipped/, '');
  467. }
  468. };
  469. };
  470. jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) {
  471. var results = runner.results();
  472. var className = (results.failedCount > 0) ? "runner failed" : "runner passed";
  473. this.runnerDiv.setAttribute("class", className);
  474. //do it twice for IE
  475. this.runnerDiv.setAttribute("className", className);
  476. var specs = runner.specs();
  477. var specCount = 0;
  478. for (var i = 0; i < specs.length; i++) {
  479. if (this.specFilter(specs[i])) {
  480. specCount++;
  481. }
  482. }
  483. var message = "" + specCount + " spec" + (specCount == 1 ? "" : "s" ) + ", " + results.failedCount + " failure" + ((results.failedCount == 1) ? "" : "s");
  484. message += " in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s";
  485. this.runnerMessageSpan.replaceChild(this.createDom('a', { className: 'description', href: '?'}, message), this.runnerMessageSpan.firstChild);
  486. this.finishedAtSpan.appendChild(document.createTextNode("Finished at " + new Date().toString()));
  487. };
  488. jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) {
  489. var results = suite.results();
  490. var status = results.passed() ? 'passed' : 'failed';
  491. if (results.totalCount === 0) { // todo: change this to check results.skipped
  492. status = 'skipped';
  493. }
  494. this.suiteDivs[suite.id].className += " " + status;
  495. };
  496. jasmine.TrivialReporter.prototype.reportSpecStarting = function(spec) {
  497. if (this.logRunningSpecs) {
  498. this.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
  499. }
  500. };
  501. jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) {
  502. var results = spec.results();
  503. var status = results.passed() ? 'passed' : 'failed';
  504. if (results.skipped) {
  505. status = 'skipped';
  506. }
  507. var specDiv = this.createDom('div', { className: 'spec ' + status },
  508. this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(spec.getFullName()) }, "run"),
  509. this.createDom('a', {
  510. className: 'description',
  511. href: '?spec=' + encodeURIComponent(spec.getFullName()),
  512. title: spec.getFullName()
  513. }, spec.description));
  514. var resultItems = results.getItems();
  515. var messagesDiv = this.createDom('div', { className: 'messages' });
  516. for (var i = 0; i < resultItems.length; i++) {
  517. var result = resultItems[i];
  518. if (result.type == 'log') {
  519. messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString()));
  520. } else if (result.type == 'expect' && result.passed && !result.passed()) {
  521. messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
  522. if (result.trace.stack) {
  523. messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
  524. }
  525. }
  526. }
  527. if (messagesDiv.childNodes.length > 0) {
  528. specDiv.appendChild(messagesDiv);
  529. }
  530. this.suiteDivs[spec.suite.id].appendChild(specDiv);
  531. };
  532. jasmine.TrivialReporter.prototype.log = function() {
  533. var console = jasmine.getGlobal().console;
  534. if (console && console.log) {
  535. if (console.log.apply) {
  536. console.log.apply(console, arguments);
  537. } else {
  538. console.log(arguments); // ie fix: console.log.apply doesn't exist on ie
  539. }
  540. }
  541. };
  542. jasmine.TrivialReporter.prototype.getLocation = function() {
  543. return this.document.location;
  544. };
  545. jasmine.TrivialReporter.prototype.specFilter = function(spec) {
  546. var paramMap = {};
  547. var params = this.getLocation().search.substring(1).split('&');
  548. for (var i = 0; i < params.length; i++) {
  549. var p = params[i].split('=');
  550. paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
  551. }
  552. if (!paramMap.spec) {
  553. return true;
  554. }
  555. return spec.getFullName().indexOf(paramMap.spec) === 0;
  556. };