Skip to content

Commit

Permalink
DevTools: automatic mapping detection is broken for cases with specif…
Browse files Browse the repository at this point in the history
…ic file paths.

BUG=595347

Review URL: https://codereview.chromium.org/1813943003

Cr-Commit-Position: refs/heads/master@{#382092}
(cherry picked from commit ca1179e)

Review URL: https://codereview.chromium.org/1822723002 .

Cr-Commit-Position: refs/branch-heads/2661@{crosswalk-project#310}
Cr-Branched-From: ef6f6ae-refs/heads/master@{#378081}
  • Loading branch information
pavelfeldman committed Mar 21, 2016
1 parent ecc5e56 commit 3477dc0
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,27 @@ Testing file system mapping.
- file:///home/username/projects/foo
- file:///home/username/projects/bar

Adding file system file:///home/username/project/build
Testing file system mapping.
file system paths:
- file:///home/username/projects/foo
- file:///home/username/projects/bar
- file:///home/username/project/build

Adding file system file:///www/site1
Testing file system mapping.
file system paths:
- file:///home/username/projects/foo
- file:///home/username/projects/bar
- file:///home/username/project/build
- file:///www/site1

Adding file mapping (file:///www/site1, http://localhost/, /)
Testing file system mapping.
file system paths:
- file:///home/username/projects/foo
- file:///home/username/projects/bar
- file:///home/username/project/build
- file:///www/site1
- {"fileSystemPath":"file:///www/site1","urlPrefix":"http://localhost/","pathPrefix":"/","configurable":true}

Expand All @@ -34,6 +43,7 @@ Testing file system mapping.
file system paths:
- file:///home/username/projects/foo
- file:///home/username/projects/bar
- file:///home/username/project/build
- file:///www/site1
- {"fileSystemPath":"file:///www/site1","urlPrefix":"http://localhost/","pathPrefix":"/","configurable":true}
- {"fileSystemPath":"file:///www/site1","urlPrefix":"http://www.foo.com/","pathPrefix":"/foo/","configurable":true}
Expand All @@ -44,6 +54,7 @@ Testing file system mapping.
- file:///home/username/projects/foo
- {"fileSystemPath":"file:///home/username/projects/foo","urlPrefix":"http://www.example.com/bar/","pathPrefix":"/foo/","configurable":true}
- file:///home/username/projects/bar
- file:///home/username/project/build
- file:///www/site1
- {"fileSystemPath":"file:///www/site1","urlPrefix":"http://localhost/","pathPrefix":"/","configurable":true}
- {"fileSystemPath":"file:///www/site1","urlPrefix":"http://www.foo.com/","pathPrefix":"/foo/","configurable":true}
Expand All @@ -55,6 +66,20 @@ Testing file system mapping.
- {"fileSystemPath":"file:///home/username/projects/foo","urlPrefix":"http://www.example.com/bar/","pathPrefix":"/foo/","configurable":true}
- {"fileSystemPath":"file:///home/username/projects/foo","urlPrefix":"http://www.bar.com/foo/","pathPrefix":"/baz/","configurable":true}
- file:///home/username/projects/bar
- file:///home/username/project/build
- file:///www/site1
- {"fileSystemPath":"file:///www/site1","urlPrefix":"http://localhost/","pathPrefix":"/","configurable":true}
- {"fileSystemPath":"file:///www/site1","urlPrefix":"http://www.foo.com/","pathPrefix":"/foo/","configurable":true}

Adding file mapping for resource (http://localhost:3333/build/layout.css, file:///home/username/project/build, file:///home/username/project/build/layout.css)
Testing file system mapping.
file system paths:
- file:///home/username/projects/foo
- {"fileSystemPath":"file:///home/username/projects/foo","urlPrefix":"http://www.example.com/bar/","pathPrefix":"/foo/","configurable":true}
- {"fileSystemPath":"file:///home/username/projects/foo","urlPrefix":"http://www.bar.com/foo/","pathPrefix":"/baz/","configurable":true}
- file:///home/username/projects/bar
- file:///home/username/project/build
- {"fileSystemPath":"file:///home/username/project/build","urlPrefix":"http://localhost:3333/build/","pathPrefix":"/","configurable":true}
- file:///www/site1
- {"fileSystemPath":"file:///www/site1","urlPrefix":"http://localhost/","pathPrefix":"/","configurable":true}
- {"fileSystemPath":"file:///www/site1","urlPrefix":"http://www.foo.com/","pathPrefix":"/foo/","configurable":true}
Expand All @@ -72,6 +97,8 @@ Testing mappings for url:
File for 'http://localhost:8080/index.html': null
Has mapping for 'http://localhost/': true
File for 'http://localhost/': file:///www/site1/
Has mapping for 'http://localhost:3333/build/main.css': true
File for 'http://localhost:3333/build/main.css': file:///home/username/project/build/main.css

Testing mappings for path:
URL for path 'file:///home/username/projects/foo/baz/folder/42.js': http://www.bar.com/foo/folder/42.js
Expand All @@ -91,6 +118,8 @@ Testing file system mapping.
- {"fileSystemPath":"file:///home/username/projects/foo","urlPrefix":"http://www.example.com/bar/","pathPrefix":"/foo/","configurable":true}
- {"fileSystemPath":"file:///home/username/projects/foo","urlPrefix":"http://www.bar.com/foo/","pathPrefix":"/baz/","configurable":true}
- file:///home/username/projects/bar
- file:///home/username/project/build
- {"fileSystemPath":"file:///home/username/project/build","urlPrefix":"http://localhost:3333/build/","pathPrefix":"/","configurable":true}
- file:///www/site1
- {"fileSystemPath":"file:///www/site1","urlPrefix":"http://localhost/","pathPrefix":"/","configurable":true}
- {"fileSystemPath":"file:///www/site1","urlPrefix":"http://www.foo.com/","pathPrefix":"/foo/","configurable":true}
Expand All @@ -101,6 +130,8 @@ Testing file system mapping.
- file:///home/username/projects/foo
- {"fileSystemPath":"file:///home/username/projects/foo","urlPrefix":"http://www.example.com/bar/","pathPrefix":"/foo/","configurable":true}
- file:///home/username/projects/bar
- file:///home/username/project/build
- {"fileSystemPath":"file:///home/username/project/build","urlPrefix":"http://localhost:3333/build/","pathPrefix":"/","configurable":true}
- file:///www/site1
- {"fileSystemPath":"file:///www/site1","urlPrefix":"http://localhost/","pathPrefix":"/","configurable":true}
- {"fileSystemPath":"file:///www/site1","urlPrefix":"http://www.foo.com/","pathPrefix":"/foo/","configurable":true}
Expand All @@ -111,6 +142,8 @@ Testing file system mapping.
- file:///home/username/projects/foo
- {"fileSystemPath":"file:///home/username/projects/foo","urlPrefix":"http://www.example.com/bar/","pathPrefix":"/foo/","configurable":true}
- file:///home/username/projects/bar
- file:///home/username/project/build
- {"fileSystemPath":"file:///home/username/project/build","urlPrefix":"http://localhost:3333/build/","pathPrefix":"/","configurable":true}
- file:///www/site1
- {"fileSystemPath":"file:///www/site1","urlPrefix":"http://www.foo.com/","pathPrefix":"/foo/","configurable":true}

Expand All @@ -120,28 +153,38 @@ Testing file system mapping.
- file:///home/username/projects/foo
- {"fileSystemPath":"file:///home/username/projects/foo","urlPrefix":"http://www.example.com/bar/","pathPrefix":"/foo/","configurable":true}
- file:///home/username/projects/bar
- file:///home/username/project/build
- {"fileSystemPath":"file:///home/username/project/build","urlPrefix":"http://localhost:3333/build/","pathPrefix":"/","configurable":true}
- file:///www/site1

Removing file mapping (file:///home/username/projects/foo, http://www.example.com/bar/, /foo/)
Testing file system mapping.
file system paths:
- file:///home/username/projects/foo
- file:///home/username/projects/bar
- file:///home/username/project/build
- {"fileSystemPath":"file:///home/username/project/build","urlPrefix":"http://localhost:3333/build/","pathPrefix":"/","configurable":true}
- file:///www/site1

Removing file system file:///www/site1
Testing file system mapping.
file system paths:
- file:///home/username/projects/foo
- file:///home/username/projects/bar
- file:///home/username/project/build
- {"fileSystemPath":"file:///home/username/project/build","urlPrefix":"http://localhost:3333/build/","pathPrefix":"/","configurable":true}

Removing file system file:///home/username/projects/foo
Testing file system mapping.
file system paths:
- file:///home/username/projects/bar
- file:///home/username/project/build
- {"fileSystemPath":"file:///home/username/project/build","urlPrefix":"http://localhost:3333/build/","pathPrefix":"/","configurable":true}

Removing file system file:///home/username/projects/bar
Testing file system mapping.
file system paths:
- file:///home/username/project/build
- {"fileSystemPath":"file:///home/username/project/build","urlPrefix":"http://localhost:3333/build/","pathPrefix":"/","configurable":true}


Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
var paths = {
FOO: "file:///home/username/projects/foo",
BAR: "file:///home/username/projects/bar",
BUILD: "file:///home/username/project/build",
SITE1: "file:///www/site1"
};

Expand Down Expand Up @@ -95,13 +96,15 @@
checkAndDumpFileSystemMapping(fileSystemMapping);
addFileSystem(fileSystemMapping, paths.FOO)
addFileSystem(fileSystemMapping, paths.BAR)
addFileSystem(fileSystemMapping, paths.BUILD)
addFileSystem(fileSystemMapping, paths.SITE1)

// Now fill it with file mappings.
addFileMapping(fileSystemMapping, paths.SITE1, "http://localhost/", "/");
addFileMapping(fileSystemMapping, paths.SITE1, "http://www.foo.com/", "/foo/");
addFileMapping(fileSystemMapping, paths.FOO, "http://www.example.com/bar/", "/foo/");
addMappingForResource(fileSystemMapping, "http://www.bar.com/foo/folder/42.js", paths.FOO, paths.FOO + "/baz/folder/42.js");
addMappingForResource(fileSystemMapping, "http://localhost:3333/build/layout.css", paths.BUILD, paths.BUILD + "/layout.css");

InspectorTest.addResult("Testing mappings for url:");
dumpFileForURL(fileSystemMapping, "http://www.bar.com/foo/folder/42.js");
Expand All @@ -110,6 +113,7 @@
dumpFileForURL(fileSystemMapping, "https://localhost/index.html");
dumpFileForURL(fileSystemMapping, "http://localhost:8080/index.html");
dumpFileForURL(fileSystemMapping, "http://localhost/");
dumpFileForURL(fileSystemMapping, "http://localhost:3333/build/main.css");
InspectorTest.addResult("");

InspectorTest.addResult("Testing mappings for path:");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,14 @@ WebInspector.FileSystemMapping.prototype = {
if (filePathCharacter === "/")
commonPathSuffixLength = i;
}
var pathPrefix = filePath.substring(fileSystemPath.length, filePath.length - commonPathSuffixLength);
var from = fileSystemPath.length;
var to = filePath.length - commonPathSuffixLength;
var pathPrefix = filePath.substring(from, to);
var urlPrefix = url.substr(0, url.length - commonPathSuffixLength);
this.addFileMapping(fileSystemPath, urlPrefix, pathPrefix);
if (to >= from)
this.addFileMapping(fileSystemPath, urlPrefix, pathPrefix);
else
this.addFileMapping(fileSystemPath, urlPrefix + pathPrefix, "/");
},

resetForTesting: function()
Expand Down

0 comments on commit 3477dc0

Please sign in to comment.