runner-browser-options.js 1.7 KB

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