runner-browser-options.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. // setup style tags with less and link tags pointing to expected css output
  16. for (var i = 0; i < testFiles.length; i++) {
  17. var file = testFiles[i],
  18. lessPath = '/test/less/' + file + '.less',
  19. cssPath = '/test/css/' + file + '.css',
  20. lessStyle = document.createElement('style'),
  21. cssLink = document.createElement('link'),
  22. lessText = '@import "' + lessPath + '";';
  23. lessStyle.type = 'text/less';
  24. lessStyle.id = file;
  25. lessStyle.href = file;
  26. if (lessStyle.styleSheet === undefined) {
  27. lessStyle.appendChild(document.createTextNode(lessText));
  28. }
  29. cssLink.rel = 'stylesheet';
  30. cssLink.type = 'text/css';
  31. cssLink.href = cssPath;
  32. cssLink.id = 'expected-' + file;
  33. var head = document.getElementsByTagName('head')[0];
  34. head.appendChild(lessStyle);
  35. if (lessStyle.styleSheet) {
  36. lessStyle.styleSheet.cssText = lessText;
  37. }
  38. head.appendChild(cssLink);
  39. testSheets[i] = lessStyle;
  40. }