runner-browser-options.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. var less = {
  2. logLevel: 4,
  3. errorReporting: 'console',
  4. javascriptEnabled: true,
  5. math: 'always'
  6. };
  7. // There originally run inside describe method. However, since they have not
  8. // been inside it, they run at jasmine compile time (not runtime). It all
  9. // worked cause less.js was in async mode and custom phantom runner had
  10. // different setup then grunt-contrib-jasmine. They have been created before
  11. // less.js run, even as they have been defined in spec.
  12. // test inline less in style tags by grabbing an assortment of less files and doing `@import`s
  13. var testFiles = ['charsets', 'colors', 'comments', 'css-3', 'strings', 'media', 'mixins'],
  14. testSheets = [];
  15. // IE 8-10 does not support less in style tags
  16. if (window.navigator.userAgent.indexOf('MSIE') >= 0) {
  17. testFiles.length = 0;
  18. }
  19. // setup style tags with less and link tags pointing to expected css output
  20. for (var i = 0; i < testFiles.length; i++) {
  21. var file = testFiles[i],
  22. lessPath = '/test/less/' + file + '.less',
  23. cssPath = '/test/css/' + file + '.css',
  24. lessStyle = document.createElement('style'),
  25. cssLink = document.createElement('link'),
  26. lessText = '@import "' + lessPath + '";';
  27. lessStyle.type = 'text/less';
  28. lessStyle.id = file;
  29. lessStyle.href = file;
  30. if (lessStyle.styleSheet === undefined) {
  31. lessStyle.appendChild(document.createTextNode(lessText));
  32. }
  33. cssLink.rel = 'stylesheet';
  34. cssLink.type = 'text/css';
  35. cssLink.href = cssPath;
  36. cssLink.id = 'expected-' + file;
  37. var head = document.getElementsByTagName('head')[0];
  38. head.appendChild(lessStyle);
  39. if (lessStyle.styleSheet) {
  40. lessStyle.styleSheet.cssText = lessText;
  41. }
  42. head.appendChild(cssLink);
  43. testSheets[i] = lessStyle;
  44. }