Skip to content

Commit

Permalink
Fix browser tests by moving url re-writing tests to urls.less. Also f…
Browse files Browse the repository at this point in the history
…ix browser rootpath.
  • Loading branch information
lukeapage committed Dec 28, 2012
1 parent 59258f5 commit addf87a
Show file tree
Hide file tree
Showing 15 changed files with 45 additions and 31 deletions.
2 changes: 1 addition & 1 deletion lib/less/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ function loadStyleSheet(sheet, callback, reload, remaining) {
var css = cache && cache.getItem(href);
var timestamp = cache && cache.getItem(href + ':timestamp');
var styles = { css: css, timestamp: timestamp };
var rootpath = sheet.rootpath || hrefParts.path;
var rootpath = hrefParts.path;

xhr(href, sheet.type, function (data, lastModified) {
// Store data this session
Expand Down
9 changes: 9 additions & 0 deletions test/browser/css/urls.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
@import "http://localhost:8081/browser/less/imports/modify-this.css";

@import "http://localhost:8081/browser/less/imports/modify-again.css";
.modify {
my-url: url("http://localhost:8081/browser/less/imports/a.png");
}
.modify {
my-url: url("http://localhost:8081/browser/less/imports/b.png");
}
@font-face {
src: url("/fonts/garamond-pro.ttf");
src: local(Futura-Medium), url(http://localhost:8081/browser/less/fonts.svg#MyGeometricModern) format("svg");
Expand Down
4 changes: 4 additions & 0 deletions test/browser/less/imports/urls.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@import "modify-this.css";
.modify {
my-url: url("a.png");
}
4 changes: 4 additions & 0 deletions test/browser/less/imports/urls2.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@import "modify-again.css";
.modify {
my-url: url("b.png");
}
2 changes: 2 additions & 0 deletions test/browser/less/urls.less
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import "imports/urls.less";
@import "http://localhost:8081/browser/less/imports/urls2.less";
@font-face {
src: url("/fonts/garamond-pro.ttf");
src: local(Futura-Medium),
Expand Down
3 changes: 0 additions & 3 deletions test/css/import-once.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
@import "import/import-test-d.css";

@import "import/deeper/../import-test-d.css";
#import {
color: #ff0000;
}
26 changes: 5 additions & 21 deletions test/css/import.css
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
@import "import/import-test-d.css";

@import url(http://fonts.googleapis.com/css?family=Open+Sans);

@import url(something.css) screen and (color) and (max-width: 600px);

@import "import/../css/background.css";
#import {
color: #ff0000;
}
.mixin {
height: 10px;
color: #ff0000;
}
#import-test {
height: 10px;
color: #ff0000;
Expand All @@ -23,15 +12,10 @@
width: 100%;
}
}
#logo {
width: 100px;
height: 100px;
background: url('import/imports/../assets/logo.png');
}
@font-face {
font-family: xecret;
src: url('import/imports/../assets/xecret.ttf');
#import {
color: #ff0000;
}
#secret {
font-family: xecret, sans-serif;
.mixin {
height: 10px;
color: #ff0000;
}
15 changes: 15 additions & 0 deletions test/css/urls.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
@import "import/../css/background.css";

@import "import/import-test-d.css";
@font-face {
src: url("/fonts/garamond-pro.ttf");
src: local(Futura-Medium), url(fonts.svg#MyGeometricModern) format("svg");
Expand Down Expand Up @@ -25,3 +28,15 @@
.values {
url: url('Trebuchet');
}
#logo {
width: 100px;
height: 100px;
background: url('import/imports/../assets/logo.png');
}
@font-face {
font-family: xecret;
src: url('import/imports/../assets/xecret.ttf');
}
#secret {
font-family: xecret, sans-serif;
}
2 changes: 1 addition & 1 deletion test/less/import-once.less
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import "import/import-once-test-c";
@import-once "import/import-once-test-c";
@import-once "import/import-once-test-c";
@import-once "import/import-once-test-c.less";
@import-once "import/deeper/import-once-test-a";
3 changes: 1 addition & 2 deletions test/less/import.less
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
@import url("import/import-test-a.less");
@import url(http://fonts.googleapis.com/css?family=Open+Sans);

@import url(something.css) screen and (color) and (max-width: 600px);
Expand All @@ -10,4 +9,4 @@
}
@import "import/import-test-e" screen and (max-width: 600px);

@import "import/import-and-relative-paths-test";
@import url("import/import-test-a.less");
1 change: 0 additions & 1 deletion test/less/import/deeper/import-once-test-a.less
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
@import-once "../import-test-d.css";
@import-once "../import-once-test-c";
1 change: 1 addition & 0 deletions test/less/import/import-and-relative-paths-test.less
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@import "../css/background.css";
@import "import-test-d.css";

@import "imports/logo";
@import "imports/font";
Expand Down
1 change: 0 additions & 1 deletion test/less/import/import-once-test-c.less
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

@import-once "import-test-d.css";
@c: red;

#import {
Expand Down
1 change: 0 additions & 1 deletion test/less/import/import-test-c.less
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

@import "import-test-d.css";
@c: red;

#import {
Expand Down
2 changes: 2 additions & 0 deletions test/less/urls.less
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@
@a: 'Trebuchet';
url: url(@a);
}

@import "import/import-and-relative-paths-test";

0 comments on commit addf87a

Please sign in to comment.