jasmine-boot.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * Javascript code in this page
  4. *
  5. * Copyright 2017 Mozilla Foundation
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. *
  19. * @licend The above is the entire license notice for the
  20. * Javascript code in this page
  21. */
  22. 'use strict';
  23. function initializePDFJS(callback) {
  24. Promise.all(['pdfjs/display/global', 'pdfjs/display/api', 'pdfjs/display/network', 'pdfjs/display/fetch_stream', 'pdfjs-test/unit/annotation_spec', 'pdfjs-test/unit/api_spec', 'pdfjs-test/unit/bidi_spec', 'pdfjs-test/unit/cff_parser_spec', 'pdfjs-test/unit/cmap_spec', 'pdfjs-test/unit/colorspace_spec', 'pdfjs-test/unit/crypto_spec', 'pdfjs-test/unit/custom_spec', 'pdfjs-test/unit/display_svg_spec', 'pdfjs-test/unit/document_spec', 'pdfjs-test/unit/dom_utils_spec', 'pdfjs-test/unit/encodings_spec', 'pdfjs-test/unit/evaluator_spec', 'pdfjs-test/unit/fonts_spec', 'pdfjs-test/unit/function_spec', 'pdfjs-test/unit/metadata_spec', 'pdfjs-test/unit/murmurhash3_spec', 'pdfjs-test/unit/network_spec', 'pdfjs-test/unit/network_utils_spec', 'pdfjs-test/unit/parser_spec', 'pdfjs-test/unit/pdf_history_spec', 'pdfjs-test/unit/primitives_spec', 'pdfjs-test/unit/stream_spec', 'pdfjs-test/unit/type1_parser_spec', 'pdfjs-test/unit/ui_utils_spec', 'pdfjs-test/unit/unicode_spec', 'pdfjs-test/unit/util_spec', 'pdfjs-test/unit/util_stream_spec'].map(function (moduleName) {
  25. return SystemJS.import(moduleName);
  26. })).then(function (modules) {
  27. var displayGlobal = modules[0];
  28. var displayApi = modules[1];
  29. var PDFNetworkStream = modules[2].PDFNetworkStream;
  30. var PDFFetchStream = modules[3].PDFFetchStream;
  31. if (typeof Response !== 'undefined' && 'body' in Response.prototype && typeof ReadableStream !== 'undefined') {
  32. displayApi.setPDFNetworkStreamClass(PDFFetchStream);
  33. } else {
  34. displayApi.setPDFNetworkStreamClass(PDFNetworkStream);
  35. }
  36. displayGlobal.PDFJS.workerSrc = '../../build/generic/build/pdf.worker.js';
  37. callback();
  38. });
  39. }
  40. (function () {
  41. window.jasmine = jasmineRequire.core(jasmineRequire);
  42. jasmineRequire.html(jasmine);
  43. var env = jasmine.getEnv();
  44. var jasmineInterface = jasmineRequire.interface(jasmine, env);
  45. extend(window, jasmineInterface);
  46. var queryString = new jasmine.QueryString({
  47. getWindowLocation: function getWindowLocation() {
  48. return window.location;
  49. }
  50. });
  51. var catchingExceptions = queryString.getParam('catch');
  52. env.catchExceptions(typeof catchingExceptions === 'undefined' ? true : catchingExceptions);
  53. var throwingExpectationFailures = queryString.getParam('throwFailures');
  54. env.throwOnExpectationFailure(throwingExpectationFailures);
  55. var random = queryString.getParam('random');
  56. env.randomizeTests(random);
  57. var seed = queryString.getParam('seed');
  58. if (seed) {
  59. env.seed(seed);
  60. }
  61. var htmlReporter = new jasmine.HtmlReporter({
  62. env: env,
  63. onRaiseExceptionsClick: function onRaiseExceptionsClick() {
  64. queryString.navigateWithNewParam('catch', !env.catchingExceptions());
  65. },
  66. onThrowExpectationsClick: function onThrowExpectationsClick() {
  67. queryString.navigateWithNewParam('throwFailures', !env.throwingExpectationFailures());
  68. },
  69. onRandomClick: function onRandomClick() {
  70. queryString.navigateWithNewParam('random', !env.randomTests());
  71. },
  72. addToExistingQueryString: function addToExistingQueryString(key, value) {
  73. return queryString.fullStringWithNewParam(key, value);
  74. },
  75. getContainer: function getContainer() {
  76. return document.body;
  77. },
  78. createElement: function createElement() {
  79. return document.createElement.apply(document, arguments);
  80. },
  81. createTextNode: function createTextNode() {
  82. return document.createTextNode.apply(document, arguments);
  83. },
  84. timer: new jasmine.Timer()
  85. });
  86. env.addReporter(htmlReporter);
  87. if (queryString.getParam('browser')) {
  88. var testReporter = new TestReporter(queryString.getParam('browser'), queryString.getParam('path'));
  89. env.addReporter(testReporter);
  90. }
  91. var specFilter = new jasmine.HtmlSpecFilter({
  92. filterString: function filterString() {
  93. return queryString.getParam('spec');
  94. }
  95. });
  96. env.specFilter = function (spec) {
  97. return specFilter.matches(spec.getFullName());
  98. };
  99. jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000;
  100. var currentWindowOnload = window.onload;
  101. window.onload = function () {
  102. if (currentWindowOnload) {
  103. currentWindowOnload();
  104. }
  105. initializePDFJS(function () {
  106. htmlReporter.initialize();
  107. env.execute();
  108. });
  109. };
  110. function extend(destination, source) {
  111. for (var property in source) {
  112. destination[property] = source[property];
  113. }
  114. return destination;
  115. }
  116. })();