mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 973741 - Linked CSS file path is wrong when server directory is same as file directory; r=pbrosset
--HG-- rename : browser/devtools/styleeditor/test/sourcemaps.css => browser/devtools/styleeditor/test/sourcemap-css/sourcemaps.css rename : browser/devtools/styleeditor/test/sourcemaps.css.map => browser/devtools/styleeditor/test/sourcemap-css/sourcemaps.css.map rename : browser/devtools/styleeditor/test/sourcemaps.scss => browser/devtools/styleeditor/test/sourcemap-sass/sourcemaps.scss
This commit is contained in:
parent
615adf2978
commit
8bf79f98a8
@ -497,6 +497,10 @@ StyleSheetEditor.prototype = {
|
||||
markLinkedFileBroken: function(error) {
|
||||
this.linkedCSSFileError = error || true;
|
||||
this.emit("linked-css-file-error");
|
||||
|
||||
error += " querying " + this.linkedCSSFile +
|
||||
" original source location: " + this.savedFile.path
|
||||
Cu.reportError(error);
|
||||
},
|
||||
|
||||
/**
|
||||
@ -616,10 +620,20 @@ function prettifyCSS(text)
|
||||
* Find a path on disk for a file given it's hosted uri, the uri of the
|
||||
* original resource that generated it (e.g. Sass file), and the location of the
|
||||
* local file for that source.
|
||||
*
|
||||
* @param {nsIURI} uri
|
||||
* The uri of the resource
|
||||
* @param {nsIURI} origUri
|
||||
* The uri of the original source for the resource
|
||||
* @param {nsIFile} file
|
||||
* The local file for the resource on disk
|
||||
*
|
||||
* @return {string}
|
||||
* The path of original file on disk
|
||||
*/
|
||||
function findLinkedFilePath(uri, origUri, file) {
|
||||
let project = findProjectPath(origUri, file);
|
||||
let branch = findUnsharedBranch(origUri, uri);
|
||||
let { origBranch, branch } = findUnsharedBranches(origUri, uri);
|
||||
let project = findProjectPath(file, origBranch);
|
||||
|
||||
let parts = project.concat(branch);
|
||||
let path = OS.Path.join.apply(this, parts);
|
||||
@ -628,57 +642,58 @@ function findLinkedFilePath(uri, origUri, file) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the path of a project given a file in the project and the uri
|
||||
* of that resource. e.g.:
|
||||
* "http://localhost/src/a.css" and "/Users/moz/proj/src/a.css"
|
||||
* would yeild ["Users", "moz", "proj"]
|
||||
* Find the path of a project given a file in the project and its branch
|
||||
* off the root. e.g.:
|
||||
* /Users/moz/proj/src/a.css" and "src/a.css"
|
||||
* would yield ["Users", "moz", "proj"]
|
||||
*
|
||||
* @param {nsIURI} uri
|
||||
* uri of hosted resource
|
||||
* @param {nsIFile} file
|
||||
* file for that resource on disk
|
||||
* @param {array} branch
|
||||
* path parts for branch to chop off file path.
|
||||
* @return {array}
|
||||
* array of path parts
|
||||
*/
|
||||
function findProjectPath(uri, file) {
|
||||
let uri = OS.Path.split(uri.path).components;
|
||||
function findProjectPath(file, branch) {
|
||||
let path = OS.Path.split(file.path).components;
|
||||
|
||||
// don't care about differing leaf names
|
||||
uri.pop();
|
||||
path.pop();
|
||||
|
||||
let dir = path.pop();
|
||||
while(dir) {
|
||||
let serverDir = uri.pop();
|
||||
if (serverDir != dir) {
|
||||
return path.concat([dir]);
|
||||
for (let i = 2; i <= branch.length; i++) {
|
||||
// work backwards until we find a differing directory name
|
||||
if (path[path.length - i] != branch[branch.length - i]) {
|
||||
return path.slice(0, path.length - i + 1);
|
||||
}
|
||||
dir = path.pop();
|
||||
}
|
||||
return [];
|
||||
|
||||
// if we don't find a differing directory, just chop off the branch
|
||||
return path.slice(0, path.length - branch.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the part of a uri past the root it shares with another uri. e.g:
|
||||
* Find the parts of a uri past the root it shares with another uri. e.g:
|
||||
* "http://localhost/built/a.scss" and "http://localhost/src/a.css"
|
||||
* would yeild ["built", "a.scss"];
|
||||
* would yield ["built", "a.scss"] and ["src", "a.css"]
|
||||
*
|
||||
* @param {nsIURI} origUri
|
||||
* uri to find unshared branch of
|
||||
* @param {nsIURI} origUri
|
||||
* uri to find unshared branch of. Usually is uri for original source.
|
||||
* @param {nsIURI} uri
|
||||
* uri to compare against to get a shared root
|
||||
* @return {array}
|
||||
* array of path parts for branch
|
||||
* @return {object}
|
||||
* object with 'branch' and 'origBranch' array of path parts for branch
|
||||
*/
|
||||
function findUnsharedBranch(origUri, uri) {
|
||||
function findUnsharedBranches(origUri, uri) {
|
||||
origUri = OS.Path.split(origUri.path).components;
|
||||
uri = OS.Path.split(uri.path).components;
|
||||
|
||||
for (var i = 0; i < uri.length - 1; i++) {
|
||||
for (let i = 0; i < uri.length - 1; i++) {
|
||||
if (uri[i] != origUri[i]) {
|
||||
return uri.slice(i);
|
||||
return {
|
||||
branch: uri.slice(i),
|
||||
origBranch: origUri.slice(i)
|
||||
};
|
||||
}
|
||||
}
|
||||
return uri;
|
||||
return {
|
||||
branch: uri,
|
||||
origBranch: origUri
|
||||
};
|
||||
}
|
||||
|
@ -22,9 +22,9 @@ support-files =
|
||||
simple.css.gz^headers^
|
||||
simple.gz.html
|
||||
simple.html
|
||||
sourcemaps.css
|
||||
sourcemaps.css.map
|
||||
sourcemaps.scss
|
||||
sourcemap-css/sourcemaps.css
|
||||
sourcemap-css/sourcemaps.css.map
|
||||
sourcemap-sass/sourcemaps.scss
|
||||
sourcemaps.html
|
||||
test_private.css
|
||||
test_private.html
|
||||
|
@ -7,10 +7,10 @@ let {devtools} = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
|
||||
let promise = devtools.require("sdk/core/promise");
|
||||
|
||||
const TESTCASE_URI_HTML = TEST_BASE + "sourcemaps.html";
|
||||
const TESTCASE_URI_CSS = TEST_BASE + "sourcemaps.css";
|
||||
const TESTCASE_URI_CSS = TEST_BASE + "sourcemap-css/sourcemaps.css";
|
||||
const TESTCASE_URI_REG_CSS = TEST_BASE + "simple.css";
|
||||
const TESTCASE_URI_SCSS = TEST_BASE + "sourcemaps.scss";
|
||||
const TESTCASE_URI_MAP = TEST_BASE + "sourcemaps.css.map";
|
||||
const TESTCASE_URI_SCSS = TEST_BASE + "sourcemap-sass/sourcemaps.scss";
|
||||
const TESTCASE_URI_MAP = TEST_BASE + "sourcemap-css/sourcemaps.css.map";
|
||||
|
||||
const PREF = "devtools.styleeditor.source-maps-enabled";
|
||||
|
||||
@ -33,11 +33,11 @@ function test()
|
||||
|
||||
Task.spawn(function() {
|
||||
// copy all our files over so we don't screw them up for other tests
|
||||
let HTMLFile = yield copy(TESTCASE_URI_HTML, "sourcemaps.html");
|
||||
let CSSFile = yield copy(TESTCASE_URI_CSS, "sourcemaps.css");
|
||||
yield copy(TESTCASE_URI_SCSS, "sourcemaps.scss");
|
||||
yield copy(TESTCASE_URI_MAP, "sourcemaps.css.map");
|
||||
yield copy(TESTCASE_URI_REG_CSS, "simple.css");
|
||||
let HTMLFile = yield copy(TESTCASE_URI_HTML, ["sourcemaps.html"]);
|
||||
let CSSFile = yield copy(TESTCASE_URI_CSS, ["sourcemap-css", "sourcemaps.css"]);
|
||||
yield copy(TESTCASE_URI_SCSS, ["sourcemap-sass", "sourcemaps.scss"]);
|
||||
yield copy(TESTCASE_URI_MAP, ["sourcemap-css", "sourcemaps.css.map"]);
|
||||
yield copy(TESTCASE_URI_REG_CSS, ["simple.css"]);
|
||||
|
||||
let uri = Services.io.newFileURI(HTMLFile);
|
||||
let testcaseURI = uri.resolve("");
|
||||
@ -136,9 +136,9 @@ function getStylesheetNameLinkFor(editor) {
|
||||
return editor.summary.querySelector(".stylesheet-name");
|
||||
}
|
||||
|
||||
function copy(aSrcChromeURL, aDestFileName)
|
||||
function copy(aSrcChromeURL, aDestFilePath)
|
||||
{
|
||||
let destFile = FileUtils.getFile("ProfD", [aDestFileName]);
|
||||
let destFile = FileUtils.getFile("ProfD", aDestFilePath);
|
||||
return write(read(aSrcChromeURL), destFile);
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
{
|
||||
"version": 3,
|
||||
"mappings": "AAGA,GAAI;EACF,KAAK,EAHU,OAAI;;AAMrB,IAAK;EACH,gBAAgB,EAAE,IAAI",
|
||||
"sources": ["sourcemaps.scss"],
|
||||
"names": [],
|
||||
"sources": ["../sourcemap-sass/sourcemaps.scss"],
|
||||
"file": "sourcemaps.css"
|
||||
}
|
@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<title>testcase for testing CSS source maps</title>
|
||||
<link rel="stylesheet" type="text/css" href="simple.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="sourcemaps.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="sourcemap-css/sourcemaps.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<div>source maps <span>testcase</span></div>
|
||||
|
Loading…
Reference in New Issue
Block a user