From addf87a75fad3c1d9e8ef9db8788b5c9ddade62e Mon Sep 17 00:00:00 2001 From: Luke Page Date: Fri, 28 Dec 2012 12:38:49 +0000 Subject: [PATCH] Fix browser tests by moving url re-writing tests to urls.less. Also fix browser rootpath. --- lib/less/browser.js | 2 +- test/browser/css/urls.css | 9 +++++++ test/browser/less/imports/urls.less | 4 +++ test/browser/less/imports/urls2.less | 4 +++ test/browser/less/urls.less | 2 ++ test/css/import-once.css | 3 --- test/css/import.css | 26 ++++--------------- test/css/urls.css | 15 +++++++++++ test/less/import-once.less | 2 +- test/less/import.less | 3 +-- .../import/deeper/import-once-test-a.less | 1 - .../import-and-relative-paths-test.less | 1 + test/less/import/import-once-test-c.less | 1 - test/less/import/import-test-c.less | 1 - test/less/urls.less | 2 ++ 15 files changed, 45 insertions(+), 31 deletions(-) create mode 100644 test/browser/less/imports/urls.less create mode 100644 test/browser/less/imports/urls2.less diff --git a/lib/less/browser.js b/lib/less/browser.js index 95888348b..d60c6e9b8 100644 --- a/lib/less/browser.js +++ b/lib/less/browser.js @@ -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 diff --git a/test/browser/css/urls.css b/test/browser/css/urls.css index a5cbe338c..8be6af865 100644 --- a/test/browser/css/urls.css +++ b/test/browser/css/urls.css @@ -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"); diff --git a/test/browser/less/imports/urls.less b/test/browser/less/imports/urls.less new file mode 100644 index 000000000..290e6b412 --- /dev/null +++ b/test/browser/less/imports/urls.less @@ -0,0 +1,4 @@ +@import "modify-this.css"; +.modify { + my-url: url("a.png"); +} \ No newline at end of file diff --git a/test/browser/less/imports/urls2.less b/test/browser/less/imports/urls2.less new file mode 100644 index 000000000..b834bb9e1 --- /dev/null +++ b/test/browser/less/imports/urls2.less @@ -0,0 +1,4 @@ +@import "modify-again.css"; +.modify { + my-url: url("b.png"); +} \ No newline at end of file diff --git a/test/browser/less/urls.less b/test/browser/less/urls.less index ea03447d6..c2040cf97 100644 --- a/test/browser/less/urls.less +++ b/test/browser/less/urls.less @@ -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), diff --git a/test/css/import-once.css b/test/css/import-once.css index b67269865..b2a15d312 100644 --- a/test/css/import-once.css +++ b/test/css/import-once.css @@ -1,6 +1,3 @@ -@import "import/import-test-d.css"; - -@import "import/deeper/../import-test-d.css"; #import { color: #ff0000; } diff --git a/test/css/import.css b/test/css/import.css index 8df052e1b..3ed7de535 100644 --- a/test/css/import.css +++ b/test/css/import.css @@ -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; @@ -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; } diff --git a/test/css/urls.css b/test/css/urls.css index c1cd8488f..6a8a4e98a 100644 --- a/test/css/urls.css +++ b/test/css/urls.css @@ -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"); @@ -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; +} diff --git a/test/less/import-once.less b/test/less/import-once.less index 1bcda77f6..5588be489 100644 --- a/test/less/import-once.less +++ b/test/less/import-once.less @@ -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"; diff --git a/test/less/import.less b/test/less/import.less index f66818c31..2a442ea94 100644 --- a/test/less/import.less +++ b/test/less/import.less @@ -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); @@ -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"); diff --git a/test/less/import/deeper/import-once-test-a.less b/test/less/import/deeper/import-once-test-a.less index 577ca4471..de2233d64 100644 --- a/test/less/import/deeper/import-once-test-a.less +++ b/test/less/import/deeper/import-once-test-a.less @@ -1,2 +1 @@ -@import-once "../import-test-d.css"; @import-once "../import-once-test-c"; \ No newline at end of file diff --git a/test/less/import/import-and-relative-paths-test.less b/test/less/import/import-and-relative-paths-test.less index b3af2bd52..da6999896 100644 --- a/test/less/import/import-and-relative-paths-test.less +++ b/test/less/import/import-and-relative-paths-test.less @@ -1,4 +1,5 @@ @import "../css/background.css"; +@import "import-test-d.css"; @import "imports/logo"; @import "imports/font"; diff --git a/test/less/import/import-once-test-c.less b/test/less/import/import-once-test-c.less index 838fabca6..686747a86 100644 --- a/test/less/import/import-once-test-c.less +++ b/test/less/import/import-once-test-c.less @@ -1,5 +1,4 @@ -@import-once "import-test-d.css"; @c: red; #import { diff --git a/test/less/import/import-test-c.less b/test/less/import/import-test-c.less index 111266ba8..686747a86 100644 --- a/test/less/import/import-test-c.less +++ b/test/less/import/import-test-c.less @@ -1,5 +1,4 @@ -@import "import-test-d.css"; @c: red; #import { diff --git a/test/less/urls.less b/test/less/urls.less index ea03447d6..93ec41226 100644 --- a/test/less/urls.less +++ b/test/less/urls.less @@ -29,3 +29,5 @@ @a: 'Trebuchet'; url: url(@a); } + +@import "import/import-and-relative-paths-test";