From 4c10b5ff4c75226f7dd7f41cf77d1a53250d4762 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Tue, 27 Feb 2024 16:20:27 -0800 Subject: [PATCH 01/68] Initial commit --- version-not-a-number.map | 6 ++++++ version-numbers.js | 6 ++++++ version-too-high.map | 6 ++++++ version-too-low.map | 6 ++++++ version-valid.map | 6 ++++++ 5 files changed, 30 insertions(+) create mode 100644 version-not-a-number.map create mode 100644 version-numbers.js create mode 100644 version-too-high.map create mode 100644 version-too-low.map create mode 100644 version-valid.map diff --git a/version-not-a-number.map b/version-not-a-number.map new file mode 100644 index 0000000..b81e58e --- /dev/null +++ b/version-not-a-number.map @@ -0,0 +1,6 @@ +{ + "version" : "3foo", + "sources": [], + "names": [], + "mappings": "", +} diff --git a/version-numbers.js b/version-numbers.js new file mode 100644 index 0000000..e79993b --- /dev/null +++ b/version-numbers.js @@ -0,0 +1,6 @@ +// Test that invalid version numbers are rejected. + +assert(isValidSourceMap("./version-valid.map")); +assert(!isValidSourceMap("./version-not-a-number.map")); +assert(!isValidSourceMap("./version-too-low.map")); +assert(!isValidSourceMap("./version-too-high.map")); diff --git a/version-too-high.map b/version-too-high.map new file mode 100644 index 0000000..fcf83f0 --- /dev/null +++ b/version-too-high.map @@ -0,0 +1,6 @@ +{ + "version" : 4, + "sources": [], + "names": [], + "mappings": "", +} diff --git a/version-too-low.map b/version-too-low.map new file mode 100644 index 0000000..228de6e --- /dev/null +++ b/version-too-low.map @@ -0,0 +1,6 @@ +{ + "version" : 2, + "sources": [], + "names": [], + "mappings": "", +} diff --git a/version-valid.map b/version-valid.map new file mode 100644 index 0000000..81dd6ad --- /dev/null +++ b/version-valid.map @@ -0,0 +1,6 @@ +{ + "version" : 3, + "sources": [], + "names": [], + "mappings": "", +} From e45ca633964bf30ea947dd891ceec00093dbeb83 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Tue, 27 Feb 2024 16:39:14 -0800 Subject: [PATCH 02/68] Rename --- version-not-a-number.map => version-not-a-number.js.map | 0 version-too-high.map => version-too-high.js.map | 0 version-too-low.map => version-too-low.js.map | 0 version-valid.map => version-valid.js.map | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename version-not-a-number.map => version-not-a-number.js.map (100%) rename version-too-high.map => version-too-high.js.map (100%) rename version-too-low.map => version-too-low.js.map (100%) rename version-valid.map => version-valid.js.map (100%) diff --git a/version-not-a-number.map b/version-not-a-number.js.map similarity index 100% rename from version-not-a-number.map rename to version-not-a-number.js.map diff --git a/version-too-high.map b/version-too-high.js.map similarity index 100% rename from version-too-high.map rename to version-too-high.js.map diff --git a/version-too-low.map b/version-too-low.js.map similarity index 100% rename from version-too-low.map rename to version-too-low.js.map diff --git a/version-valid.map b/version-valid.js.map similarity index 100% rename from version-valid.map rename to version-valid.js.map From 5cbde6e646a78830270b19798522aebd1524547f Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Tue, 27 Feb 2024 16:39:51 -0800 Subject: [PATCH 03/68] Dummy JS files --- version-not-a-number.js | 0 version-too-high.js | 0 version-too-low.js | 0 version-valid.js | 0 4 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 version-not-a-number.js create mode 100644 version-too-high.js create mode 100644 version-too-low.js create mode 100644 version-valid.js diff --git a/version-not-a-number.js b/version-not-a-number.js new file mode 100644 index 0000000..e69de29 diff --git a/version-too-high.js b/version-too-high.js new file mode 100644 index 0000000..e69de29 diff --git a/version-too-low.js b/version-too-low.js new file mode 100644 index 0000000..e69de29 diff --git a/version-valid.js b/version-valid.js new file mode 100644 index 0000000..e69de29 From f32b2a34731adc7ec6b291af98ba5f5310edddd7 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Tue, 27 Feb 2024 19:19:18 -0800 Subject: [PATCH 04/68] Add Firefox harness patch --- 0001-WIP-Firefox-source-map-spec-tests.patch | 155 +++++++++++++++++++ 1 file changed, 155 insertions(+) create mode 100644 0001-WIP-Firefox-source-map-spec-tests.patch diff --git a/0001-WIP-Firefox-source-map-spec-tests.patch b/0001-WIP-Firefox-source-map-spec-tests.patch new file mode 100644 index 0000000..48b83c7 --- /dev/null +++ b/0001-WIP-Firefox-source-map-spec-tests.patch @@ -0,0 +1,155 @@ +From 73df7e9d5816bbfbb4f1b1609bc27dba7e66676d Mon Sep 17 00:00:00 2001 +From: Asumu Takikawa +Date: Tue, 27 Feb 2024 18:22:45 -0800 +Subject: [PATCH] WIP Firefox source map spec tests + +--- + .../test/browser/browser.toml | 2 ++ + .../test/browser/browser_spec-source-map.js | 19 +++++++++++++++++++ + .../browser/fixtures/version-not-a-number.js | 1 + + .../fixtures/version-not-a-number.js.map | 6 ++++++ + .../test/browser/fixtures/version-numbers.js | 6 ++++++ + .../test/browser/fixtures/version-too-high.js | 1 + + .../browser/fixtures/version-too-high.js.map | 6 ++++++ + .../test/browser/fixtures/version-too-low.js | 1 + + .../browser/fixtures/version-too-low.js.map | 6 ++++++ + .../test/browser/fixtures/version-valid.js | 1 + + .../browser/fixtures/version-valid.js.map | 6 ++++++ + 11 files changed, 55 insertions(+) + create mode 100644 devtools/client/shared/source-map-loader/test/browser/browser_spec-source-map.js + create mode 100644 devtools/client/shared/source-map-loader/test/browser/fixtures/version-not-a-number.js + create mode 100644 devtools/client/shared/source-map-loader/test/browser/fixtures/version-not-a-number.js.map + create mode 100644 devtools/client/shared/source-map-loader/test/browser/fixtures/version-numbers.js + create mode 100644 devtools/client/shared/source-map-loader/test/browser/fixtures/version-too-high.js + create mode 100644 devtools/client/shared/source-map-loader/test/browser/fixtures/version-too-high.js.map + create mode 100644 devtools/client/shared/source-map-loader/test/browser/fixtures/version-too-low.js + create mode 100644 devtools/client/shared/source-map-loader/test/browser/fixtures/version-too-low.js.map + create mode 100644 devtools/client/shared/source-map-loader/test/browser/fixtures/version-valid.js + create mode 100644 devtools/client/shared/source-map-loader/test/browser/fixtures/version-valid.js.map + +diff --git a/devtools/client/shared/source-map-loader/test/browser/browser.toml b/devtools/client/shared/source-map-loader/test/browser/browser.toml +index 5a602e9eeb893..a670ab0acee89 100644 +--- a/devtools/client/shared/source-map-loader/test/browser/browser.toml ++++ b/devtools/client/shared/source-map-loader/test/browser/browser.toml +@@ -19,3 +19,5 @@ skip-if = [ + "http3", # Bug 1829298 + "http2", + ] ++ ++["browser_spec-source-map.js"] +diff --git a/devtools/client/shared/source-map-loader/test/browser/browser_spec-source-map.js b/devtools/client/shared/source-map-loader/test/browser/browser_spec-source-map.js +new file mode 100644 +index 0000000000000..fc481b2b5b3ec +--- /dev/null ++++ b/devtools/client/shared/source-map-loader/test/browser/browser_spec-source-map.js +@@ -0,0 +1,19 @@ ++"use strict"; ++ ++async function isValidSourceMap(base) { ++ try { ++ await fetchFixtureSourceMap(base); ++ } catch (exn) { ++ return false; ++ } ++ return true; ++} ++ ++add_task(async function testSourceMapVersion() { ++ ++ Assert.equal(true, await isValidSourceMap("version-valid")); ++ Assert.equal(false, await isValidSourceMap("version-not-a-number")); ++ Assert.equal(false, await isValidSourceMap("version-too-low")); ++ Assert.equal(false, await isValidSourceMap("version-too-high")); ++ ++}); +diff --git a/devtools/client/shared/source-map-loader/test/browser/fixtures/version-not-a-number.js b/devtools/client/shared/source-map-loader/test/browser/fixtures/version-not-a-number.js +new file mode 100644 +index 0000000000000..5382a716e3a21 +--- /dev/null ++++ b/devtools/client/shared/source-map-loader/test/browser/fixtures/version-not-a-number.js +@@ -0,0 +1 @@ ++// # sourceMappingURL=version-not-a-number.js.map +diff --git a/devtools/client/shared/source-map-loader/test/browser/fixtures/version-not-a-number.js.map b/devtools/client/shared/source-map-loader/test/browser/fixtures/version-not-a-number.js.map +new file mode 100644 +index 0000000000000..a584d6e695117 +--- /dev/null ++++ b/devtools/client/shared/source-map-loader/test/browser/fixtures/version-not-a-number.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version" : "3foo", ++ "sources": [], ++ "names": [], ++ "mappings": "" ++} +diff --git a/devtools/client/shared/source-map-loader/test/browser/fixtures/version-numbers.js b/devtools/client/shared/source-map-loader/test/browser/fixtures/version-numbers.js +new file mode 100644 +index 0000000000000..e79993b659db6 +--- /dev/null ++++ b/devtools/client/shared/source-map-loader/test/browser/fixtures/version-numbers.js +@@ -0,0 +1,6 @@ ++// Test that invalid version numbers are rejected. ++ ++assert(isValidSourceMap("./version-valid.map")); ++assert(!isValidSourceMap("./version-not-a-number.map")); ++assert(!isValidSourceMap("./version-too-low.map")); ++assert(!isValidSourceMap("./version-too-high.map")); +diff --git a/devtools/client/shared/source-map-loader/test/browser/fixtures/version-too-high.js b/devtools/client/shared/source-map-loader/test/browser/fixtures/version-too-high.js +new file mode 100644 +index 0000000000000..04bfe7f62b7b9 +--- /dev/null ++++ b/devtools/client/shared/source-map-loader/test/browser/fixtures/version-too-high.js +@@ -0,0 +1 @@ ++// # sourceMappingURL=version-too-high.js.map +diff --git a/devtools/client/shared/source-map-loader/test/browser/fixtures/version-too-high.js.map b/devtools/client/shared/source-map-loader/test/browser/fixtures/version-too-high.js.map +new file mode 100644 +index 0000000000000..ee23be32ff278 +--- /dev/null ++++ b/devtools/client/shared/source-map-loader/test/browser/fixtures/version-too-high.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version" : 4, ++ "sources": [], ++ "names": [], ++ "mappings": "" ++} +diff --git a/devtools/client/shared/source-map-loader/test/browser/fixtures/version-too-low.js b/devtools/client/shared/source-map-loader/test/browser/fixtures/version-too-low.js +new file mode 100644 +index 0000000000000..54b3526c6b5e2 +--- /dev/null ++++ b/devtools/client/shared/source-map-loader/test/browser/fixtures/version-too-low.js +@@ -0,0 +1 @@ ++// # sourceMappingURL=version-too-low.js.map +diff --git a/devtools/client/shared/source-map-loader/test/browser/fixtures/version-too-low.js.map b/devtools/client/shared/source-map-loader/test/browser/fixtures/version-too-low.js.map +new file mode 100644 +index 0000000000000..64ca7a6e2e928 +--- /dev/null ++++ b/devtools/client/shared/source-map-loader/test/browser/fixtures/version-too-low.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version" : 2, ++ "sources": [], ++ "names": [], ++ "mappings": "" ++} +diff --git a/devtools/client/shared/source-map-loader/test/browser/fixtures/version-valid.js b/devtools/client/shared/source-map-loader/test/browser/fixtures/version-valid.js +new file mode 100644 +index 0000000000000..f8541f9efdc71 +--- /dev/null ++++ b/devtools/client/shared/source-map-loader/test/browser/fixtures/version-valid.js +@@ -0,0 +1 @@ ++// # sourceMappingURL=version-valid.js.map +diff --git a/devtools/client/shared/source-map-loader/test/browser/fixtures/version-valid.js.map b/devtools/client/shared/source-map-loader/test/browser/fixtures/version-valid.js.map +new file mode 100644 +index 0000000000000..1a163052d8fc8 +--- /dev/null ++++ b/devtools/client/shared/source-map-loader/test/browser/fixtures/version-valid.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version" : 3, ++ "sources": [], ++ "names": [], ++ "mappings": "" ++} +-- +2.39.2 + From d3c0d32012c30c61a3c7cdb6426c6e18b08abaf5 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Tue, 27 Feb 2024 19:20:34 -0800 Subject: [PATCH 05/68] Fix test files --- version-not-a-number.js | 1 + version-not-a-number.js.map | 2 +- version-too-high.js | 1 + version-too-high.js.map | 2 +- version-too-low.js | 1 + version-too-low.js.map | 2 +- version-valid.js | 1 + version-valid.js.map | 2 +- 8 files changed, 8 insertions(+), 4 deletions(-) diff --git a/version-not-a-number.js b/version-not-a-number.js index e69de29..5382a71 100644 --- a/version-not-a-number.js +++ b/version-not-a-number.js @@ -0,0 +1 @@ +// # sourceMappingURL=version-not-a-number.js.map diff --git a/version-not-a-number.js.map b/version-not-a-number.js.map index b81e58e..a584d6e 100644 --- a/version-not-a-number.js.map +++ b/version-not-a-number.js.map @@ -2,5 +2,5 @@ "version" : "3foo", "sources": [], "names": [], - "mappings": "", + "mappings": "" } diff --git a/version-too-high.js b/version-too-high.js index e69de29..04bfe7f 100644 --- a/version-too-high.js +++ b/version-too-high.js @@ -0,0 +1 @@ +// # sourceMappingURL=version-too-high.js.map diff --git a/version-too-high.js.map b/version-too-high.js.map index fcf83f0..ee23be3 100644 --- a/version-too-high.js.map +++ b/version-too-high.js.map @@ -2,5 +2,5 @@ "version" : 4, "sources": [], "names": [], - "mappings": "", + "mappings": "" } diff --git a/version-too-low.js b/version-too-low.js index e69de29..54b3526 100644 --- a/version-too-low.js +++ b/version-too-low.js @@ -0,0 +1 @@ +// # sourceMappingURL=version-too-low.js.map diff --git a/version-too-low.js.map b/version-too-low.js.map index 228de6e..64ca7a6 100644 --- a/version-too-low.js.map +++ b/version-too-low.js.map @@ -2,5 +2,5 @@ "version" : 2, "sources": [], "names": [], - "mappings": "", + "mappings": "" } diff --git a/version-valid.js b/version-valid.js index e69de29..f8541f9 100644 --- a/version-valid.js +++ b/version-valid.js @@ -0,0 +1 @@ +// # sourceMappingURL=version-valid.js.map diff --git a/version-valid.js.map b/version-valid.js.map index 81dd6ad..1a16305 100644 --- a/version-valid.js.map +++ b/version-valid.js.map @@ -2,5 +2,5 @@ "version" : 3, "sources": [], "names": [], - "mappings": "", + "mappings": "" } From 18c934ab32a49c1b091a4308cb58124f8ddc379b Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Tue, 27 Feb 2024 19:20:58 -0800 Subject: [PATCH 06/68] Add Firefox example test This goes in the mochitests for devtools/client/shared/source-map-loader --- firefox/browser_spec-source-map.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 firefox/browser_spec-source-map.js diff --git a/firefox/browser_spec-source-map.js b/firefox/browser_spec-source-map.js new file mode 100644 index 0000000..fc481b2 --- /dev/null +++ b/firefox/browser_spec-source-map.js @@ -0,0 +1,19 @@ +"use strict"; + +async function isValidSourceMap(base) { + try { + await fetchFixtureSourceMap(base); + } catch (exn) { + return false; + } + return true; +} + +add_task(async function testSourceMapVersion() { + + Assert.equal(true, await isValidSourceMap("version-valid")); + Assert.equal(false, await isValidSourceMap("version-not-a-number")); + Assert.equal(false, await isValidSourceMap("version-too-low")); + Assert.equal(false, await isValidSourceMap("version-too-high")); + +}); From cf8ed45706da4f8c20d2082715aefb7ad90e49b3 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Tue, 27 Feb 2024 19:23:16 -0800 Subject: [PATCH 07/68] Add test-specific README info --- README.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 962b65d..6420008 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Source Map Tests -This repository holds testing discussions for the the Source Map debugging format. Specifically, we're looking to encourage discussion around: +This repository holds testing discussions and tests for the the Source Map debugging format. Specifically, we're looking to encourage discussion around: - Manual and automated testing strategies for Source Maps - Gathering a list of Soure Map generators and consumers @@ -9,3 +9,13 @@ This repository holds testing discussions for the the Source Map debugging forma Open discussion happens in the [GitHub issues](https://github.com/source-map/source-map-tests/issues). Source Map spec: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1# + +## Test cases + +These test cases are still a work-in-progress 🚧. + +How to run in Firefox: + * Check out mozilla-unified + * git am /0001-WIP-Firefox-source-map-spec-tests.patch + * mach build + * mach-with firefox test devtools/client/shared/source-map-loader/ From ba4bb792d91e0294713b571fcaeed2aca9ca6093 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Tue, 27 Feb 2024 19:25:36 -0800 Subject: [PATCH 08/68] Adjust README --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6420008..d81f1b4 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,6 @@ These test cases are still a work-in-progress 🚧. How to run in Firefox: * Check out mozilla-unified - * git am /0001-WIP-Firefox-source-map-spec-tests.patch - * mach build - * mach-with firefox test devtools/client/shared/source-map-loader/ + * `git am /0001-WIP-Firefox-source-map-spec-tests.patch` + * `mach build` + * `mach-with firefox test devtools/client/shared/source-map-loader/` From f8213ff2ed1ff566a3b56325112f5b140449d5d9 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Tue, 27 Feb 2024 19:33:15 -0800 Subject: [PATCH 09/68] Update README (use the upstream command and not the shortcut on my setup) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d81f1b4..e0a95af 100644 --- a/README.md +++ b/README.md @@ -18,4 +18,4 @@ How to run in Firefox: * Check out mozilla-unified * `git am /0001-WIP-Firefox-source-map-spec-tests.patch` * `mach build` - * `mach-with firefox test devtools/client/shared/source-map-loader/` + * `mach test devtools/client/shared/source-map-loader/` From 0c2525fef4c90f6ad154be1d8e75c831528969db Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Wed, 28 Feb 2024 16:28:11 -0800 Subject: [PATCH 10/68] Move test resources to a separate directory --- version-not-a-number.js => resources/version-not-a-number.js | 0 .../version-not-a-number.js.map | 0 version-too-high.js => resources/version-too-high.js | 0 version-too-high.js.map => resources/version-too-high.js.map | 0 version-too-low.js => resources/version-too-low.js | 0 version-too-low.js.map => resources/version-too-low.js.map | 0 version-valid.js => resources/version-valid.js | 0 version-valid.js.map => resources/version-valid.js.map | 0 8 files changed, 0 insertions(+), 0 deletions(-) rename version-not-a-number.js => resources/version-not-a-number.js (100%) rename version-not-a-number.js.map => resources/version-not-a-number.js.map (100%) rename version-too-high.js => resources/version-too-high.js (100%) rename version-too-high.js.map => resources/version-too-high.js.map (100%) rename version-too-low.js => resources/version-too-low.js (100%) rename version-too-low.js.map => resources/version-too-low.js.map (100%) rename version-valid.js => resources/version-valid.js (100%) rename version-valid.js.map => resources/version-valid.js.map (100%) diff --git a/version-not-a-number.js b/resources/version-not-a-number.js similarity index 100% rename from version-not-a-number.js rename to resources/version-not-a-number.js diff --git a/version-not-a-number.js.map b/resources/version-not-a-number.js.map similarity index 100% rename from version-not-a-number.js.map rename to resources/version-not-a-number.js.map diff --git a/version-too-high.js b/resources/version-too-high.js similarity index 100% rename from version-too-high.js rename to resources/version-too-high.js diff --git a/version-too-high.js.map b/resources/version-too-high.js.map similarity index 100% rename from version-too-high.js.map rename to resources/version-too-high.js.map diff --git a/version-too-low.js b/resources/version-too-low.js similarity index 100% rename from version-too-low.js rename to resources/version-too-low.js diff --git a/version-too-low.js.map b/resources/version-too-low.js.map similarity index 100% rename from version-too-low.js.map rename to resources/version-too-low.js.map diff --git a/version-valid.js b/resources/version-valid.js similarity index 100% rename from version-valid.js rename to resources/version-valid.js diff --git a/version-valid.js.map b/resources/version-valid.js.map similarity index 100% rename from version-valid.js.map rename to resources/version-valid.js.map From 52edb894f7b949e8dc1152748b36cd5ed98379dc Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Wed, 28 Feb 2024 16:31:41 -0800 Subject: [PATCH 11/68] Add initial JSON test file Tests are described in a single JSON file. Using a single file instead of one file per test makes it easier to load all the test descriptions in the harness. --- source-map-spec-tests.json | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 source-map-spec-tests.json diff --git a/source-map-spec-tests.json b/source-map-spec-tests.json new file mode 100644 index 0000000..2ff5c90 --- /dev/null +++ b/source-map-spec-tests.json @@ -0,0 +1,24 @@ +{ + "tests": [ + { + "baseFile": "version-valid.js", + "sourceMapFile": "version-valid.js.map", + "sourceMapIsValid": true + }, + { + "baseFile": "version-not-a-number.js", + "sourceMapFile": "version-not-a-number.js.map", + "sourceMapIsValid": false + }, + { + "baseFile": "version-too-high.js", + "sourceMapFile": "version-too-high.js.map", + "sourceMapIsValid": false + }, + { + "baseFile": "version-too-low.js", + "sourceMapFile": "version-too-low.js.map", + "sourceMapIsValid": false + } + ] +} From fe23e11bbe401216554805321d93657c8517df57 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Wed, 28 Feb 2024 18:37:14 -0800 Subject: [PATCH 12/68] Add name fields to tests In case test harnesses wish to print the test case name or define a function for each test case, and so on. --- source-map-spec-tests.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source-map-spec-tests.json b/source-map-spec-tests.json index 2ff5c90..086f41a 100644 --- a/source-map-spec-tests.json +++ b/source-map-spec-tests.json @@ -1,21 +1,25 @@ { "tests": [ { + "name": "versionValid", "baseFile": "version-valid.js", "sourceMapFile": "version-valid.js.map", "sourceMapIsValid": true }, { + "name": "versionNotANumber", "baseFile": "version-not-a-number.js", "sourceMapFile": "version-not-a-number.js.map", "sourceMapIsValid": false }, { + "name": "versionTooHigh", "baseFile": "version-too-high.js", "sourceMapFile": "version-too-high.js.map", "sourceMapIsValid": false }, { + "name": "versionTooLow", "baseFile": "version-too-low.js", "sourceMapFile": "version-too-low.js.map", "sourceMapIsValid": false From a4d49fb3cb60d9be9c372871ccb1c1f1c1d1c3b4 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Wed, 28 Feb 2024 18:37:51 -0800 Subject: [PATCH 13/68] Add updated Firefox harness --- firefox/browser_spec-source-map.js | 37 +++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/firefox/browser_spec-source-map.js b/firefox/browser_spec-source-map.js index fc481b2..4145268 100644 --- a/firefox/browser_spec-source-map.js +++ b/firefox/browser_spec-source-map.js @@ -9,11 +9,36 @@ async function isValidSourceMap(base) { return true; } -add_task(async function testSourceMapVersion() { +const SPEC_TESTS_URI = `${URL_ROOT_SSL}fixtures/source-map-spec-tests.json` +const testDescriptions = JSON.parse(read(SPEC_TESTS_URI)); - Assert.equal(true, await isValidSourceMap("version-valid")); - Assert.equal(false, await isValidSourceMap("version-not-a-number")); - Assert.equal(false, await isValidSourceMap("version-too-low")); - Assert.equal(false, await isValidSourceMap("version-too-high")); +for (const testCase of testDescriptions.tests) { + async function testFunction() { + const baseName = testCase.baseFile.substring(0, testCase.baseFile.indexOf(".js")); + Assert.equal(testCase.sourceMapIsValid, await isValidSourceMap(baseName)); + }; + Object.defineProperty(testFunction, "name", { value: testCase.name }); + add_task(testFunction); +} + +function read(srcChromeURL) { + const scriptableStream = Cc[ + "@mozilla.org/scriptableinputstream;1" + ].getService(Ci.nsIScriptableInputStream); + + const channel = NetUtil.newChannel({ + uri: srcChromeURL, + loadUsingSystemPrincipal: true, + }); + const input = channel.open(); + scriptableStream.init(input); -}); + let data = ""; + while (input.available()) { + data = data.concat(scriptableStream.read(input.available())); + } + scriptableStream.close(); + input.close(); + + return data; +} From 0fa59ac5b77670adedcfb3122f386819921a1eed Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Wed, 28 Feb 2024 18:39:21 -0800 Subject: [PATCH 14/68] Update Firefox patch --- 0001-WIP-Firefox-source-map-spec-tests.patch | 95 ++++++++++++++++---- 1 file changed, 78 insertions(+), 17 deletions(-) diff --git a/0001-WIP-Firefox-source-map-spec-tests.patch b/0001-WIP-Firefox-source-map-spec-tests.patch index 48b83c7..646d594 100644 --- a/0001-WIP-Firefox-source-map-spec-tests.patch +++ b/0001-WIP-Firefox-source-map-spec-tests.patch @@ -1,22 +1,24 @@ -From 73df7e9d5816bbfbb4f1b1609bc27dba7e66676d Mon Sep 17 00:00:00 2001 +From 763e1e0ce78d6dcd3b94e428b9f399b6c92cdf34 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Tue, 27 Feb 2024 18:22:45 -0800 Subject: [PATCH] WIP Firefox source map spec tests --- - .../test/browser/browser.toml | 2 ++ - .../test/browser/browser_spec-source-map.js | 19 +++++++++++++++++++ + .../test/browser/browser.toml | 2 + + .../test/browser/browser_spec-source-map.js | 44 +++++++++++++++++++ + .../fixtures/source-map-spec-tests.json | 28 ++++++++++++ .../browser/fixtures/version-not-a-number.js | 1 + - .../fixtures/version-not-a-number.js.map | 6 ++++++ - .../test/browser/fixtures/version-numbers.js | 6 ++++++ + .../fixtures/version-not-a-number.js.map | 6 +++ + .../test/browser/fixtures/version-numbers.js | 6 +++ .../test/browser/fixtures/version-too-high.js | 1 + - .../browser/fixtures/version-too-high.js.map | 6 ++++++ + .../browser/fixtures/version-too-high.js.map | 6 +++ .../test/browser/fixtures/version-too-low.js | 1 + - .../browser/fixtures/version-too-low.js.map | 6 ++++++ + .../browser/fixtures/version-too-low.js.map | 6 +++ .../test/browser/fixtures/version-valid.js | 1 + - .../browser/fixtures/version-valid.js.map | 6 ++++++ - 11 files changed, 55 insertions(+) + .../browser/fixtures/version-valid.js.map | 6 +++ + 12 files changed, 108 insertions(+) create mode 100644 devtools/client/shared/source-map-loader/test/browser/browser_spec-source-map.js + create mode 100644 devtools/client/shared/source-map-loader/test/browser/fixtures/source-map-spec-tests.json create mode 100644 devtools/client/shared/source-map-loader/test/browser/fixtures/version-not-a-number.js create mode 100644 devtools/client/shared/source-map-loader/test/browser/fixtures/version-not-a-number.js.map create mode 100644 devtools/client/shared/source-map-loader/test/browser/fixtures/version-numbers.js @@ -39,10 +41,10 @@ index 5a602e9eeb893..a670ab0acee89 100644 +["browser_spec-source-map.js"] diff --git a/devtools/client/shared/source-map-loader/test/browser/browser_spec-source-map.js b/devtools/client/shared/source-map-loader/test/browser/browser_spec-source-map.js new file mode 100644 -index 0000000000000..fc481b2b5b3ec +index 0000000000000..4145268b8d542 --- /dev/null +++ b/devtools/client/shared/source-map-loader/test/browser/browser_spec-source-map.js -@@ -0,0 +1,19 @@ +@@ -0,0 +1,44 @@ +"use strict"; + +async function isValidSourceMap(base) { @@ -54,14 +56,73 @@ index 0000000000000..fc481b2b5b3ec + return true; +} + -+add_task(async function testSourceMapVersion() { ++const SPEC_TESTS_URI = `${URL_ROOT_SSL}fixtures/source-map-spec-tests.json` ++const testDescriptions = JSON.parse(read(SPEC_TESTS_URI)); + -+ Assert.equal(true, await isValidSourceMap("version-valid")); -+ Assert.equal(false, await isValidSourceMap("version-not-a-number")); -+ Assert.equal(false, await isValidSourceMap("version-too-low")); -+ Assert.equal(false, await isValidSourceMap("version-too-high")); ++for (const testCase of testDescriptions.tests) { ++ async function testFunction() { ++ const baseName = testCase.baseFile.substring(0, testCase.baseFile.indexOf(".js")); ++ Assert.equal(testCase.sourceMapIsValid, await isValidSourceMap(baseName)); ++ }; ++ Object.defineProperty(testFunction, "name", { value: testCase.name }); ++ add_task(testFunction); ++} ++ ++function read(srcChromeURL) { ++ const scriptableStream = Cc[ ++ "@mozilla.org/scriptableinputstream;1" ++ ].getService(Ci.nsIScriptableInputStream); ++ ++ const channel = NetUtil.newChannel({ ++ uri: srcChromeURL, ++ loadUsingSystemPrincipal: true, ++ }); ++ const input = channel.open(); ++ scriptableStream.init(input); ++ ++ let data = ""; ++ while (input.available()) { ++ data = data.concat(scriptableStream.read(input.available())); ++ } ++ scriptableStream.close(); ++ input.close(); + -+}); ++ return data; ++} +diff --git a/devtools/client/shared/source-map-loader/test/browser/fixtures/source-map-spec-tests.json b/devtools/client/shared/source-map-loader/test/browser/fixtures/source-map-spec-tests.json +new file mode 100644 +index 0000000000000..086f41ae34a35 +--- /dev/null ++++ b/devtools/client/shared/source-map-loader/test/browser/fixtures/source-map-spec-tests.json +@@ -0,0 +1,28 @@ ++{ ++ "tests": [ ++ { ++ "name": "versionValid", ++ "baseFile": "version-valid.js", ++ "sourceMapFile": "version-valid.js.map", ++ "sourceMapIsValid": true ++ }, ++ { ++ "name": "versionNotANumber", ++ "baseFile": "version-not-a-number.js", ++ "sourceMapFile": "version-not-a-number.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "versionTooHigh", ++ "baseFile": "version-too-high.js", ++ "sourceMapFile": "version-too-high.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "versionTooLow", ++ "baseFile": "version-too-low.js", ++ "sourceMapFile": "version-too-low.js.map", ++ "sourceMapIsValid": false ++ } ++ ] ++} diff --git a/devtools/client/shared/source-map-loader/test/browser/fixtures/version-not-a-number.js b/devtools/client/shared/source-map-loader/test/browser/fixtures/version-not-a-number.js new file mode 100644 index 0000000000000..5382a716e3a21 From 3b992dad1590c71346a1e144b67e8e430712cf53 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Wed, 28 Feb 2024 18:41:01 -0800 Subject: [PATCH 15/68] Move patch file to subdirectory, update README --- README.md | 2 +- .../0001-WIP-Firefox-source-map-spec-tests.patch | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename 0001-WIP-Firefox-source-map-spec-tests.patch => firefox/0001-WIP-Firefox-source-map-spec-tests.patch (100%) diff --git a/README.md b/README.md index e0a95af..c66abd5 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,6 @@ These test cases are still a work-in-progress 🚧. How to run in Firefox: * Check out mozilla-unified - * `git am /0001-WIP-Firefox-source-map-spec-tests.patch` + * `git am /firefox/0001-WIP-Firefox-source-map-spec-tests.patch` * `mach build` * `mach test devtools/client/shared/source-map-loader/` diff --git a/0001-WIP-Firefox-source-map-spec-tests.patch b/firefox/0001-WIP-Firefox-source-map-spec-tests.patch similarity index 100% rename from 0001-WIP-Firefox-source-map-spec-tests.patch rename to firefox/0001-WIP-Firefox-source-map-spec-tests.patch From 38622596ed2e76b12d9e71b8f4d149d7c856ffcb Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Thu, 29 Feb 2024 13:13:55 -0800 Subject: [PATCH 16/68] Add a test for unrecognized properties (sec 4.3) --- resources/unrecognized-property.js | 1 + resources/unrecognized-property.js.map | 8 ++++++++ source-map-spec-tests.json | 6 ++++++ 3 files changed, 15 insertions(+) create mode 100644 resources/unrecognized-property.js create mode 100644 resources/unrecognized-property.js.map diff --git a/resources/unrecognized-property.js b/resources/unrecognized-property.js new file mode 100644 index 0000000..47303d1 --- /dev/null +++ b/resources/unrecognized-property.js @@ -0,0 +1 @@ +// # sourceMappingURL=unrecognized-property.js.map diff --git a/resources/unrecognized-property.js.map b/resources/unrecognized-property.js.map new file mode 100644 index 0000000..40bee55 --- /dev/null +++ b/resources/unrecognized-property.js.map @@ -0,0 +1,8 @@ +{ + "version" : 3, + "sources": [], + "names": [], + "mappings": "", + "foobar": 42, + "unusedProperty": [1, 2, 3, 4] +} diff --git a/source-map-spec-tests.json b/source-map-spec-tests.json index 086f41a..d3a70cf 100644 --- a/source-map-spec-tests.json +++ b/source-map-spec-tests.json @@ -23,6 +23,12 @@ "baseFile": "version-too-low.js", "sourceMapFile": "version-too-low.js.map", "sourceMapIsValid": false + }, + { + "name": "unrecognizedProperty", + "baseFile": "unrecognized-property.js", + "sourceMapFile": "unrecognized-property.js.map", + "sourceMapIsValid": true } ] } From 0a4a58ccdfd231e85272b4e5795dcfccfeed30d1 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Thu, 29 Feb 2024 15:32:17 -0800 Subject: [PATCH 17/68] Add a test to check basic name mappings --- firefox/browser_spec-source-map.js | 24 ++++++++++++++++++++++++ resources/basic-mapping-original.js | 8 ++++++++ resources/basic-mapping.js | 1 + resources/basic-mapping.js.map | 6 ++++++ source-map-spec-tests.json | 26 ++++++++++++++++++++++++++ 5 files changed, 65 insertions(+) create mode 100644 resources/basic-mapping-original.js create mode 100644 resources/basic-mapping.js create mode 100644 resources/basic-mapping.js.map diff --git a/firefox/browser_spec-source-map.js b/firefox/browser_spec-source-map.js index 4145268..34695d6 100644 --- a/firefox/browser_spec-source-map.js +++ b/firefox/browser_spec-source-map.js @@ -1,5 +1,9 @@ "use strict"; +const { + generatedToOriginalId, +} = require("resource://devtools/client/shared/source-map-loader/utils/index.js"); + async function isValidSourceMap(base) { try { await fetchFixtureSourceMap(base); @@ -9,6 +13,19 @@ async function isValidSourceMap(base) { return true; } +async function checkMapping(testCase, action) { + const originalId = generatedToOriginalId(testCase.baseFile, `${URL_ROOT_SSL}fixtures/${action.originalSource}`); + const generatedLoc = await gSourceMapLoader.getGeneratedLocation({ + sourceId: originalId, + line: action.originalLine + 1, + column: action.originalColumn, + }); + Assert.ok(generatedLoc !== null, "Location lookup should not return null"); + Assert.equal(testCase.baseFile, generatedLoc.sourceId); + Assert.equal(action.generatedLine + 1, generatedLoc.line); + Assert.equal(action.generatedColumn, generatedLoc.column); +} + const SPEC_TESTS_URI = `${URL_ROOT_SSL}fixtures/source-map-spec-tests.json` const testDescriptions = JSON.parse(read(SPEC_TESTS_URI)); @@ -16,6 +33,13 @@ for (const testCase of testDescriptions.tests) { async function testFunction() { const baseName = testCase.baseFile.substring(0, testCase.baseFile.indexOf(".js")); Assert.equal(testCase.sourceMapIsValid, await isValidSourceMap(baseName)); + + if (testCase.testActions) { + for (const action of testCase.testActions) { + if (action.actionType === "checkMapping") + await checkMapping(testCase, action); + } + } }; Object.defineProperty(testFunction, "name", { value: testCase.name }); add_task(testFunction); diff --git a/resources/basic-mapping-original.js b/resources/basic-mapping-original.js new file mode 100644 index 0000000..301b186 --- /dev/null +++ b/resources/basic-mapping-original.js @@ -0,0 +1,8 @@ +function foo() { + return 42; +} +function bar() { + return 24; +} +foo(); +bar(); diff --git a/resources/basic-mapping.js b/resources/basic-mapping.js new file mode 100644 index 0000000..9df7240 --- /dev/null +++ b/resources/basic-mapping.js @@ -0,0 +1 @@ +function foo(){return 42}function bar(){return 24}foo();bar(); \ No newline at end of file diff --git a/resources/basic-mapping.js.map b/resources/basic-mapping.js.map new file mode 100644 index 0000000..12dc967 --- /dev/null +++ b/resources/basic-mapping.js.map @@ -0,0 +1,6 @@ +{ + "version":3, + "names": ["foo","bar"], + "sources": ["basic-mapping-original.js"], + "mappings":"AAAA,SAASA,MACP,OAAO,EACT,CACA,SAASC,MACP,OAAO,EACT,CACAD,MACAC" +} diff --git a/source-map-spec-tests.json b/source-map-spec-tests.json index d3a70cf..16d8442 100644 --- a/source-map-spec-tests.json +++ b/source-map-spec-tests.json @@ -29,6 +29,32 @@ "baseFile": "unrecognized-property.js", "sourceMapFile": "unrecognized-property.js.map", "sourceMapIsValid": true + }, + { + "name": "basicMapping", + "baseFile": "basic-mapping.js", + "sourceMapFile": "basic-mapping.js.map", + "sourceMapIsValid": true, + "testActions": [ + { + "actionType": "checkMapping", + "originalSource": "basic-mapping-original.js", + "originalLine": 0, + "originalColumn": 9, + "generatedLine": 0, + "generatedColumn": 9, + "mappedName": "foo" + }, + { + "actionType": "checkMapping", + "originalSource": "basic-mapping-original.js", + "originalLine": 3, + "originalColumn": 9, + "generatedLine": 0, + "generatedColumn": 34, + "mappedName": "bar" + } + ] } ] } From b96b7a204da112c1399df3d56e64173bfd9f11d5 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Thu, 29 Feb 2024 17:05:53 -0800 Subject: [PATCH 18/68] Update FF patch --- ...01-WIP-Firefox-source-map-spec-tests.patch | 147 ++++++++++++++++-- 1 file changed, 134 insertions(+), 13 deletions(-) diff --git a/firefox/0001-WIP-Firefox-source-map-spec-tests.patch b/firefox/0001-WIP-Firefox-source-map-spec-tests.patch index 646d594..a9e256e 100644 --- a/firefox/0001-WIP-Firefox-source-map-spec-tests.patch +++ b/firefox/0001-WIP-Firefox-source-map-spec-tests.patch @@ -1,24 +1,34 @@ -From 763e1e0ce78d6dcd3b94e428b9f399b6c92cdf34 Mon Sep 17 00:00:00 2001 +From 8327515870d595ab04a111f6c37b84eab8a5010c Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Tue, 27 Feb 2024 18:22:45 -0800 Subject: [PATCH] WIP Firefox source map spec tests --- .../test/browser/browser.toml | 2 + - .../test/browser/browser_spec-source-map.js | 44 +++++++++++++++++++ - .../fixtures/source-map-spec-tests.json | 28 ++++++++++++ + .../test/browser/browser_spec-source-map.js | 68 +++++++++++++++++++ + .../fixtures/basic-mapping-original.js | 8 +++ + .../test/browser/fixtures/basic-mapping.js | 1 + + .../browser/fixtures/basic-mapping.js.map | 6 ++ + .../fixtures/source-map-spec-tests.json | 60 ++++++++++++++++ + .../browser/fixtures/unrecognized-property.js | 1 + + .../fixtures/unrecognized-property.js.map | 8 +++ .../browser/fixtures/version-not-a-number.js | 1 + - .../fixtures/version-not-a-number.js.map | 6 +++ - .../test/browser/fixtures/version-numbers.js | 6 +++ + .../fixtures/version-not-a-number.js.map | 6 ++ + .../test/browser/fixtures/version-numbers.js | 6 ++ .../test/browser/fixtures/version-too-high.js | 1 + - .../browser/fixtures/version-too-high.js.map | 6 +++ + .../browser/fixtures/version-too-high.js.map | 6 ++ .../test/browser/fixtures/version-too-low.js | 1 + - .../browser/fixtures/version-too-low.js.map | 6 +++ + .../browser/fixtures/version-too-low.js.map | 6 ++ .../test/browser/fixtures/version-valid.js | 1 + - .../browser/fixtures/version-valid.js.map | 6 +++ - 12 files changed, 108 insertions(+) + .../browser/fixtures/version-valid.js.map | 6 ++ + 17 files changed, 188 insertions(+) create mode 100644 devtools/client/shared/source-map-loader/test/browser/browser_spec-source-map.js + create mode 100644 devtools/client/shared/source-map-loader/test/browser/fixtures/basic-mapping-original.js + create mode 100644 devtools/client/shared/source-map-loader/test/browser/fixtures/basic-mapping.js + create mode 100644 devtools/client/shared/source-map-loader/test/browser/fixtures/basic-mapping.js.map create mode 100644 devtools/client/shared/source-map-loader/test/browser/fixtures/source-map-spec-tests.json + create mode 100644 devtools/client/shared/source-map-loader/test/browser/fixtures/unrecognized-property.js + create mode 100644 devtools/client/shared/source-map-loader/test/browser/fixtures/unrecognized-property.js.map create mode 100644 devtools/client/shared/source-map-loader/test/browser/fixtures/version-not-a-number.js create mode 100644 devtools/client/shared/source-map-loader/test/browser/fixtures/version-not-a-number.js.map create mode 100644 devtools/client/shared/source-map-loader/test/browser/fixtures/version-numbers.js @@ -41,12 +51,16 @@ index 5a602e9eeb893..a670ab0acee89 100644 +["browser_spec-source-map.js"] diff --git a/devtools/client/shared/source-map-loader/test/browser/browser_spec-source-map.js b/devtools/client/shared/source-map-loader/test/browser/browser_spec-source-map.js new file mode 100644 -index 0000000000000..4145268b8d542 +index 0000000000000..34695d6bd395b --- /dev/null +++ b/devtools/client/shared/source-map-loader/test/browser/browser_spec-source-map.js -@@ -0,0 +1,44 @@ +@@ -0,0 +1,68 @@ +"use strict"; + ++const { ++ generatedToOriginalId, ++} = require("resource://devtools/client/shared/source-map-loader/utils/index.js"); ++ +async function isValidSourceMap(base) { + try { + await fetchFixtureSourceMap(base); @@ -56,6 +70,19 @@ index 0000000000000..4145268b8d542 + return true; +} + ++async function checkMapping(testCase, action) { ++ const originalId = generatedToOriginalId(testCase.baseFile, `${URL_ROOT_SSL}fixtures/${action.originalSource}`); ++ const generatedLoc = await gSourceMapLoader.getGeneratedLocation({ ++ sourceId: originalId, ++ line: action.originalLine + 1, ++ column: action.originalColumn, ++ }); ++ Assert.ok(generatedLoc !== null, "Location lookup should not return null"); ++ Assert.equal(testCase.baseFile, generatedLoc.sourceId); ++ Assert.equal(action.generatedLine + 1, generatedLoc.line); ++ Assert.equal(action.generatedColumn, generatedLoc.column); ++} ++ +const SPEC_TESTS_URI = `${URL_ROOT_SSL}fixtures/source-map-spec-tests.json` +const testDescriptions = JSON.parse(read(SPEC_TESTS_URI)); + @@ -63,6 +90,13 @@ index 0000000000000..4145268b8d542 + async function testFunction() { + const baseName = testCase.baseFile.substring(0, testCase.baseFile.indexOf(".js")); + Assert.equal(testCase.sourceMapIsValid, await isValidSourceMap(baseName)); ++ ++ if (testCase.testActions) { ++ for (const action of testCase.testActions) { ++ if (action.actionType === "checkMapping") ++ await checkMapping(testCase, action); ++ } ++ } + }; + Object.defineProperty(testFunction, "name", { value: testCase.name }); + add_task(testFunction); @@ -89,12 +123,46 @@ index 0000000000000..4145268b8d542 + + return data; +} +diff --git a/devtools/client/shared/source-map-loader/test/browser/fixtures/basic-mapping-original.js b/devtools/client/shared/source-map-loader/test/browser/fixtures/basic-mapping-original.js +new file mode 100644 +index 0000000000000..301b186cb15e6 +--- /dev/null ++++ b/devtools/client/shared/source-map-loader/test/browser/fixtures/basic-mapping-original.js +@@ -0,0 +1,8 @@ ++function foo() { ++ return 42; ++} ++function bar() { ++ return 24; ++} ++foo(); ++bar(); +diff --git a/devtools/client/shared/source-map-loader/test/browser/fixtures/basic-mapping.js b/devtools/client/shared/source-map-loader/test/browser/fixtures/basic-mapping.js +new file mode 100644 +index 0000000000000..9df72406be544 +--- /dev/null ++++ b/devtools/client/shared/source-map-loader/test/browser/fixtures/basic-mapping.js +@@ -0,0 +1 @@ ++function foo(){return 42}function bar(){return 24}foo();bar(); +\ No newline at end of file +diff --git a/devtools/client/shared/source-map-loader/test/browser/fixtures/basic-mapping.js.map b/devtools/client/shared/source-map-loader/test/browser/fixtures/basic-mapping.js.map +new file mode 100644 +index 0000000000000..12dc9679a4b1d +--- /dev/null ++++ b/devtools/client/shared/source-map-loader/test/browser/fixtures/basic-mapping.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version":3, ++ "names": ["foo","bar"], ++ "sources": ["basic-mapping-original.js"], ++ "mappings":"AAAA,SAASA,MACP,OAAO,EACT,CACA,SAASC,MACP,OAAO,EACT,CACAD,MACAC" ++} diff --git a/devtools/client/shared/source-map-loader/test/browser/fixtures/source-map-spec-tests.json b/devtools/client/shared/source-map-loader/test/browser/fixtures/source-map-spec-tests.json new file mode 100644 -index 0000000000000..086f41ae34a35 +index 0000000000000..16d8442811655 --- /dev/null +++ b/devtools/client/shared/source-map-loader/test/browser/fixtures/source-map-spec-tests.json -@@ -0,0 +1,28 @@ +@@ -0,0 +1,60 @@ +{ + "tests": [ + { @@ -120,9 +188,62 @@ index 0000000000000..086f41ae34a35 + "baseFile": "version-too-low.js", + "sourceMapFile": "version-too-low.js.map", + "sourceMapIsValid": false ++ }, ++ { ++ "name": "unrecognizedProperty", ++ "baseFile": "unrecognized-property.js", ++ "sourceMapFile": "unrecognized-property.js.map", ++ "sourceMapIsValid": true ++ }, ++ { ++ "name": "basicMapping", ++ "baseFile": "basic-mapping.js", ++ "sourceMapFile": "basic-mapping.js.map", ++ "sourceMapIsValid": true, ++ "testActions": [ ++ { ++ "actionType": "checkMapping", ++ "originalSource": "basic-mapping-original.js", ++ "originalLine": 0, ++ "originalColumn": 9, ++ "generatedLine": 0, ++ "generatedColumn": 9, ++ "mappedName": "foo" ++ }, ++ { ++ "actionType": "checkMapping", ++ "originalSource": "basic-mapping-original.js", ++ "originalLine": 3, ++ "originalColumn": 9, ++ "generatedLine": 0, ++ "generatedColumn": 34, ++ "mappedName": "bar" ++ } ++ ] + } + ] +} +diff --git a/devtools/client/shared/source-map-loader/test/browser/fixtures/unrecognized-property.js b/devtools/client/shared/source-map-loader/test/browser/fixtures/unrecognized-property.js +new file mode 100644 +index 0000000000000..47303d1fcf302 +--- /dev/null ++++ b/devtools/client/shared/source-map-loader/test/browser/fixtures/unrecognized-property.js +@@ -0,0 +1 @@ ++// # sourceMappingURL=unrecognized-property.js.map +diff --git a/devtools/client/shared/source-map-loader/test/browser/fixtures/unrecognized-property.js.map b/devtools/client/shared/source-map-loader/test/browser/fixtures/unrecognized-property.js.map +new file mode 100644 +index 0000000000000..40bee558a4ff9 +--- /dev/null ++++ b/devtools/client/shared/source-map-loader/test/browser/fixtures/unrecognized-property.js.map +@@ -0,0 +1,8 @@ ++{ ++ "version" : 3, ++ "sources": [], ++ "names": [], ++ "mappings": "", ++ "foobar": 42, ++ "unusedProperty": [1, 2, 3, 4] ++} diff --git a/devtools/client/shared/source-map-loader/test/browser/fixtures/version-not-a-number.js b/devtools/client/shared/source-map-loader/test/browser/fixtures/version-not-a-number.js new file mode 100644 index 0000000000000..5382a716e3a21 From 037f7329be049a91b52ff666bd0302f202ff2ca3 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Mon, 4 Mar 2024 16:24:27 -0800 Subject: [PATCH 19/68] Use a better hack for preserving test case name --- firefox/browser_spec-source-map.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/firefox/browser_spec-source-map.js b/firefox/browser_spec-source-map.js index 34695d6..602916f 100644 --- a/firefox/browser_spec-source-map.js +++ b/firefox/browser_spec-source-map.js @@ -30,18 +30,18 @@ const SPEC_TESTS_URI = `${URL_ROOT_SSL}fixtures/source-map-spec-tests.json` const testDescriptions = JSON.parse(read(SPEC_TESTS_URI)); for (const testCase of testDescriptions.tests) { - async function testFunction() { - const baseName = testCase.baseFile.substring(0, testCase.baseFile.indexOf(".js")); - Assert.equal(testCase.sourceMapIsValid, await isValidSourceMap(baseName)); + // The following uses a hack to ensure the test case name is used in stack traces. + const testFunction = {[testCase.name]: async function() { + const baseName = testCase.baseFile.substring(0, testCase.baseFile.indexOf(".js")); + Assert.equal(testCase.sourceMapIsValid, await isValidSourceMap(baseName)); - if (testCase.testActions) { - for (const action of testCase.testActions) { - if (action.actionType === "checkMapping") - await checkMapping(testCase, action); - } + if (testCase.testActions) { + for (const action of testCase.testActions) { + if (action.actionType === "checkMapping") + await checkMapping(testCase, action); } - }; - Object.defineProperty(testFunction, "name", { value: testCase.name }); + } + }}[testCase.name]; add_task(testFunction); } From 2a23caa94bed9ef3233fa5e1d538401b3949ff21 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Mon, 4 Mar 2024 16:25:03 -0800 Subject: [PATCH 20/68] Add a numeric string test case for the version A version field like "3" is is accepted in some tools but not technically valid. For the purposes of spec tests, we specify it's invalid. --- resources/version-numeric-string.js | 1 + resources/version-numeric-string.js.map | 6 ++++++ source-map-spec-tests.json | 6 ++++++ 3 files changed, 13 insertions(+) create mode 100644 resources/version-numeric-string.js create mode 100644 resources/version-numeric-string.js.map diff --git a/resources/version-numeric-string.js b/resources/version-numeric-string.js new file mode 100644 index 0000000..241a01d --- /dev/null +++ b/resources/version-numeric-string.js @@ -0,0 +1 @@ +// # sourceMappingURL=version-numeric-string.js.map diff --git a/resources/version-numeric-string.js.map b/resources/version-numeric-string.js.map new file mode 100644 index 0000000..dbe52a7 --- /dev/null +++ b/resources/version-numeric-string.js.map @@ -0,0 +1,6 @@ +{ + "version" : "3", + "sources": [], + "names": [], + "mappings": "" +} diff --git a/source-map-spec-tests.json b/source-map-spec-tests.json index 16d8442..a9f1c14 100644 --- a/source-map-spec-tests.json +++ b/source-map-spec-tests.json @@ -12,6 +12,12 @@ "sourceMapFile": "version-not-a-number.js.map", "sourceMapIsValid": false }, + { + "name": "versionNumericString", + "baseFile": "version-numeric-string.js", + "sourceMapFile": "version-numeric-string.js.map", + "sourceMapIsValid": false + }, { "name": "versionTooHigh", "baseFile": "version-too-high.js", From a94ebf9e88977205d0619a5abdbc3b722b5aeeb0 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Wed, 20 Mar 2024 16:45:17 -0700 Subject: [PATCH 21/68] Add WebKit test harness --- ...d-harness-for-source-maps-spec-tests.patch | 402 ++++++++++++++++++ webkit/source-map-spec.html | 70 +++ 2 files changed, 472 insertions(+) create mode 100644 webkit/0001-Add-harness-for-source-maps-spec-tests.patch create mode 100644 webkit/source-map-spec.html diff --git a/webkit/0001-Add-harness-for-source-maps-spec-tests.patch b/webkit/0001-Add-harness-for-source-maps-spec-tests.patch new file mode 100644 index 0000000..00acf97 --- /dev/null +++ b/webkit/0001-Add-harness-for-source-maps-spec-tests.patch @@ -0,0 +1,402 @@ +From 7b5cfb32770099d368aed4b4340dae3074541e91 Mon Sep 17 00:00:00 2001 +From: Asumu Takikawa +Date: Mon, 11 Mar 2024 13:41:31 -0700 +Subject: [PATCH] Add harness for source maps spec tests + +Need a short description (OOPS!). +Need the bug URL (OOPS!). + +Reviewed by NOBODY (OOPS!). + +Explanation of why this fixes the bug (OOPS!). + +* LayoutTests/inspector/model/resources/basic-mapping-original.js: Added. +(foo): +(bar): +* LayoutTests/inspector/model/resources/basic-mapping.js: Added. +(foo): +(bar): +* LayoutTests/inspector/model/resources/basic-mapping.js.map: Added. +* LayoutTests/inspector/model/resources/source-map-spec-tests.json: Added. +* LayoutTests/inspector/model/resources/unrecognized-property.js: Added. +* LayoutTests/inspector/model/resources/unrecognized-property.js.map: Added. +* LayoutTests/inspector/model/resources/version-not-a-number.js: Added. +* LayoutTests/inspector/model/resources/version-not-a-number.js.map: Added. +* LayoutTests/inspector/model/resources/version-numeric-string.js: Added. +* LayoutTests/inspector/model/resources/version-numeric-string.js.map: Added. +* LayoutTests/inspector/model/resources/version-too-high.js: Added. +* LayoutTests/inspector/model/resources/version-too-high.js.map: Added. +* LayoutTests/inspector/model/resources/version-too-low.js: Added. +* LayoutTests/inspector/model/resources/version-too-low.js.map: Added. +* LayoutTests/inspector/model/resources/version-valid.js: Added. +* LayoutTests/inspector/model/resources/version-valid.js.map: Added. +* LayoutTests/inspector/model/source-map-spec-expected.txt: Added. +* LayoutTests/inspector/model/source-map-spec.html: Added. +--- + .../model/resources/basic-mapping-original.js | 8 +++ + .../model/resources/basic-mapping.js | 2 + + .../model/resources/basic-mapping.js.map | 6 ++ + .../resources/source-map-spec-tests.json | 66 +++++++++++++++++ + .../model/resources/unrecognized-property.js | 1 + + .../resources/unrecognized-property.js.map | 8 +++ + .../model/resources/version-not-a-number.js | 1 + + .../resources/version-not-a-number.js.map | 6 ++ + .../model/resources/version-numeric-string.js | 1 + + .../resources/version-numeric-string.js.map | 6 ++ + .../model/resources/version-too-high.js | 1 + + .../model/resources/version-too-high.js.map | 6 ++ + .../model/resources/version-too-low.js | 1 + + .../model/resources/version-too-low.js.map | 6 ++ + .../model/resources/version-valid.js | 1 + + .../model/resources/version-valid.js.map | 6 ++ + .../model/source-map-spec-expected.txt | 22 ++++++ + .../inspector/model/source-map-spec.html | 70 +++++++++++++++++++ + 18 files changed, 218 insertions(+) + create mode 100644 LayoutTests/inspector/model/resources/basic-mapping-original.js + create mode 100644 LayoutTests/inspector/model/resources/basic-mapping.js + create mode 100644 LayoutTests/inspector/model/resources/basic-mapping.js.map + create mode 100644 LayoutTests/inspector/model/resources/source-map-spec-tests.json + create mode 100644 LayoutTests/inspector/model/resources/unrecognized-property.js + create mode 100644 LayoutTests/inspector/model/resources/unrecognized-property.js.map + create mode 100644 LayoutTests/inspector/model/resources/version-not-a-number.js + create mode 100644 LayoutTests/inspector/model/resources/version-not-a-number.js.map + create mode 100644 LayoutTests/inspector/model/resources/version-numeric-string.js + create mode 100644 LayoutTests/inspector/model/resources/version-numeric-string.js.map + create mode 100644 LayoutTests/inspector/model/resources/version-too-high.js + create mode 100644 LayoutTests/inspector/model/resources/version-too-high.js.map + create mode 100644 LayoutTests/inspector/model/resources/version-too-low.js + create mode 100644 LayoutTests/inspector/model/resources/version-too-low.js.map + create mode 100644 LayoutTests/inspector/model/resources/version-valid.js + create mode 100644 LayoutTests/inspector/model/resources/version-valid.js.map + create mode 100644 LayoutTests/inspector/model/source-map-spec-expected.txt + create mode 100644 LayoutTests/inspector/model/source-map-spec.html + +diff --git a/LayoutTests/inspector/model/resources/basic-mapping-original.js b/LayoutTests/inspector/model/resources/basic-mapping-original.js +new file mode 100644 +index 000000000000..301b186cb15e +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/basic-mapping-original.js +@@ -0,0 +1,8 @@ ++function foo() { ++ return 42; ++} ++function bar() { ++ return 24; ++} ++foo(); ++bar(); +diff --git a/LayoutTests/inspector/model/resources/basic-mapping.js b/LayoutTests/inspector/model/resources/basic-mapping.js +new file mode 100644 +index 000000000000..2e479a4175b8 +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/basic-mapping.js +@@ -0,0 +1,2 @@ ++function foo(){return 42}function bar(){return 24}foo();bar(); ++//# sourceMappingURL=basic-mapping.js.map +diff --git a/LayoutTests/inspector/model/resources/basic-mapping.js.map b/LayoutTests/inspector/model/resources/basic-mapping.js.map +new file mode 100644 +index 000000000000..12dc9679a4b1 +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/basic-mapping.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version":3, ++ "names": ["foo","bar"], ++ "sources": ["basic-mapping-original.js"], ++ "mappings":"AAAA,SAASA,MACP,OAAO,EACT,CACA,SAASC,MACP,OAAO,EACT,CACAD,MACAC" ++} +diff --git a/LayoutTests/inspector/model/resources/source-map-spec-tests.json b/LayoutTests/inspector/model/resources/source-map-spec-tests.json +new file mode 100644 +index 000000000000..a9f1c149f102 +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/source-map-spec-tests.json +@@ -0,0 +1,66 @@ ++{ ++ "tests": [ ++ { ++ "name": "versionValid", ++ "baseFile": "version-valid.js", ++ "sourceMapFile": "version-valid.js.map", ++ "sourceMapIsValid": true ++ }, ++ { ++ "name": "versionNotANumber", ++ "baseFile": "version-not-a-number.js", ++ "sourceMapFile": "version-not-a-number.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "versionNumericString", ++ "baseFile": "version-numeric-string.js", ++ "sourceMapFile": "version-numeric-string.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "versionTooHigh", ++ "baseFile": "version-too-high.js", ++ "sourceMapFile": "version-too-high.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "versionTooLow", ++ "baseFile": "version-too-low.js", ++ "sourceMapFile": "version-too-low.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "unrecognizedProperty", ++ "baseFile": "unrecognized-property.js", ++ "sourceMapFile": "unrecognized-property.js.map", ++ "sourceMapIsValid": true ++ }, ++ { ++ "name": "basicMapping", ++ "baseFile": "basic-mapping.js", ++ "sourceMapFile": "basic-mapping.js.map", ++ "sourceMapIsValid": true, ++ "testActions": [ ++ { ++ "actionType": "checkMapping", ++ "originalSource": "basic-mapping-original.js", ++ "originalLine": 0, ++ "originalColumn": 9, ++ "generatedLine": 0, ++ "generatedColumn": 9, ++ "mappedName": "foo" ++ }, ++ { ++ "actionType": "checkMapping", ++ "originalSource": "basic-mapping-original.js", ++ "originalLine": 3, ++ "originalColumn": 9, ++ "generatedLine": 0, ++ "generatedColumn": 34, ++ "mappedName": "bar" ++ } ++ ] ++ } ++ ] ++} +diff --git a/LayoutTests/inspector/model/resources/unrecognized-property.js b/LayoutTests/inspector/model/resources/unrecognized-property.js +new file mode 100644 +index 000000000000..19dfb0e2e6c7 +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/unrecognized-property.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=unrecognized-property.js.map +diff --git a/LayoutTests/inspector/model/resources/unrecognized-property.js.map b/LayoutTests/inspector/model/resources/unrecognized-property.js.map +new file mode 100644 +index 000000000000..40bee558a4ff +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/unrecognized-property.js.map +@@ -0,0 +1,8 @@ ++{ ++ "version" : 3, ++ "sources": [], ++ "names": [], ++ "mappings": "", ++ "foobar": 42, ++ "unusedProperty": [1, 2, 3, 4] ++} +diff --git a/LayoutTests/inspector/model/resources/version-not-a-number.js b/LayoutTests/inspector/model/resources/version-not-a-number.js +new file mode 100644 +index 000000000000..ae2342e2ffe5 +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/version-not-a-number.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=version-not-a-number.js.map +diff --git a/LayoutTests/inspector/model/resources/version-not-a-number.js.map b/LayoutTests/inspector/model/resources/version-not-a-number.js.map +new file mode 100644 +index 000000000000..a584d6e69511 +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/version-not-a-number.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version" : "3foo", ++ "sources": [], ++ "names": [], ++ "mappings": "" ++} +diff --git a/LayoutTests/inspector/model/resources/version-numeric-string.js b/LayoutTests/inspector/model/resources/version-numeric-string.js +new file mode 100644 +index 000000000000..a55170885da6 +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/version-numeric-string.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=version-numeric-string.js.map +diff --git a/LayoutTests/inspector/model/resources/version-numeric-string.js.map b/LayoutTests/inspector/model/resources/version-numeric-string.js.map +new file mode 100644 +index 000000000000..dbe52a7d0df6 +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/version-numeric-string.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version" : "3", ++ "sources": [], ++ "names": [], ++ "mappings": "" ++} +diff --git a/LayoutTests/inspector/model/resources/version-too-high.js b/LayoutTests/inspector/model/resources/version-too-high.js +new file mode 100644 +index 000000000000..55f4e1a298fa +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/version-too-high.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=version-too-high.js.map +diff --git a/LayoutTests/inspector/model/resources/version-too-high.js.map b/LayoutTests/inspector/model/resources/version-too-high.js.map +new file mode 100644 +index 000000000000..ee23be32ff27 +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/version-too-high.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version" : 4, ++ "sources": [], ++ "names": [], ++ "mappings": "" ++} +diff --git a/LayoutTests/inspector/model/resources/version-too-low.js b/LayoutTests/inspector/model/resources/version-too-low.js +new file mode 100644 +index 000000000000..d9642920b313 +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/version-too-low.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=version-too-low.js.map +diff --git a/LayoutTests/inspector/model/resources/version-too-low.js.map b/LayoutTests/inspector/model/resources/version-too-low.js.map +new file mode 100644 +index 000000000000..64ca7a6e2e92 +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/version-too-low.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version" : 2, ++ "sources": [], ++ "names": [], ++ "mappings": "" ++} +diff --git a/LayoutTests/inspector/model/resources/version-valid.js b/LayoutTests/inspector/model/resources/version-valid.js +new file mode 100644 +index 000000000000..82d0bfa1eb2a +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/version-valid.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=version-valid.js.map +diff --git a/LayoutTests/inspector/model/resources/version-valid.js.map b/LayoutTests/inspector/model/resources/version-valid.js.map +new file mode 100644 +index 000000000000..1a163052d8fc +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/version-valid.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version" : 3, ++ "sources": [], ++ "names": [], ++ "mappings": "" ++} +diff --git a/LayoutTests/inspector/model/source-map-spec-expected.txt b/LayoutTests/inspector/model/source-map-spec-expected.txt +new file mode 100644 +index 000000000000..c74ab5bcfb32 +--- /dev/null ++++ b/LayoutTests/inspector/model/source-map-spec-expected.txt +@@ -0,0 +1,22 @@ ++Ensure a source map loads for resources with sourceMappingURLs. ++ ++ ++== Running test suite: SourceMapSpec ++-- Running test case: SourceMapSpec ++PASS: Resource should have loaded 1 SourceMap. ++PASS: SourceMap should be a WI.SourceMap instance. ++PASS: Resource may or may not load a SourceMap. ++PASS: Resource may or may not load a SourceMap. ++PASS: Resource may or may not load a SourceMap. ++PASS: Resource may or may not load a SourceMap. ++PASS: Resource should have loaded 1 SourceMap. ++PASS: SourceMap should be a WI.SourceMap instance. ++PASS: Resource should have loaded 1 SourceMap. ++PASS: SourceMap should be a WI.SourceMap instance. ++PASS: expectEqual(0, 0) ++PASS: expectEqual(9, 9) ++PASS: expectEqual("basic-mapping-original.js", "basic-mapping-original.js") ++PASS: expectEqual(3, 3) ++PASS: expectEqual(9, 9) ++PASS: expectEqual("basic-mapping-original.js", "basic-mapping-original.js") ++ +diff --git a/LayoutTests/inspector/model/source-map-spec.html b/LayoutTests/inspector/model/source-map-spec.html +new file mode 100644 +index 000000000000..9763c9294ef5 +--- /dev/null ++++ b/LayoutTests/inspector/model/source-map-spec.html +@@ -0,0 +1,70 @@ ++ ++ ++ ++ ++ ++ ++ ++

Ensure a source map loads for resources with sourceMappingURLs.

++ ++ +-- +2.39.2 + diff --git a/webkit/source-map-spec.html b/webkit/source-map-spec.html new file mode 100644 index 0000000..9763c92 --- /dev/null +++ b/webkit/source-map-spec.html @@ -0,0 +1,70 @@ + + + + + + + +

Ensure a source map loads for resources with sourceMappingURLs.

+ + From c869f00fd170d6534be384bc4a6fbbbac7f4a560 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Wed, 20 Mar 2024 16:52:21 -0700 Subject: [PATCH 22/68] Fix source mapping comment in tests The invalid form is accepted by some implementations, so it would be worth putting that in as an additional test. Also add a missing comment in basic-mapping.js --- resources/basic-mapping.js | 3 ++- resources/unrecognized-property.js | 2 +- resources/version-not-a-number.js | 2 +- resources/version-numeric-string.js | 2 +- resources/version-too-high.js | 2 +- resources/version-too-low.js | 2 +- resources/version-valid.js | 2 +- 7 files changed, 8 insertions(+), 7 deletions(-) diff --git a/resources/basic-mapping.js b/resources/basic-mapping.js index 9df7240..2e479a4 100644 --- a/resources/basic-mapping.js +++ b/resources/basic-mapping.js @@ -1 +1,2 @@ -function foo(){return 42}function bar(){return 24}foo();bar(); \ No newline at end of file +function foo(){return 42}function bar(){return 24}foo();bar(); +//# sourceMappingURL=basic-mapping.js.map diff --git a/resources/unrecognized-property.js b/resources/unrecognized-property.js index 47303d1..19dfb0e 100644 --- a/resources/unrecognized-property.js +++ b/resources/unrecognized-property.js @@ -1 +1 @@ -// # sourceMappingURL=unrecognized-property.js.map +//# sourceMappingURL=unrecognized-property.js.map diff --git a/resources/version-not-a-number.js b/resources/version-not-a-number.js index 5382a71..ae2342e 100644 --- a/resources/version-not-a-number.js +++ b/resources/version-not-a-number.js @@ -1 +1 @@ -// # sourceMappingURL=version-not-a-number.js.map +//# sourceMappingURL=version-not-a-number.js.map diff --git a/resources/version-numeric-string.js b/resources/version-numeric-string.js index 241a01d..a551708 100644 --- a/resources/version-numeric-string.js +++ b/resources/version-numeric-string.js @@ -1 +1 @@ -// # sourceMappingURL=version-numeric-string.js.map +//# sourceMappingURL=version-numeric-string.js.map diff --git a/resources/version-too-high.js b/resources/version-too-high.js index 04bfe7f..55f4e1a 100644 --- a/resources/version-too-high.js +++ b/resources/version-too-high.js @@ -1 +1 @@ -// # sourceMappingURL=version-too-high.js.map +//# sourceMappingURL=version-too-high.js.map diff --git a/resources/version-too-low.js b/resources/version-too-low.js index 54b3526..d964292 100644 --- a/resources/version-too-low.js +++ b/resources/version-too-low.js @@ -1 +1 @@ -// # sourceMappingURL=version-too-low.js.map +//# sourceMappingURL=version-too-low.js.map diff --git a/resources/version-valid.js b/resources/version-valid.js index f8541f9..82d0bfa 100644 --- a/resources/version-valid.js +++ b/resources/version-valid.js @@ -1 +1 @@ -// # sourceMappingURL=version-valid.js.map +//# sourceMappingURL=version-valid.js.map From 09badfed62650f2b6320a13f0546ef5b9d2b059c Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Thu, 21 Mar 2024 15:57:16 -0700 Subject: [PATCH 23/68] Update build instructions --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c66abd5..03cf880 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,15 @@ Source Map spec: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze These test cases are still a work-in-progress 🚧. How to run in Firefox: - * Check out mozilla-unified + * Check out mozilla-unified (see [Firefox dev setup](https://firefox-source-docs.mozilla.org/setup/index.html) for details, note that you can use git via [git-cinnabar](https://github.com/glandium/git-cinnabar/)) + * Change to the checked out directory. * `git am /firefox/0001-WIP-Firefox-source-map-spec-tests.patch` * `mach build` * `mach test devtools/client/shared/source-map-loader/` + +How to run in WebKit: + * Check out [WebKit](https://github.com/WebKit/WebKit/) + * `git am /webkit/0001-Add-harness-for-source-maps-spec-tests.patch` + * Change to the WebKit directory. + * Run `Tools/Scripts/build-webkit` (depending on the platform you may need to pass `--gtk` or other flags) + * Run `run-webkit-tests LayoutTests/inspector/model/source-map-spec.html` (again, you may need `--gtk` on Linux) From 55aff10316b20993b5fcf03645786b5c43b3ca19 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Thu, 21 Mar 2024 16:01:08 -0700 Subject: [PATCH 24/68] Fix some details in the instructions to be clearer --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 03cf880..8a47eb6 100644 --- a/README.md +++ b/README.md @@ -15,15 +15,15 @@ Source Map spec: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze These test cases are still a work-in-progress 🚧. How to run in Firefox: - * Check out mozilla-unified (see [Firefox dev setup](https://firefox-source-docs.mozilla.org/setup/index.html) for details, note that you can use git via [git-cinnabar](https://github.com/glandium/git-cinnabar/)) - * Change to the checked out directory. - * `git am /firefox/0001-WIP-Firefox-source-map-spec-tests.patch` - * `mach build` - * `mach test devtools/client/shared/source-map-loader/` + * Check out mozilla-unified (see [Firefox dev setup](https://firefox-source-docs.mozilla.org/setup/index.html) under "Setting up your machine" for details, note that you can use git via [git-cinnabar](https://github.com/glandium/git-cinnabar/)) + * `cd` to the checked out directory. + * Run `git am /firefox/0001-WIP-Firefox-source-map-spec-tests.patch` + * Run `mach build` (this builds the test too, you'll need to run it if you modify tests/harness) + * Run `mach test devtools/client/shared/source-map-loader/` How to run in WebKit: * Check out [WebKit](https://github.com/WebKit/WebKit/) - * `git am /webkit/0001-Add-harness-for-source-maps-spec-tests.patch` - * Change to the WebKit directory. + * `cd` to the checked out WebKit directory. + * Run `git am /webkit/0001-Add-harness-for-source-maps-spec-tests.patch` * Run `Tools/Scripts/build-webkit` (depending on the platform you may need to pass `--gtk` or other flags) - * Run `run-webkit-tests LayoutTests/inspector/model/source-map-spec.html` (again, you may need `--gtk` on Linux) + * Run `Tools/Scripts/run-webkit-tests LayoutTests/inspector/model/source-map-spec.html` (again, you may need `--gtk` on Linux) From 8fc8bd57b86cafaa32ab68c4dcb7dd64e39bb709 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Tue, 26 Mar 2024 15:34:14 -0700 Subject: [PATCH 25/68] Add new tests for correct mapping format Improves Firefox harness to check these new conditions as well, TODO to add it for WebKit --- firefox/browser_spec-source-map.js | 11 +++++---- resources/invalid-mapping-bad-separator.js | 2 ++ .../invalid-mapping-bad-separator.js.map | 6 +++++ ...valid-mapping-segment-with-three-fields.js | 2 ++ ...d-mapping-segment-with-three-fields.js.map | 6 +++++ ...invalid-mapping-segment-with-two-fields.js | 2 ++ ...lid-mapping-segment-with-two-fields.js.map | 6 +++++ resources/invalid-vlq-non-base64-char.js | 1 + resources/invalid-vlq-non-base64-char.js.map | 6 +++++ source-map-spec-tests.json | 24 +++++++++++++++++++ 10 files changed, 62 insertions(+), 4 deletions(-) create mode 100644 resources/invalid-mapping-bad-separator.js create mode 100644 resources/invalid-mapping-bad-separator.js.map create mode 100644 resources/invalid-mapping-segment-with-three-fields.js create mode 100644 resources/invalid-mapping-segment-with-three-fields.js.map create mode 100644 resources/invalid-mapping-segment-with-two-fields.js create mode 100644 resources/invalid-mapping-segment-with-two-fields.js.map create mode 100644 resources/invalid-vlq-non-base64-char.js create mode 100644 resources/invalid-vlq-non-base64-char.js.map diff --git a/firefox/browser_spec-source-map.js b/firefox/browser_spec-source-map.js index 602916f..af18e9b 100644 --- a/firefox/browser_spec-source-map.js +++ b/firefox/browser_spec-source-map.js @@ -4,13 +4,16 @@ const { generatedToOriginalId, } = require("resource://devtools/client/shared/source-map-loader/utils/index.js"); -async function isValidSourceMap(base) { +async function checkValidity(isValid, base, testCase) { try { await fetchFixtureSourceMap(base); + const originalId = generatedToOriginalId(testCase.baseFile, "unused"); + await gSourceMapLoader.getOriginalRanges(originalId); } catch (exn) { - return false; + Assert.ok(!isValid, "Source map loading failed with " + exn.message); + return; } - return true; + Assert.ok(isValid, "Source map loading should have failed but did not"); } async function checkMapping(testCase, action) { @@ -33,7 +36,7 @@ for (const testCase of testDescriptions.tests) { // The following uses a hack to ensure the test case name is used in stack traces. const testFunction = {[testCase.name]: async function() { const baseName = testCase.baseFile.substring(0, testCase.baseFile.indexOf(".js")); - Assert.equal(testCase.sourceMapIsValid, await isValidSourceMap(baseName)); + await checkValidity(testCase.sourceMapIsValid, baseName, testCase); if (testCase.testActions) { for (const action of testCase.testActions) { diff --git a/resources/invalid-mapping-bad-separator.js b/resources/invalid-mapping-bad-separator.js new file mode 100644 index 0000000..25338ac --- /dev/null +++ b/resources/invalid-mapping-bad-separator.js @@ -0,0 +1,2 @@ +function foo(){return 42}function bar(){return 24}foo();bar(); +//# sourceMappingURL=invalid-mapping-bad-separator.js.map diff --git a/resources/invalid-mapping-bad-separator.js.map b/resources/invalid-mapping-bad-separator.js.map new file mode 100644 index 0000000..5f4f5b9 --- /dev/null +++ b/resources/invalid-mapping-bad-separator.js.map @@ -0,0 +1,6 @@ +{ + "version": 3, + "names": ["foo","bar"], + "sources": ["basic-mapping-original.js"], + "mappings": "AAAA.SAASA:MACP" +} diff --git a/resources/invalid-mapping-segment-with-three-fields.js b/resources/invalid-mapping-segment-with-three-fields.js new file mode 100644 index 0000000..4b868fa --- /dev/null +++ b/resources/invalid-mapping-segment-with-three-fields.js @@ -0,0 +1,2 @@ +function foo(){return 42}function bar(){return 24}foo();bar(); +//# sourceMappingURL=invalid-mapping-three-fields.js.map diff --git a/resources/invalid-mapping-segment-with-three-fields.js.map b/resources/invalid-mapping-segment-with-three-fields.js.map new file mode 100644 index 0000000..c2af116 --- /dev/null +++ b/resources/invalid-mapping-segment-with-three-fields.js.map @@ -0,0 +1,6 @@ +{ + "version": 3, + "names": ["foo","bar"], + "sources": ["basic-mapping-original.js"], + "mappings": "AAA" +} diff --git a/resources/invalid-mapping-segment-with-two-fields.js b/resources/invalid-mapping-segment-with-two-fields.js new file mode 100644 index 0000000..96045a7 --- /dev/null +++ b/resources/invalid-mapping-segment-with-two-fields.js @@ -0,0 +1,2 @@ +function foo(){return 42}function bar(){return 24}foo();bar(); +//# sourceMappingURL=invalid-mapping-two-fields.js.map diff --git a/resources/invalid-mapping-segment-with-two-fields.js.map b/resources/invalid-mapping-segment-with-two-fields.js.map new file mode 100644 index 0000000..73cf00f --- /dev/null +++ b/resources/invalid-mapping-segment-with-two-fields.js.map @@ -0,0 +1,6 @@ +{ + "version": 3, + "names": ["foo","bar"], + "sources": ["basic-mapping-original.js"], + "mappings": "AA" +} diff --git a/resources/invalid-vlq-non-base64-char.js b/resources/invalid-vlq-non-base64-char.js new file mode 100644 index 0000000..d1b20b4 --- /dev/null +++ b/resources/invalid-vlq-non-base64-char.js @@ -0,0 +1 @@ +//# sourceMappingURL=invalid-vlq-non-base64-char.js.map diff --git a/resources/invalid-vlq-non-base64-char.js.map b/resources/invalid-vlq-non-base64-char.js.map new file mode 100644 index 0000000..4fa1ac5 --- /dev/null +++ b/resources/invalid-vlq-non-base64-char.js.map @@ -0,0 +1,6 @@ +{ + "version" : 3, + "sources": [], + "names": [], + "mappings": "A$%?!" +} diff --git a/source-map-spec-tests.json b/source-map-spec-tests.json index a9f1c14..bc85d28 100644 --- a/source-map-spec-tests.json +++ b/source-map-spec-tests.json @@ -36,6 +36,30 @@ "sourceMapFile": "unrecognized-property.js.map", "sourceMapIsValid": true }, + { + "name": "invalidVLQDueToNonBase64Character", + "baseFile": "invalid-vlq-non-base64-char.js", + "sourceMapFile": "invalid-vlq-non-base64-char.js.map", + "sourceMapIsValid": false + }, + { + "name": "invalidMappingSegmentBadSeparator", + "baseFile": "invalid-mapping-bad-separator.js", + "sourceMapFile": "invalid-mapping-bad-separator.js.map", + "sourceMapIsValid": false + }, + { + "name": "invalidMappingSegmentWithTwoFields", + "baseFile": "invalid-mapping-segment-with-two-fields.js", + "sourceMapFile": "invalid-mapping-segment-with-two-fields.js.map", + "sourceMapIsValid": false + }, + { + "name": "invalidMappingSegmentWithThreeFields", + "baseFile": "invalid-mapping-segment-with-three-fields.js", + "sourceMapFile": "invalid-mapping-segment-with-three-fields.js.map", + "sourceMapIsValid": false + }, { "name": "basicMapping", "baseFile": "basic-mapping.js", From 5c67f20751c315051e9111f57e56a4f625d2d04b Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Tue, 26 Mar 2024 17:07:08 -0700 Subject: [PATCH 26/68] Add tests for negative non-relative fields --- ...invalid-mapping-segment-negative-column.js | 1 + ...lid-mapping-segment-negative-column.js.map | 6 ++++ ...lid-mapping-segment-negative-name-index.js | 1 + ...mapping-segment-negative-name-index.js.map | 6 ++++ ...apping-segment-negative-original-column.js | 1 + ...ng-segment-negative-original-column.js.map | 6 ++++ ...-mapping-segment-negative-original-line.js | 1 + ...ping-segment-negative-original-line.js.map | 6 ++++ ...d-mapping-segment-negative-source-index.js | 1 + ...pping-segment-negative-source-index.js.map | 6 ++++ source-map-spec-tests.json | 30 +++++++++++++++++++ 11 files changed, 65 insertions(+) create mode 100644 resources/invalid-mapping-segment-negative-column.js create mode 100644 resources/invalid-mapping-segment-negative-column.js.map create mode 100644 resources/invalid-mapping-segment-negative-name-index.js create mode 100644 resources/invalid-mapping-segment-negative-name-index.js.map create mode 100644 resources/invalid-mapping-segment-negative-original-column.js create mode 100644 resources/invalid-mapping-segment-negative-original-column.js.map create mode 100644 resources/invalid-mapping-segment-negative-original-line.js create mode 100644 resources/invalid-mapping-segment-negative-original-line.js.map create mode 100644 resources/invalid-mapping-segment-negative-source-index.js create mode 100644 resources/invalid-mapping-segment-negative-source-index.js.map diff --git a/resources/invalid-mapping-segment-negative-column.js b/resources/invalid-mapping-segment-negative-column.js new file mode 100644 index 0000000..a202152 --- /dev/null +++ b/resources/invalid-mapping-segment-negative-column.js @@ -0,0 +1 @@ +//# sourceMappingURL=invalid-mapping-segment-negative-column.js.map diff --git a/resources/invalid-mapping-segment-negative-column.js.map b/resources/invalid-mapping-segment-negative-column.js.map new file mode 100644 index 0000000..fc78d88 --- /dev/null +++ b/resources/invalid-mapping-segment-negative-column.js.map @@ -0,0 +1,6 @@ +{ + "version": 3, + "names": [], + "sources": ["invalid-mapping-segment-negative-column.js"], + "mappings": "F" +} diff --git a/resources/invalid-mapping-segment-negative-name-index.js b/resources/invalid-mapping-segment-negative-name-index.js new file mode 100644 index 0000000..3e3f634 --- /dev/null +++ b/resources/invalid-mapping-segment-negative-name-index.js @@ -0,0 +1 @@ +//# sourceMappingURL=invalid-mapping-segment-negative-name-index.js.map diff --git a/resources/invalid-mapping-segment-negative-name-index.js.map b/resources/invalid-mapping-segment-negative-name-index.js.map new file mode 100644 index 0000000..7b1717f --- /dev/null +++ b/resources/invalid-mapping-segment-negative-name-index.js.map @@ -0,0 +1,6 @@ +{ + "version": 3, + "names": [], + "sources": ["invalid-mapping-segment-negative-name-index.js"], + "mappings": "AAAAF" +} diff --git a/resources/invalid-mapping-segment-negative-original-column.js b/resources/invalid-mapping-segment-negative-original-column.js new file mode 100644 index 0000000..f21d534 --- /dev/null +++ b/resources/invalid-mapping-segment-negative-original-column.js @@ -0,0 +1 @@ +//# sourceMappingURL=invalid-mapping-segment-negative-original-column.js.map diff --git a/resources/invalid-mapping-segment-negative-original-column.js.map b/resources/invalid-mapping-segment-negative-original-column.js.map new file mode 100644 index 0000000..0469de0 --- /dev/null +++ b/resources/invalid-mapping-segment-negative-original-column.js.map @@ -0,0 +1,6 @@ +{ + "version": 3, + "names": [], + "sources": ["invalid-mapping-segment-negative-original-column.js"], + "mappings": "AAAF" +} diff --git a/resources/invalid-mapping-segment-negative-original-line.js b/resources/invalid-mapping-segment-negative-original-line.js new file mode 100644 index 0000000..b373096 --- /dev/null +++ b/resources/invalid-mapping-segment-negative-original-line.js @@ -0,0 +1 @@ +//# sourceMappingURL=invalid-mapping-segment-negative-original-line.js.map diff --git a/resources/invalid-mapping-segment-negative-original-line.js.map b/resources/invalid-mapping-segment-negative-original-line.js.map new file mode 100644 index 0000000..1f33706 --- /dev/null +++ b/resources/invalid-mapping-segment-negative-original-line.js.map @@ -0,0 +1,6 @@ +{ + "version": 3, + "names": [], + "sources": ["invalid-mapping-segment-negative-original-line.js"], + "mappings": "AAFA" +} diff --git a/resources/invalid-mapping-segment-negative-source-index.js b/resources/invalid-mapping-segment-negative-source-index.js new file mode 100644 index 0000000..6e05849 --- /dev/null +++ b/resources/invalid-mapping-segment-negative-source-index.js @@ -0,0 +1 @@ +//# sourceMappingURL=invalid-mapping-segment-negative-source-index.js.map diff --git a/resources/invalid-mapping-segment-negative-source-index.js.map b/resources/invalid-mapping-segment-negative-source-index.js.map new file mode 100644 index 0000000..5453ad0 --- /dev/null +++ b/resources/invalid-mapping-segment-negative-source-index.js.map @@ -0,0 +1,6 @@ +{ + "version": 3, + "names": [], + "sources": ["invalid-mapping-segment-negative-source-index.js"], + "mappings": "AFAA" +} diff --git a/source-map-spec-tests.json b/source-map-spec-tests.json index bc85d28..517d1d6 100644 --- a/source-map-spec-tests.json +++ b/source-map-spec-tests.json @@ -60,6 +60,36 @@ "sourceMapFile": "invalid-mapping-segment-with-three-fields.js.map", "sourceMapIsValid": false }, + { + "name": "invalidMappingSegmentWithNegativeColumn", + "baseFile": "invalid-mapping-segment-negative-column.js", + "sourceMapFile": "invalid-mapping-segment-negative-column.js.map", + "sourceMapIsValid": false + }, + { + "name": "invalidMappingSegmentWithNegativeSourceIndex", + "baseFile": "invalid-mapping-segment-negative-source-index.js", + "sourceMapFile": "invalid-mapping-segment-negative-source-index.js.map", + "sourceMapIsValid": false + }, + { + "name": "invalidMappingSegmentWithNegativeOriginalLine", + "baseFile": "invalid-mapping-segment-negative-original-line.js", + "sourceMapFile": "invalid-mapping-segment-negative-original-line.js.map", + "sourceMapIsValid": false + }, + { + "name": "invalidMappingSegmentWithNegativeOriginalColumn", + "baseFile": "invalid-mapping-segment-negative-original-column.js", + "sourceMapFile": "invalid-mapping-segment-negative-original-column.js.map", + "sourceMapIsValid": false + }, + { + "name": "invalidMappingSegmentWithNegativeNameIndex", + "baseFile": "invalid-mapping-segment-negative-name-index.js", + "sourceMapFile": "invalid-mapping-segment-negative-name-index.js.map", + "sourceMapIsValid": false + }, { "name": "basicMapping", "baseFile": "basic-mapping.js", From 7203d11c683918f88e1acce1a33279e8961dc355 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Tue, 26 Mar 2024 17:16:45 -0700 Subject: [PATCH 27/68] Add description fields to test cases These can be used by test harnesses if desired, but mainly they are present to make it easier to understand what the intention of tests are. --- source-map-spec-tests.json | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/source-map-spec-tests.json b/source-map-spec-tests.json index 517d1d6..ebfc6fc 100644 --- a/source-map-spec-tests.json +++ b/source-map-spec-tests.json @@ -2,96 +2,112 @@ "tests": [ { "name": "versionValid", + "description": "Test a simple source map with a valid version number", "baseFile": "version-valid.js", "sourceMapFile": "version-valid.js.map", "sourceMapIsValid": true }, { "name": "versionNotANumber", + "description": "Test a source map with a version field that is not a number", "baseFile": "version-not-a-number.js", "sourceMapFile": "version-not-a-number.js.map", "sourceMapIsValid": false }, { "name": "versionNumericString", + "description": "Test a source map with a version field that is a number as a string", "baseFile": "version-numeric-string.js", "sourceMapFile": "version-numeric-string.js.map", "sourceMapIsValid": false }, { "name": "versionTooHigh", + "description": "Test a source map with an integer version field that is too high", "baseFile": "version-too-high.js", "sourceMapFile": "version-too-high.js.map", "sourceMapIsValid": false }, { "name": "versionTooLow", + "description": "Test a source map with an integer version field that is too low", "baseFile": "version-too-low.js", "sourceMapFile": "version-too-low.js.map", "sourceMapIsValid": false }, { "name": "unrecognizedProperty", + "description": "Test a source map that has an extra field not explicitly encoded in the spec", "baseFile": "unrecognized-property.js", "sourceMapFile": "unrecognized-property.js.map", "sourceMapIsValid": true }, { "name": "invalidVLQDueToNonBase64Character", + "description": "Test a source map that has a mapping with an invalid non-base64 character", "baseFile": "invalid-vlq-non-base64-char.js", "sourceMapFile": "invalid-vlq-non-base64-char.js.map", "sourceMapIsValid": false }, { "name": "invalidMappingSegmentBadSeparator", + "description": "Test a source map that uses separator characters not recognized in the spec", "baseFile": "invalid-mapping-bad-separator.js", "sourceMapFile": "invalid-mapping-bad-separator.js.map", "sourceMapIsValid": false }, { "name": "invalidMappingSegmentWithTwoFields", + "description": "Test a source map that has the wrong number (two) of segments fields", "baseFile": "invalid-mapping-segment-with-two-fields.js", "sourceMapFile": "invalid-mapping-segment-with-two-fields.js.map", "sourceMapIsValid": false }, { "name": "invalidMappingSegmentWithThreeFields", + "description": "Test a source map that has the wrong number (three) of segments fields", "baseFile": "invalid-mapping-segment-with-three-fields.js", "sourceMapFile": "invalid-mapping-segment-with-three-fields.js.map", "sourceMapIsValid": false }, { "name": "invalidMappingSegmentWithNegativeColumn", + "description": "Test a source map that has an invalid negative non-relative column field", "baseFile": "invalid-mapping-segment-negative-column.js", "sourceMapFile": "invalid-mapping-segment-negative-column.js.map", "sourceMapIsValid": false }, { "name": "invalidMappingSegmentWithNegativeSourceIndex", + "description": "Test a source map that has an invalid negative non-relative source index field", "baseFile": "invalid-mapping-segment-negative-source-index.js", "sourceMapFile": "invalid-mapping-segment-negative-source-index.js.map", "sourceMapIsValid": false }, { "name": "invalidMappingSegmentWithNegativeOriginalLine", + "description": "Test a source map that has an invalid negative non-relative original line field", "baseFile": "invalid-mapping-segment-negative-original-line.js", "sourceMapFile": "invalid-mapping-segment-negative-original-line.js.map", "sourceMapIsValid": false }, { "name": "invalidMappingSegmentWithNegativeOriginalColumn", + "description": "Test a source map that has an invalid negative non-relative original column field", "baseFile": "invalid-mapping-segment-negative-original-column.js", "sourceMapFile": "invalid-mapping-segment-negative-original-column.js.map", "sourceMapIsValid": false }, { "name": "invalidMappingSegmentWithNegativeNameIndex", + "description": "Test a source map that has an invalid negative non-relative name index field", "baseFile": "invalid-mapping-segment-negative-name-index.js", "sourceMapFile": "invalid-mapping-segment-negative-name-index.js.map", "sourceMapIsValid": false }, { "name": "basicMapping", + "description": "Test a simple source map that has several valid mappings", "baseFile": "basic-mapping.js", "sourceMapFile": "basic-mapping.js.map", "sourceMapIsValid": true, From ec6c9070efb458c02eca874edcd93ec611352799 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Thu, 28 Mar 2024 11:45:56 -0700 Subject: [PATCH 28/68] Add tests for field values being too large The spec gives a limit of 32-bits for the values of VLQ fields. However, it's not very precise on how this limit is implemented. For example, it's not clear if the sign bit is included or not. For these tests, we have assumed for now that values exceeding 32-bits are invalid and makes the mapping invalid. In addition, we have assumed the sign bit should be included in the limit. --- ...nvalid-mapping-segment-column-too-large.js | 1 + ...id-mapping-segment-column-too-large.js.map | 6 +++ ...id-mapping-segment-name-index-too-large.js | 1 + ...apping-segment-name-index-too-large.js.map | 6 +++ ...pping-segment-original-column-too-large.js | 1 + ...g-segment-original-column-too-large.js.map | 6 +++ ...mapping-segment-original-line-too-large.js | 1 + ...ing-segment-original-line-too-large.js.map | 6 +++ ...-mapping-segment-source-index-too-large.js | 1 + ...ping-segment-source-index-too-large.js.map | 6 +++ resources/valid-mapping-boundary-values.js | 1 + .../valid-mapping-boundary-values.js.map | 6 +++ source-map-spec-tests.json | 42 +++++++++++++++++++ 13 files changed, 84 insertions(+) create mode 100644 resources/invalid-mapping-segment-column-too-large.js create mode 100644 resources/invalid-mapping-segment-column-too-large.js.map create mode 100644 resources/invalid-mapping-segment-name-index-too-large.js create mode 100644 resources/invalid-mapping-segment-name-index-too-large.js.map create mode 100644 resources/invalid-mapping-segment-original-column-too-large.js create mode 100644 resources/invalid-mapping-segment-original-column-too-large.js.map create mode 100644 resources/invalid-mapping-segment-original-line-too-large.js create mode 100644 resources/invalid-mapping-segment-original-line-too-large.js.map create mode 100644 resources/invalid-mapping-segment-source-index-too-large.js create mode 100644 resources/invalid-mapping-segment-source-index-too-large.js.map create mode 100644 resources/valid-mapping-boundary-values.js create mode 100644 resources/valid-mapping-boundary-values.js.map diff --git a/resources/invalid-mapping-segment-column-too-large.js b/resources/invalid-mapping-segment-column-too-large.js new file mode 100644 index 0000000..55591f8 --- /dev/null +++ b/resources/invalid-mapping-segment-column-too-large.js @@ -0,0 +1 @@ +//# sourceMappingURL=invalid-mapping-segment-column-too-large.js.map diff --git a/resources/invalid-mapping-segment-column-too-large.js.map b/resources/invalid-mapping-segment-column-too-large.js.map new file mode 100644 index 0000000..dc2c346 --- /dev/null +++ b/resources/invalid-mapping-segment-column-too-large.js.map @@ -0,0 +1,6 @@ +{ + "version": 3, + "names": [], + "sources": ["invalid-mapping-segment-column-too-large.js"], + "mappings": "ggggggE" +} diff --git a/resources/invalid-mapping-segment-name-index-too-large.js b/resources/invalid-mapping-segment-name-index-too-large.js new file mode 100644 index 0000000..709e34d --- /dev/null +++ b/resources/invalid-mapping-segment-name-index-too-large.js @@ -0,0 +1 @@ +//# sourceMappingURL=invalid-mapping-segment-name-index-too-large.js.map diff --git a/resources/invalid-mapping-segment-name-index-too-large.js.map b/resources/invalid-mapping-segment-name-index-too-large.js.map new file mode 100644 index 0000000..e27eaf7 --- /dev/null +++ b/resources/invalid-mapping-segment-name-index-too-large.js.map @@ -0,0 +1,6 @@ +{ + "version": 3, + "names": [], + "sources": ["invalid-mapping-segment-name-index-too-large.js"], + "mappings": "AAAAggggggE" +} diff --git a/resources/invalid-mapping-segment-original-column-too-large.js b/resources/invalid-mapping-segment-original-column-too-large.js new file mode 100644 index 0000000..0936ed7 --- /dev/null +++ b/resources/invalid-mapping-segment-original-column-too-large.js @@ -0,0 +1 @@ +//# sourceMappingURL=invalid-mapping-segment-original-column-too-large.js.map diff --git a/resources/invalid-mapping-segment-original-column-too-large.js.map b/resources/invalid-mapping-segment-original-column-too-large.js.map new file mode 100644 index 0000000..218fc20 --- /dev/null +++ b/resources/invalid-mapping-segment-original-column-too-large.js.map @@ -0,0 +1,6 @@ +{ + "version": 3, + "names": [], + "sources": ["invalid-mapping-segment-original-column-too-large.js"], + "mappings": "AAAggggggE" +} diff --git a/resources/invalid-mapping-segment-original-line-too-large.js b/resources/invalid-mapping-segment-original-line-too-large.js new file mode 100644 index 0000000..9b3aa5a --- /dev/null +++ b/resources/invalid-mapping-segment-original-line-too-large.js @@ -0,0 +1 @@ +//# sourceMappingURL=invalid-mapping-segment-original-line-too-large.js.map diff --git a/resources/invalid-mapping-segment-original-line-too-large.js.map b/resources/invalid-mapping-segment-original-line-too-large.js.map new file mode 100644 index 0000000..d96075d --- /dev/null +++ b/resources/invalid-mapping-segment-original-line-too-large.js.map @@ -0,0 +1,6 @@ +{ + "version": 3, + "names": [], + "sources": ["invalid-mapping-segment-original-line-too-large.js"], + "mappings": "AAggggggEA" +} diff --git a/resources/invalid-mapping-segment-source-index-too-large.js b/resources/invalid-mapping-segment-source-index-too-large.js new file mode 100644 index 0000000..3f4943e --- /dev/null +++ b/resources/invalid-mapping-segment-source-index-too-large.js @@ -0,0 +1 @@ +//# sourceMappingURL=invalid-mapping-segment-source-index-too-large.js.map diff --git a/resources/invalid-mapping-segment-source-index-too-large.js.map b/resources/invalid-mapping-segment-source-index-too-large.js.map new file mode 100644 index 0000000..c136e36 --- /dev/null +++ b/resources/invalid-mapping-segment-source-index-too-large.js.map @@ -0,0 +1,6 @@ +{ + "version": 3, + "names": [], + "sources": ["invalid-mapping-segment-source-index-too-large.js"], + "mappings": "AggggggEAA" +} diff --git a/resources/valid-mapping-boundary-values.js b/resources/valid-mapping-boundary-values.js new file mode 100644 index 0000000..3c49709 --- /dev/null +++ b/resources/valid-mapping-boundary-values.js @@ -0,0 +1 @@ +//# sourceMappingURL=valid-mapping-boundary-values.js.map diff --git a/resources/valid-mapping-boundary-values.js.map b/resources/valid-mapping-boundary-values.js.map new file mode 100644 index 0000000..d80126b --- /dev/null +++ b/resources/valid-mapping-boundary-values.js.map @@ -0,0 +1,6 @@ +{ + "version": 3, + "names": ["foo"], + "sources": ["valid-mapping-boundary-values.js"], + "mappings": "+/////DA+/////D+/////DA" +} diff --git a/source-map-spec-tests.json b/source-map-spec-tests.json index ebfc6fc..777bb28 100644 --- a/source-map-spec-tests.json +++ b/source-map-spec-tests.json @@ -105,6 +105,48 @@ "sourceMapFile": "invalid-mapping-segment-negative-name-index.js.map", "sourceMapIsValid": false }, + { + "name": "invalidMappingSegmentWithColumnExceeding32Bits", + "description": "Test a source map that has a column field that exceeds 32 bits", + "baseFile": "invalid-mapping-segment-column-too-large.js", + "sourceMapFile": "invalid-mapping-segment-column-too-large.js.map", + "sourceMapIsValid": false + }, + { + "name": "invalidMappingSegmentWithSourceIndexExceeding32Bits", + "description": "Test a source map that has a source index field that exceeds 32 bits", + "baseFile": "invalid-mapping-segment-source-index-too-large.js", + "sourceMapFile": "invalid-mapping-segment-source-index-too-large.js.map", + "sourceMapIsValid": false + }, + { + "name": "invalidMappingSegmentWithOriginalLineExceeding32Bits", + "description": "Test a source map that has a original line field that exceeds 32 bits", + "baseFile": "invalid-mapping-segment-original-line-too-large.js", + "sourceMapFile": "invalid-mapping-segment-original-line-too-large.js.map", + "sourceMapIsValid": false + }, + { + "name": "invalidMappingSegmentWithOriginalColumnExceeding32Bits", + "description": "Test a source map that has an original column field that exceeds 32 bits", + "baseFile": "invalid-mapping-segment-original-column-too-large.js", + "sourceMapFile": "invalid-mapping-segment-original-column-too-large.js.map", + "sourceMapIsValid": false + }, + { + "name": "invalidMappingSegmentWithNameIndexExceeding32Bits", + "description": "Test a source map that has a name index field that exceeds 32 bits", + "baseFile": "invalid-mapping-segment-name-index-too-large.js", + "sourceMapFile": "invalid-mapping-segment-name-index-too-large.js.map", + "sourceMapIsValid": false + }, + { + "name": "validMappingFieldsWith32BitMaxValues", + "description": "Test a source map that has segment fields with max values representable in 32 bits", + "baseFile": "valid-mapping-boundary-values.js", + "sourceMapFile": "valid-mapping-boundary-values.js.map", + "sourceMapIsValid": true + }, { "name": "basicMapping", "description": "Test a simple source map that has several valid mappings", From 3716d7651482f3e19a2f022bcf13d44650c788c5 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Thu, 28 Mar 2024 13:37:32 -0700 Subject: [PATCH 29/68] Add several more mappings tests * Test when the mappings key does not map to a string * Test a large VLQ that should be valid and decode to within 32-bits --- resources/invalid-mapping-not-a-string-1.js | 1 + .../invalid-mapping-not-a-string-1.js.map | 6 ++++++ resources/invalid-mapping-not-a-string-2.js | 1 + .../invalid-mapping-not-a-string-2.js.map | 6 ++++++ resources/valid-mapping-large-vlq.js | 1 + resources/valid-mapping-large-vlq.js.map | 6 ++++++ source-map-spec-tests.json | 21 +++++++++++++++++++ 7 files changed, 42 insertions(+) create mode 100644 resources/invalid-mapping-not-a-string-1.js create mode 100644 resources/invalid-mapping-not-a-string-1.js.map create mode 100644 resources/invalid-mapping-not-a-string-2.js create mode 100644 resources/invalid-mapping-not-a-string-2.js.map create mode 100644 resources/valid-mapping-large-vlq.js create mode 100644 resources/valid-mapping-large-vlq.js.map diff --git a/resources/invalid-mapping-not-a-string-1.js b/resources/invalid-mapping-not-a-string-1.js new file mode 100644 index 0000000..cb38e2f --- /dev/null +++ b/resources/invalid-mapping-not-a-string-1.js @@ -0,0 +1 @@ +//# sourceMappingURL=invalid-mapping-not-a-string-1.js.map diff --git a/resources/invalid-mapping-not-a-string-1.js.map b/resources/invalid-mapping-not-a-string-1.js.map new file mode 100644 index 0000000..54bf8d9 --- /dev/null +++ b/resources/invalid-mapping-not-a-string-1.js.map @@ -0,0 +1,6 @@ +{ + "version": 3, + "names": [], + "sources": ["invalid-mapping-not-a-string-1.js"], + "mappings": 5 +} diff --git a/resources/invalid-mapping-not-a-string-2.js b/resources/invalid-mapping-not-a-string-2.js new file mode 100644 index 0000000..3d84abd --- /dev/null +++ b/resources/invalid-mapping-not-a-string-2.js @@ -0,0 +1 @@ +//# sourceMappingURL=invalid-mapping-not-a-string-2.js.map diff --git a/resources/invalid-mapping-not-a-string-2.js.map b/resources/invalid-mapping-not-a-string-2.js.map new file mode 100644 index 0000000..77bd62e --- /dev/null +++ b/resources/invalid-mapping-not-a-string-2.js.map @@ -0,0 +1,6 @@ +{ + "version": 3, + "names": [], + "sources": ["invalid-mapping-not-a-string-2.js"], + "mappings": [1, 2, 3, 4] +} diff --git a/resources/valid-mapping-large-vlq.js b/resources/valid-mapping-large-vlq.js new file mode 100644 index 0000000..b0cd897 --- /dev/null +++ b/resources/valid-mapping-large-vlq.js @@ -0,0 +1 @@ +//# sourceMappingURL=valid-mapping-large-vlq.js.map diff --git a/resources/valid-mapping-large-vlq.js.map b/resources/valid-mapping-large-vlq.js.map new file mode 100644 index 0000000..76e1870 --- /dev/null +++ b/resources/valid-mapping-large-vlq.js.map @@ -0,0 +1,6 @@ +{ + "version": 3, + "names": [], + "sources": ["valid-mapping-large-vlq.js"], + "mappings": "igggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggA" +} diff --git a/source-map-spec-tests.json b/source-map-spec-tests.json index 777bb28..60f4eff 100644 --- a/source-map-spec-tests.json +++ b/source-map-spec-tests.json @@ -49,6 +49,20 @@ "sourceMapFile": "invalid-vlq-non-base64-char.js.map", "sourceMapIsValid": false }, + { + "name": "invalidMappingNotAString1", + "description": "Test a source map that has an invalid mapping that is not a string (number)", + "baseFile": "invalid-mapping-not-a-string-1.js", + "sourceMapFile": "invalid-mapping-not-a-string-1.js.map", + "sourceMapIsValid": false + }, + { + "name": "invalidMappingNotAString2", + "description": "Test a source map that has an invalid mapping that is not a string (array)", + "baseFile": "invalid-mapping-not-a-string-2.js", + "sourceMapFile": "invalid-mapping-not-a-string-2.js.map", + "sourceMapIsValid": false + }, { "name": "invalidMappingSegmentBadSeparator", "description": "Test a source map that uses separator characters not recognized in the spec", @@ -147,6 +161,13 @@ "sourceMapFile": "valid-mapping-boundary-values.js.map", "sourceMapIsValid": true }, + { + "name": "validMappingLargeVLQ", + "description": "Test a source map that has a segment field VLQ that is very long but within 32-bits", + "baseFile": "valid-mapping-large-vlq.js", + "sourceMapFile": "valid-mapping-large-vlq.js.map", + "sourceMapIsValid": true + }, { "name": "basicMapping", "description": "Test a simple source map that has several valid mappings", From 528a4c82db857c950d5a77b17ce58d8161b4bd20 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Thu, 28 Mar 2024 15:31:25 -0700 Subject: [PATCH 30/68] Add a test for segments with zero fields Reading the spec strictly, a mapping like ",," is not legal as an empty segment with zero fields is not legal. However, in practice implementations don't parse this very strictly. --- resources/invalid-mapping-segment-with-zero-fields.js | 1 + resources/invalid-mapping-segment-with-zero-fields.js.map | 6 ++++++ source-map-spec-tests.json | 7 +++++++ 3 files changed, 14 insertions(+) create mode 100644 resources/invalid-mapping-segment-with-zero-fields.js create mode 100644 resources/invalid-mapping-segment-with-zero-fields.js.map diff --git a/resources/invalid-mapping-segment-with-zero-fields.js b/resources/invalid-mapping-segment-with-zero-fields.js new file mode 100644 index 0000000..9d5332a --- /dev/null +++ b/resources/invalid-mapping-segment-with-zero-fields.js @@ -0,0 +1 @@ +//# sourceMappingURL=invalid-mapping-segment-column-with-zero-fields.js.map diff --git a/resources/invalid-mapping-segment-with-zero-fields.js.map b/resources/invalid-mapping-segment-with-zero-fields.js.map new file mode 100644 index 0000000..d848cc1 --- /dev/null +++ b/resources/invalid-mapping-segment-with-zero-fields.js.map @@ -0,0 +1,6 @@ +{ + "version": 3, + "names": [], + "sources": ["invalid-mapping-segment-with-zero-fields.js"], + "mappings": ",,,," +} diff --git a/source-map-spec-tests.json b/source-map-spec-tests.json index 60f4eff..796c1b3 100644 --- a/source-map-spec-tests.json +++ b/source-map-spec-tests.json @@ -70,6 +70,13 @@ "sourceMapFile": "invalid-mapping-bad-separator.js.map", "sourceMapIsValid": false }, + { + "name": "invalidMappingSegmentWithZeroFields", + "description": "Test a source map that has the wrong number (zero) of segments fields", + "baseFile": "invalid-mapping-segment-with-zero-fields.js", + "sourceMapFile": "invalid-mapping-segment-with-zero-fields.js.map", + "sourceMapIsValid": false + }, { "name": "invalidMappingSegmentWithTwoFields", "description": "Test a source map that has the wrong number (two) of segments fields", From f42908b10324200c15ca6e35085d416e0b909760 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Thu, 28 Mar 2024 15:35:31 -0700 Subject: [PATCH 31/68] Add a test for a mapping with many empty groups A mapping like ";;;;;;" is legal as groups can be empty --- resources/valid-mapping-empty-groups.js | 1 + resources/valid-mapping-empty-groups.js.map | 6 ++++++ source-map-spec-tests.json | 7 +++++++ 3 files changed, 14 insertions(+) create mode 100644 resources/valid-mapping-empty-groups.js create mode 100644 resources/valid-mapping-empty-groups.js.map diff --git a/resources/valid-mapping-empty-groups.js b/resources/valid-mapping-empty-groups.js new file mode 100644 index 0000000..a2b767b --- /dev/null +++ b/resources/valid-mapping-empty-groups.js @@ -0,0 +1 @@ +//# sourceMappingURL=valid-mapping-empty-groups.js.map diff --git a/resources/valid-mapping-empty-groups.js.map b/resources/valid-mapping-empty-groups.js.map new file mode 100644 index 0000000..8079ce8 --- /dev/null +++ b/resources/valid-mapping-empty-groups.js.map @@ -0,0 +1,6 @@ +{ + "version": 3, + "names": [], + "sources": ["valid-mapping-empty-groups.js"], + "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;" +} diff --git a/source-map-spec-tests.json b/source-map-spec-tests.json index 796c1b3..71dc5e5 100644 --- a/source-map-spec-tests.json +++ b/source-map-spec-tests.json @@ -175,6 +175,13 @@ "sourceMapFile": "valid-mapping-large-vlq.js.map", "sourceMapIsValid": true }, + { + "name": "validMappingEmptyGroups", + "description": "Test a source map with a mapping that has many empty groups", + "baseFile": "valid-mapping-empty-groups.js", + "sourceMapFile": "valid-mapping-empty-groups.js.map", + "sourceMapIsValid": true + }, { "name": "basicMapping", "description": "Test a simple source map that has several valid mappings", From 0f8c662553196bd7e2676da5be543359bf31d84e Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Fri, 29 Mar 2024 15:40:54 -0700 Subject: [PATCH 32/68] Update WebKit harness * Stricter checking of validation failure cases * Check for a failed source map URL with the NetworkManager * Use a timeout to avoid blocking on a source map event --- ...d-harness-for-source-maps-spec-tests.patch | 615 +++++++++++++++++- webkit/source-map-spec.html | 17 +- 2 files changed, 602 insertions(+), 30 deletions(-) diff --git a/webkit/0001-Add-harness-for-source-maps-spec-tests.patch b/webkit/0001-Add-harness-for-source-maps-spec-tests.patch index 00acf97..fbab821 100644 --- a/webkit/0001-Add-harness-for-source-maps-spec-tests.patch +++ b/webkit/0001-Add-harness-for-source-maps-spec-tests.patch @@ -1,4 +1,4 @@ -From 7b5cfb32770099d368aed4b4340dae3074541e91 Mon Sep 17 00:00:00 2001 +From a8069fe61364a3ac4ffd3434b4d9c87650b3a7d5 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Mon, 11 Mar 2024 13:41:31 -0700 Subject: [PATCH] Add harness for source maps spec tests @@ -33,31 +33,103 @@ Explanation of why this fixes the bug (OOPS!). * LayoutTests/inspector/model/source-map-spec-expected.txt: Added. * LayoutTests/inspector/model/source-map-spec.html: Added. --- - .../model/resources/basic-mapping-original.js | 8 +++ - .../model/resources/basic-mapping.js | 2 + - .../model/resources/basic-mapping.js.map | 6 ++ - .../resources/source-map-spec-tests.json | 66 +++++++++++++++++ - .../model/resources/unrecognized-property.js | 1 + - .../resources/unrecognized-property.js.map | 8 +++ - .../model/resources/version-not-a-number.js | 1 + - .../resources/version-not-a-number.js.map | 6 ++ - .../model/resources/version-numeric-string.js | 1 + - .../resources/version-numeric-string.js.map | 6 ++ - .../model/resources/version-too-high.js | 1 + - .../model/resources/version-too-high.js.map | 6 ++ - .../model/resources/version-too-low.js | 1 + - .../model/resources/version-too-low.js.map | 6 ++ - .../model/resources/version-valid.js | 1 + - .../model/resources/version-valid.js.map | 6 ++ - .../model/source-map-spec-expected.txt | 22 ++++++ - .../inspector/model/source-map-spec.html | 70 +++++++++++++++++++ - 18 files changed, 218 insertions(+) + .../model/resources/basic-mapping-original.js | 8 + + .../model/resources/basic-mapping.js | 2 + + .../model/resources/basic-mapping.js.map | 6 + + .../invalid-mapping-bad-separator.js | 2 + + .../invalid-mapping-bad-separator.js.map | 6 + + .../invalid-mapping-not-a-string-1.js | 1 + + .../invalid-mapping-not-a-string-1.js.map | 6 + + .../invalid-mapping-not-a-string-2.js | 1 + + .../invalid-mapping-not-a-string-2.js.map | 6 + + ...nvalid-mapping-segment-column-too-large.js | 1 + + ...id-mapping-segment-column-too-large.js.map | 6 + + ...id-mapping-segment-name-index-too-large.js | 1 + + ...apping-segment-name-index-too-large.js.map | 6 + + ...invalid-mapping-segment-negative-column.js | 1 + + ...lid-mapping-segment-negative-column.js.map | 6 + + ...lid-mapping-segment-negative-name-index.js | 1 + + ...mapping-segment-negative-name-index.js.map | 6 + + ...apping-segment-negative-original-column.js | 1 + + ...ng-segment-negative-original-column.js.map | 6 + + ...-mapping-segment-negative-original-line.js | 1 + + ...ping-segment-negative-original-line.js.map | 6 + + ...d-mapping-segment-negative-source-index.js | 1 + + ...pping-segment-negative-source-index.js.map | 6 + + ...pping-segment-original-column-too-large.js | 1 + + ...g-segment-original-column-too-large.js.map | 6 + + ...mapping-segment-original-line-too-large.js | 1 + + ...ing-segment-original-line-too-large.js.map | 6 + + ...-mapping-segment-source-index-too-large.js | 1 + + ...ping-segment-source-index-too-large.js.map | 6 + + ...valid-mapping-segment-with-three-fields.js | 2 + + ...d-mapping-segment-with-three-fields.js.map | 6 + + ...invalid-mapping-segment-with-two-fields.js | 2 + + ...lid-mapping-segment-with-two-fields.js.map | 6 + + .../resources/invalid-vlq-non-base64-char.js | 1 + + .../invalid-vlq-non-base64-char.js.map | 6 + + .../resources/source-map-spec-tests.json | 199 ++++++++++++++++++ + .../model/resources/unrecognized-property.js | 1 + + .../resources/unrecognized-property.js.map | 8 + + .../valid-mapping-boundary-values.js | 1 + + .../valid-mapping-boundary-values.js.map | 6 + + .../resources/valid-mapping-large-vlq.js | 1 + + .../resources/valid-mapping-large-vlq.js.map | 6 + + .../model/resources/version-not-a-number.js | 1 + + .../resources/version-not-a-number.js.map | 6 + + .../model/resources/version-numeric-string.js | 1 + + .../resources/version-numeric-string.js.map | 6 + + .../model/resources/version-too-high.js | 1 + + .../model/resources/version-too-high.js.map | 6 + + .../model/resources/version-too-low.js | 1 + + .../model/resources/version-too-low.js.map | 6 + + .../model/resources/version-valid.js | 1 + + .../model/resources/version-valid.js.map | 6 + + .../model/source-map-spec-expected.txt | 22 ++ + .../inspector/model/source-map-spec.html | 81 +++++++ + 54 files changed, 491 insertions(+) create mode 100644 LayoutTests/inspector/model/resources/basic-mapping-original.js create mode 100644 LayoutTests/inspector/model/resources/basic-mapping.js create mode 100644 LayoutTests/inspector/model/resources/basic-mapping.js.map + create mode 100644 LayoutTests/inspector/model/resources/invalid-mapping-bad-separator.js + create mode 100644 LayoutTests/inspector/model/resources/invalid-mapping-bad-separator.js.map + create mode 100644 LayoutTests/inspector/model/resources/invalid-mapping-not-a-string-1.js + create mode 100644 LayoutTests/inspector/model/resources/invalid-mapping-not-a-string-1.js.map + create mode 100644 LayoutTests/inspector/model/resources/invalid-mapping-not-a-string-2.js + create mode 100644 LayoutTests/inspector/model/resources/invalid-mapping-not-a-string-2.js.map + create mode 100644 LayoutTests/inspector/model/resources/invalid-mapping-segment-column-too-large.js + create mode 100644 LayoutTests/inspector/model/resources/invalid-mapping-segment-column-too-large.js.map + create mode 100644 LayoutTests/inspector/model/resources/invalid-mapping-segment-name-index-too-large.js + create mode 100644 LayoutTests/inspector/model/resources/invalid-mapping-segment-name-index-too-large.js.map + create mode 100644 LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-column.js + create mode 100644 LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-column.js.map + create mode 100644 LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-name-index.js + create mode 100644 LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-name-index.js.map + create mode 100644 LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-original-column.js + create mode 100644 LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-original-column.js.map + create mode 100644 LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-original-line.js + create mode 100644 LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-original-line.js.map + create mode 100644 LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-source-index.js + create mode 100644 LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-source-index.js.map + create mode 100644 LayoutTests/inspector/model/resources/invalid-mapping-segment-original-column-too-large.js + create mode 100644 LayoutTests/inspector/model/resources/invalid-mapping-segment-original-column-too-large.js.map + create mode 100644 LayoutTests/inspector/model/resources/invalid-mapping-segment-original-line-too-large.js + create mode 100644 LayoutTests/inspector/model/resources/invalid-mapping-segment-original-line-too-large.js.map + create mode 100644 LayoutTests/inspector/model/resources/invalid-mapping-segment-source-index-too-large.js + create mode 100644 LayoutTests/inspector/model/resources/invalid-mapping-segment-source-index-too-large.js.map + create mode 100644 LayoutTests/inspector/model/resources/invalid-mapping-segment-with-three-fields.js + create mode 100644 LayoutTests/inspector/model/resources/invalid-mapping-segment-with-three-fields.js.map + create mode 100644 LayoutTests/inspector/model/resources/invalid-mapping-segment-with-two-fields.js + create mode 100644 LayoutTests/inspector/model/resources/invalid-mapping-segment-with-two-fields.js.map + create mode 100644 LayoutTests/inspector/model/resources/invalid-vlq-non-base64-char.js + create mode 100644 LayoutTests/inspector/model/resources/invalid-vlq-non-base64-char.js.map create mode 100644 LayoutTests/inspector/model/resources/source-map-spec-tests.json create mode 100644 LayoutTests/inspector/model/resources/unrecognized-property.js create mode 100644 LayoutTests/inspector/model/resources/unrecognized-property.js.map + create mode 100644 LayoutTests/inspector/model/resources/valid-mapping-boundary-values.js + create mode 100644 LayoutTests/inspector/model/resources/valid-mapping-boundary-values.js.map + create mode 100644 LayoutTests/inspector/model/resources/valid-mapping-large-vlq.js + create mode 100644 LayoutTests/inspector/model/resources/valid-mapping-large-vlq.js.map create mode 100644 LayoutTests/inspector/model/resources/version-not-a-number.js create mode 100644 LayoutTests/inspector/model/resources/version-not-a-number.js.map create mode 100644 LayoutTests/inspector/model/resources/version-numeric-string.js @@ -105,52 +177,492 @@ index 000000000000..12dc9679a4b1 + "sources": ["basic-mapping-original.js"], + "mappings":"AAAA,SAASA,MACP,OAAO,EACT,CACA,SAASC,MACP,OAAO,EACT,CACAD,MACAC" +} +diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-bad-separator.js b/LayoutTests/inspector/model/resources/invalid-mapping-bad-separator.js +new file mode 100644 +index 000000000000..25338aca30ce +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/invalid-mapping-bad-separator.js +@@ -0,0 +1,2 @@ ++function foo(){return 42}function bar(){return 24}foo();bar(); ++//# sourceMappingURL=invalid-mapping-bad-separator.js.map +diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-bad-separator.js.map b/LayoutTests/inspector/model/resources/invalid-mapping-bad-separator.js.map +new file mode 100644 +index 000000000000..5f4f5b92330a +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/invalid-mapping-bad-separator.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version": 3, ++ "names": ["foo","bar"], ++ "sources": ["basic-mapping-original.js"], ++ "mappings": "AAAA.SAASA:MACP" ++} +diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-not-a-string-1.js b/LayoutTests/inspector/model/resources/invalid-mapping-not-a-string-1.js +new file mode 100644 +index 000000000000..cb38e2fe9d7b +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/invalid-mapping-not-a-string-1.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=invalid-mapping-not-a-string-1.js.map +diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-not-a-string-1.js.map b/LayoutTests/inspector/model/resources/invalid-mapping-not-a-string-1.js.map +new file mode 100644 +index 000000000000..54bf8d953d74 +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/invalid-mapping-not-a-string-1.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version": 3, ++ "names": [], ++ "sources": ["invalid-mapping-not-a-string-1.js"], ++ "mappings": 5 ++} +diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-not-a-string-2.js b/LayoutTests/inspector/model/resources/invalid-mapping-not-a-string-2.js +new file mode 100644 +index 000000000000..3d84abd6c6b4 +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/invalid-mapping-not-a-string-2.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=invalid-mapping-not-a-string-2.js.map +diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-not-a-string-2.js.map b/LayoutTests/inspector/model/resources/invalid-mapping-not-a-string-2.js.map +new file mode 100644 +index 000000000000..77bd62e18452 +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/invalid-mapping-not-a-string-2.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version": 3, ++ "names": [], ++ "sources": ["invalid-mapping-not-a-string-2.js"], ++ "mappings": [1, 2, 3, 4] ++} +diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-segment-column-too-large.js b/LayoutTests/inspector/model/resources/invalid-mapping-segment-column-too-large.js +new file mode 100644 +index 000000000000..55591f874b1b +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/invalid-mapping-segment-column-too-large.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=invalid-mapping-segment-column-too-large.js.map +diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-segment-column-too-large.js.map b/LayoutTests/inspector/model/resources/invalid-mapping-segment-column-too-large.js.map +new file mode 100644 +index 000000000000..dc2c3464d12e +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/invalid-mapping-segment-column-too-large.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version": 3, ++ "names": [], ++ "sources": ["invalid-mapping-segment-column-too-large.js"], ++ "mappings": "ggggggE" ++} +diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-segment-name-index-too-large.js b/LayoutTests/inspector/model/resources/invalid-mapping-segment-name-index-too-large.js +new file mode 100644 +index 000000000000..709e34dbd326 +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/invalid-mapping-segment-name-index-too-large.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=invalid-mapping-segment-name-index-too-large.js.map +diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-segment-name-index-too-large.js.map b/LayoutTests/inspector/model/resources/invalid-mapping-segment-name-index-too-large.js.map +new file mode 100644 +index 000000000000..e27eaf715f2c +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/invalid-mapping-segment-name-index-too-large.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version": 3, ++ "names": [], ++ "sources": ["invalid-mapping-segment-name-index-too-large.js"], ++ "mappings": "AAAAggggggE" ++} +diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-column.js b/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-column.js +new file mode 100644 +index 000000000000..a202152d6fdf +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-column.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=invalid-mapping-segment-negative-column.js.map +diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-column.js.map b/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-column.js.map +new file mode 100644 +index 000000000000..fc78d8888060 +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-column.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version": 3, ++ "names": [], ++ "sources": ["invalid-mapping-segment-negative-column.js"], ++ "mappings": "F" ++} +diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-name-index.js b/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-name-index.js +new file mode 100644 +index 000000000000..3e3f63420467 +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-name-index.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=invalid-mapping-segment-negative-name-index.js.map +diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-name-index.js.map b/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-name-index.js.map +new file mode 100644 +index 000000000000..7b1717fc92ff +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-name-index.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version": 3, ++ "names": [], ++ "sources": ["invalid-mapping-segment-negative-name-index.js"], ++ "mappings": "AAAAF" ++} +diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-original-column.js b/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-original-column.js +new file mode 100644 +index 000000000000..f21d5342b395 +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-original-column.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=invalid-mapping-segment-negative-original-column.js.map +diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-original-column.js.map b/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-original-column.js.map +new file mode 100644 +index 000000000000..0469de0be003 +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-original-column.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version": 3, ++ "names": [], ++ "sources": ["invalid-mapping-segment-negative-original-column.js"], ++ "mappings": "AAAF" ++} +diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-original-line.js b/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-original-line.js +new file mode 100644 +index 000000000000..b37309601ce0 +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-original-line.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=invalid-mapping-segment-negative-original-line.js.map +diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-original-line.js.map b/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-original-line.js.map +new file mode 100644 +index 000000000000..1f33706bc1f1 +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-original-line.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version": 3, ++ "names": [], ++ "sources": ["invalid-mapping-segment-negative-original-line.js"], ++ "mappings": "AAFA" ++} +diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-source-index.js b/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-source-index.js +new file mode 100644 +index 000000000000..6e05849b6a03 +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-source-index.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=invalid-mapping-segment-negative-source-index.js.map +diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-source-index.js.map b/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-source-index.js.map +new file mode 100644 +index 000000000000..5453ad0b3058 +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-source-index.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version": 3, ++ "names": [], ++ "sources": ["invalid-mapping-segment-negative-source-index.js"], ++ "mappings": "AFAA" ++} +diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-segment-original-column-too-large.js b/LayoutTests/inspector/model/resources/invalid-mapping-segment-original-column-too-large.js +new file mode 100644 +index 000000000000..0936ed7ea8fd +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/invalid-mapping-segment-original-column-too-large.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=invalid-mapping-segment-original-column-too-large.js.map +diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-segment-original-column-too-large.js.map b/LayoutTests/inspector/model/resources/invalid-mapping-segment-original-column-too-large.js.map +new file mode 100644 +index 000000000000..218fc2021913 +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/invalid-mapping-segment-original-column-too-large.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version": 3, ++ "names": [], ++ "sources": ["invalid-mapping-segment-original-column-too-large.js"], ++ "mappings": "AAAggggggE" ++} +diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-segment-original-line-too-large.js b/LayoutTests/inspector/model/resources/invalid-mapping-segment-original-line-too-large.js +new file mode 100644 +index 000000000000..9b3aa5a361ae +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/invalid-mapping-segment-original-line-too-large.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=invalid-mapping-segment-original-line-too-large.js.map +diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-segment-original-line-too-large.js.map b/LayoutTests/inspector/model/resources/invalid-mapping-segment-original-line-too-large.js.map +new file mode 100644 +index 000000000000..d96075dc0b85 +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/invalid-mapping-segment-original-line-too-large.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version": 3, ++ "names": [], ++ "sources": ["invalid-mapping-segment-original-line-too-large.js"], ++ "mappings": "AAggggggEA" ++} +diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-segment-source-index-too-large.js b/LayoutTests/inspector/model/resources/invalid-mapping-segment-source-index-too-large.js +new file mode 100644 +index 000000000000..3f4943e1272d +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/invalid-mapping-segment-source-index-too-large.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=invalid-mapping-segment-source-index-too-large.js.map +diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-segment-source-index-too-large.js.map b/LayoutTests/inspector/model/resources/invalid-mapping-segment-source-index-too-large.js.map +new file mode 100644 +index 000000000000..c136e3637301 +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/invalid-mapping-segment-source-index-too-large.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version": 3, ++ "names": [], ++ "sources": ["invalid-mapping-segment-source-index-too-large.js"], ++ "mappings": "AggggggEAA" ++} +diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-segment-with-three-fields.js b/LayoutTests/inspector/model/resources/invalid-mapping-segment-with-three-fields.js +new file mode 100644 +index 000000000000..4b868fac9c5e +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/invalid-mapping-segment-with-three-fields.js +@@ -0,0 +1,2 @@ ++function foo(){return 42}function bar(){return 24}foo();bar(); ++//# sourceMappingURL=invalid-mapping-three-fields.js.map +diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-segment-with-three-fields.js.map b/LayoutTests/inspector/model/resources/invalid-mapping-segment-with-three-fields.js.map +new file mode 100644 +index 000000000000..c2af1165ad8f +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/invalid-mapping-segment-with-three-fields.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version": 3, ++ "names": ["foo","bar"], ++ "sources": ["basic-mapping-original.js"], ++ "mappings": "AAA" ++} +diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-segment-with-two-fields.js b/LayoutTests/inspector/model/resources/invalid-mapping-segment-with-two-fields.js +new file mode 100644 +index 000000000000..96045a7a11dd +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/invalid-mapping-segment-with-two-fields.js +@@ -0,0 +1,2 @@ ++function foo(){return 42}function bar(){return 24}foo();bar(); ++//# sourceMappingURL=invalid-mapping-two-fields.js.map +diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-segment-with-two-fields.js.map b/LayoutTests/inspector/model/resources/invalid-mapping-segment-with-two-fields.js.map +new file mode 100644 +index 000000000000..73cf00fa1c96 +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/invalid-mapping-segment-with-two-fields.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version": 3, ++ "names": ["foo","bar"], ++ "sources": ["basic-mapping-original.js"], ++ "mappings": "AA" ++} +diff --git a/LayoutTests/inspector/model/resources/invalid-vlq-non-base64-char.js b/LayoutTests/inspector/model/resources/invalid-vlq-non-base64-char.js +new file mode 100644 +index 000000000000..d1b20b41a29f +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/invalid-vlq-non-base64-char.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=invalid-vlq-non-base64-char.js.map +diff --git a/LayoutTests/inspector/model/resources/invalid-vlq-non-base64-char.js.map b/LayoutTests/inspector/model/resources/invalid-vlq-non-base64-char.js.map +new file mode 100644 +index 000000000000..4fa1ac576885 +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/invalid-vlq-non-base64-char.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version" : 3, ++ "sources": [], ++ "names": [], ++ "mappings": "A$%?!" ++} diff --git a/LayoutTests/inspector/model/resources/source-map-spec-tests.json b/LayoutTests/inspector/model/resources/source-map-spec-tests.json new file mode 100644 -index 000000000000..a9f1c149f102 +index 000000000000..60f4effc775a --- /dev/null +++ b/LayoutTests/inspector/model/resources/source-map-spec-tests.json -@@ -0,0 +1,66 @@ +@@ -0,0 +1,199 @@ +{ + "tests": [ + { + "name": "versionValid", ++ "description": "Test a simple source map with a valid version number", + "baseFile": "version-valid.js", + "sourceMapFile": "version-valid.js.map", + "sourceMapIsValid": true + }, + { + "name": "versionNotANumber", ++ "description": "Test a source map with a version field that is not a number", + "baseFile": "version-not-a-number.js", + "sourceMapFile": "version-not-a-number.js.map", + "sourceMapIsValid": false + }, + { + "name": "versionNumericString", ++ "description": "Test a source map with a version field that is a number as a string", + "baseFile": "version-numeric-string.js", + "sourceMapFile": "version-numeric-string.js.map", + "sourceMapIsValid": false + }, + { + "name": "versionTooHigh", ++ "description": "Test a source map with an integer version field that is too high", + "baseFile": "version-too-high.js", + "sourceMapFile": "version-too-high.js.map", + "sourceMapIsValid": false + }, + { + "name": "versionTooLow", ++ "description": "Test a source map with an integer version field that is too low", + "baseFile": "version-too-low.js", + "sourceMapFile": "version-too-low.js.map", + "sourceMapIsValid": false + }, + { + "name": "unrecognizedProperty", ++ "description": "Test a source map that has an extra field not explicitly encoded in the spec", + "baseFile": "unrecognized-property.js", + "sourceMapFile": "unrecognized-property.js.map", + "sourceMapIsValid": true + }, + { ++ "name": "invalidVLQDueToNonBase64Character", ++ "description": "Test a source map that has a mapping with an invalid non-base64 character", ++ "baseFile": "invalid-vlq-non-base64-char.js", ++ "sourceMapFile": "invalid-vlq-non-base64-char.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "invalidMappingNotAString1", ++ "description": "Test a source map that has an invalid mapping that is not a string (number)", ++ "baseFile": "invalid-mapping-not-a-string-1.js", ++ "sourceMapFile": "invalid-mapping-not-a-string-1.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "invalidMappingNotAString2", ++ "description": "Test a source map that has an invalid mapping that is not a string (array)", ++ "baseFile": "invalid-mapping-not-a-string-2.js", ++ "sourceMapFile": "invalid-mapping-not-a-string-2.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "invalidMappingSegmentBadSeparator", ++ "description": "Test a source map that uses separator characters not recognized in the spec", ++ "baseFile": "invalid-mapping-bad-separator.js", ++ "sourceMapFile": "invalid-mapping-bad-separator.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "invalidMappingSegmentWithTwoFields", ++ "description": "Test a source map that has the wrong number (two) of segments fields", ++ "baseFile": "invalid-mapping-segment-with-two-fields.js", ++ "sourceMapFile": "invalid-mapping-segment-with-two-fields.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "invalidMappingSegmentWithThreeFields", ++ "description": "Test a source map that has the wrong number (three) of segments fields", ++ "baseFile": "invalid-mapping-segment-with-three-fields.js", ++ "sourceMapFile": "invalid-mapping-segment-with-three-fields.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "invalidMappingSegmentWithNegativeColumn", ++ "description": "Test a source map that has an invalid negative non-relative column field", ++ "baseFile": "invalid-mapping-segment-negative-column.js", ++ "sourceMapFile": "invalid-mapping-segment-negative-column.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "invalidMappingSegmentWithNegativeSourceIndex", ++ "description": "Test a source map that has an invalid negative non-relative source index field", ++ "baseFile": "invalid-mapping-segment-negative-source-index.js", ++ "sourceMapFile": "invalid-mapping-segment-negative-source-index.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "invalidMappingSegmentWithNegativeOriginalLine", ++ "description": "Test a source map that has an invalid negative non-relative original line field", ++ "baseFile": "invalid-mapping-segment-negative-original-line.js", ++ "sourceMapFile": "invalid-mapping-segment-negative-original-line.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "invalidMappingSegmentWithNegativeOriginalColumn", ++ "description": "Test a source map that has an invalid negative non-relative original column field", ++ "baseFile": "invalid-mapping-segment-negative-original-column.js", ++ "sourceMapFile": "invalid-mapping-segment-negative-original-column.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "invalidMappingSegmentWithNegativeNameIndex", ++ "description": "Test a source map that has an invalid negative non-relative name index field", ++ "baseFile": "invalid-mapping-segment-negative-name-index.js", ++ "sourceMapFile": "invalid-mapping-segment-negative-name-index.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "invalidMappingSegmentWithColumnExceeding32Bits", ++ "description": "Test a source map that has a column field that exceeds 32 bits", ++ "baseFile": "invalid-mapping-segment-column-too-large.js", ++ "sourceMapFile": "invalid-mapping-segment-column-too-large.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "invalidMappingSegmentWithSourceIndexExceeding32Bits", ++ "description": "Test a source map that has a source index field that exceeds 32 bits", ++ "baseFile": "invalid-mapping-segment-source-index-too-large.js", ++ "sourceMapFile": "invalid-mapping-segment-source-index-too-large.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "invalidMappingSegmentWithOriginalLineExceeding32Bits", ++ "description": "Test a source map that has a original line field that exceeds 32 bits", ++ "baseFile": "invalid-mapping-segment-original-line-too-large.js", ++ "sourceMapFile": "invalid-mapping-segment-original-line-too-large.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "invalidMappingSegmentWithOriginalColumnExceeding32Bits", ++ "description": "Test a source map that has an original column field that exceeds 32 bits", ++ "baseFile": "invalid-mapping-segment-original-column-too-large.js", ++ "sourceMapFile": "invalid-mapping-segment-original-column-too-large.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "invalidMappingSegmentWithNameIndexExceeding32Bits", ++ "description": "Test a source map that has a name index field that exceeds 32 bits", ++ "baseFile": "invalid-mapping-segment-name-index-too-large.js", ++ "sourceMapFile": "invalid-mapping-segment-name-index-too-large.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "validMappingFieldsWith32BitMaxValues", ++ "description": "Test a source map that has segment fields with max values representable in 32 bits", ++ "baseFile": "valid-mapping-boundary-values.js", ++ "sourceMapFile": "valid-mapping-boundary-values.js.map", ++ "sourceMapIsValid": true ++ }, ++ { ++ "name": "validMappingLargeVLQ", ++ "description": "Test a source map that has a segment field VLQ that is very long but within 32-bits", ++ "baseFile": "valid-mapping-large-vlq.js", ++ "sourceMapFile": "valid-mapping-large-vlq.js.map", ++ "sourceMapIsValid": true ++ }, ++ { + "name": "basicMapping", ++ "description": "Test a simple source map that has several valid mappings", + "baseFile": "basic-mapping.js", + "sourceMapFile": "basic-mapping.js.map", + "sourceMapIsValid": true, @@ -198,6 +710,44 @@ index 000000000000..40bee558a4ff + "foobar": 42, + "unusedProperty": [1, 2, 3, 4] +} +diff --git a/LayoutTests/inspector/model/resources/valid-mapping-boundary-values.js b/LayoutTests/inspector/model/resources/valid-mapping-boundary-values.js +new file mode 100644 +index 000000000000..3c49709e05ac +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/valid-mapping-boundary-values.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=valid-mapping-boundary-values.js.map +diff --git a/LayoutTests/inspector/model/resources/valid-mapping-boundary-values.js.map b/LayoutTests/inspector/model/resources/valid-mapping-boundary-values.js.map +new file mode 100644 +index 000000000000..d80126ba9efe +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/valid-mapping-boundary-values.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version": 3, ++ "names": ["foo"], ++ "sources": ["valid-mapping-boundary-values.js"], ++ "mappings": "+/////DA+/////D+/////DA" ++} +diff --git a/LayoutTests/inspector/model/resources/valid-mapping-large-vlq.js b/LayoutTests/inspector/model/resources/valid-mapping-large-vlq.js +new file mode 100644 +index 000000000000..b0cd8978132a +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/valid-mapping-large-vlq.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=valid-mapping-large-vlq.js.map +diff --git a/LayoutTests/inspector/model/resources/valid-mapping-large-vlq.js.map b/LayoutTests/inspector/model/resources/valid-mapping-large-vlq.js.map +new file mode 100644 +index 000000000000..76e18704c4b1 +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/valid-mapping-large-vlq.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version": 3, ++ "names": [], ++ "sources": ["valid-mapping-large-vlq.js"], ++ "mappings": "igggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggA" ++} diff --git a/LayoutTests/inspector/model/resources/version-not-a-number.js b/LayoutTests/inspector/model/resources/version-not-a-number.js new file mode 100644 index 000000000000..ae2342e2ffe5 @@ -323,10 +873,10 @@ index 000000000000..c74ab5bcfb32 + diff --git a/LayoutTests/inspector/model/source-map-spec.html b/LayoutTests/inspector/model/source-map-spec.html new file mode 100644 -index 000000000000..9763c9294ef5 +index 000000000000..82a056d8bc80 --- /dev/null +++ b/LayoutTests/inspector/model/source-map-spec.html -@@ -0,0 +1,70 @@ +@@ -0,0 +1,81 @@ + + + @@ -356,6 +906,13 @@ index 000000000000..9763c9294ef5 + InspectorTest.expectEqual(location.displaySourceCode.displayName, action.originalSource); + } + ++ function withTimeout(promise, seconds) ++ { ++ return Promise.race([promise, new Promise((resolve, reject) => { ++ setTimeout(resolve, seconds); ++ })]); ++ } ++ + let suite = InspectorTest.createAsyncSuite("SourceMapSpec"); + + suite.addTestCase({ @@ -367,17 +924,21 @@ index 000000000000..9763c9294ef5 + const testDescriptions = event.data.json; + + for (const testCase of testDescriptions.tests) { ++ console.log(testCase.name); + InspectorTest.evaluateInPage(`triggerScriptResource('${testCase.baseFile}')`); + let resourceEvent = await WI.Frame.awaitEvent(WI.Frame.Event.ResourceWasAdded); + let resource = resourceEvent.data.resource; -+ let sourceMapEvent = await resource.awaitEvent(WI.SourceCode.Event.SourceMapAdded); ++ let sourceMapEvent = await withTimeout(resource.awaitEvent(WI.SourceCode.Event.SourceMapAdded), 50); + + if (testCase.sourceMapIsValid) { + InspectorTest.expectEqual(resource.sourceMaps.length, 1, "Resource should have loaded 1 SourceMap."); + InspectorTest.expectThat(resource.sourceMaps[0] instanceof WI.SourceMap, "SourceMap should be a WI.SourceMap instance."); + const loadedSourceMap = resource.sourceMaps[0]; -+ } else -+ InspectorTest.expectLessThanOrEqual(resource.sourceMaps.length, 1, "Resource may or may not load a SourceMap."); ++ } else { ++ const hasFailedSourceMap = WI.networkManager.isSourceMapURL(absoluteURL(testCase.sourceMapFile, resource.displayURL)); ++ InspectorTest.expectThat(hasFailedSourceMap, "Expected that there is an associated failed source map URL"); ++ InspectorTest.expectEqual(resource.sourceMaps.length, 0, "Expected no source map resource loaded"); ++ } + + if (testCase.testActions) { + for (const action of testCase.testActions) { diff --git a/webkit/source-map-spec.html b/webkit/source-map-spec.html index 9763c92..82a056d 100644 --- a/webkit/source-map-spec.html +++ b/webkit/source-map-spec.html @@ -27,6 +27,13 @@ InspectorTest.expectEqual(location.displaySourceCode.displayName, action.originalSource); } + function withTimeout(promise, seconds) + { + return Promise.race([promise, new Promise((resolve, reject) => { + setTimeout(resolve, seconds); + })]); + } + let suite = InspectorTest.createAsyncSuite("SourceMapSpec"); suite.addTestCase({ @@ -38,17 +45,21 @@ const testDescriptions = event.data.json; for (const testCase of testDescriptions.tests) { + console.log(testCase.name); InspectorTest.evaluateInPage(`triggerScriptResource('${testCase.baseFile}')`); let resourceEvent = await WI.Frame.awaitEvent(WI.Frame.Event.ResourceWasAdded); let resource = resourceEvent.data.resource; - let sourceMapEvent = await resource.awaitEvent(WI.SourceCode.Event.SourceMapAdded); + let sourceMapEvent = await withTimeout(resource.awaitEvent(WI.SourceCode.Event.SourceMapAdded), 50); if (testCase.sourceMapIsValid) { InspectorTest.expectEqual(resource.sourceMaps.length, 1, "Resource should have loaded 1 SourceMap."); InspectorTest.expectThat(resource.sourceMaps[0] instanceof WI.SourceMap, "SourceMap should be a WI.SourceMap instance."); const loadedSourceMap = resource.sourceMaps[0]; - } else - InspectorTest.expectLessThanOrEqual(resource.sourceMaps.length, 1, "Resource may or may not load a SourceMap."); + } else { + const hasFailedSourceMap = WI.networkManager.isSourceMapURL(absoluteURL(testCase.sourceMapFile, resource.displayURL)); + InspectorTest.expectThat(hasFailedSourceMap, "Expected that there is an associated failed source map URL"); + InspectorTest.expectEqual(resource.sourceMaps.length, 0, "Expected no source map resource loaded"); + } if (testCase.testActions) { for (const action of testCase.testActions) { From b65116637e03ebca9cc78968b79c1f16b5397b97 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Fri, 29 Mar 2024 16:51:36 -0700 Subject: [PATCH 33/68] Add all the mappings for basic-mappings.js.map Previously the test only checked two of the mappings. This commit adds the remaining hand-decoded mapping test actions. --- source-map-spec-tests.json | 94 +++++++++++++++++++++++++++++++++++++- 1 file changed, 92 insertions(+), 2 deletions(-) diff --git a/source-map-spec-tests.json b/source-map-spec-tests.json index 71dc5e5..beaa542 100644 --- a/source-map-spec-tests.json +++ b/source-map-spec-tests.json @@ -191,20 +191,110 @@ "testActions": [ { "actionType": "checkMapping", + "generatedLine": 0, + "generatedColumn": 0, "originalSource": "basic-mapping-original.js", "originalLine": 0, - "originalColumn": 9, + "originalColumn": 0, + "mappedName": null + }, + { + "actionType": "checkMapping", "generatedLine": 0, "generatedColumn": 9, + "originalSource": "basic-mapping-original.js", + "originalLine": 0, + "originalColumn": 9, "mappedName": "foo" }, { "actionType": "checkMapping", "originalSource": "basic-mapping-original.js", - "originalLine": 3, + "generatedLine": 0, + "generatedColumn": 15, + "originalLine": 1, + "originalColumn": 2, + "mappedName": null + }, + { + "actionType": "checkMapping", + "originalSource": "basic-mapping-original.js", + "generatedLine": 0, + "generatedColumn": 22, + "originalLine": 1, "originalColumn": 9, + "mappedName": null + }, + { + "actionType": "checkMapping", + "originalSource": "basic-mapping-original.js", + "generatedLine": 0, + "generatedColumn": 24, + "originalLine": 2, + "originalColumn": 0, + "mappedName": null + }, + { + "actionType": "checkMapping", + "originalSource": "basic-mapping-original.js", + "generatedLine": 0, + "generatedColumn": 25, + "originalLine": 3, + "originalColumn": 0, + "mappedName": null + }, + { + "actionType": "checkMapping", "generatedLine": 0, "generatedColumn": 34, + "originalSource": "basic-mapping-original.js", + "originalLine": 3, + "originalColumn": 9, + "mappedName": "bar" + }, + { + "actionType": "checkMapping", + "originalSource": "basic-mapping-original.js", + "generatedLine": 0, + "generatedColumn": 40, + "originalLine": 4, + "originalColumn": 2, + "mappedName": null + }, + { + "actionType": "checkMapping", + "originalSource": "basic-mapping-original.js", + "generatedLine": 0, + "generatedColumn": 47, + "originalLine": 4, + "originalColumn": 9, + "mappedName": null + }, + { + "actionType": "checkMapping", + "originalSource": "basic-mapping-original.js", + "generatedLine": 0, + "generatedColumn": 49, + "originalLine": 5, + "originalColumn": 0, + "mappedName": null + }, + { + "actionType": "checkMapping", + "originalSource": "basic-mapping-original.js", + "generatedLine": 0, + "generatedColumn": 50, + "originalLine": 6, + "originalColumn": 0, + "mappedName": "foo" + }, + { + "actionType": "checkMapping", + "originalSource": "basic-mapping-original.js", + "generatedLine": 0, + "generatedColumn": 56, + "originalLine": 7, + "originalColumn": 0, "mappedName": "bar" } ] From 8402fee37be058487479560fad5edf41980fed17 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Wed, 3 Apr 2024 18:19:50 -0700 Subject: [PATCH 34/68] Add tests for index out of bounds --- ...lid-mapping-segment-name-index-out-of-bounds.js | 1 + ...mapping-segment-name-index-out-of-bounds.js.map | 6 ++++++ ...d-mapping-segment-source-index-out-of-bounds.js | 1 + ...pping-segment-source-index-out-of-bounds.js.map | 6 ++++++ source-map-spec-tests.json | 14 ++++++++++++++ 5 files changed, 28 insertions(+) create mode 100644 resources/invalid-mapping-segment-name-index-out-of-bounds.js create mode 100644 resources/invalid-mapping-segment-name-index-out-of-bounds.js.map create mode 100644 resources/invalid-mapping-segment-source-index-out-of-bounds.js create mode 100644 resources/invalid-mapping-segment-source-index-out-of-bounds.js.map diff --git a/resources/invalid-mapping-segment-name-index-out-of-bounds.js b/resources/invalid-mapping-segment-name-index-out-of-bounds.js new file mode 100644 index 0000000..2a6b434 --- /dev/null +++ b/resources/invalid-mapping-segment-name-index-out-of-bounds.js @@ -0,0 +1 @@ +//# sourceMappingURL=invalid-mapping-segment-name-index-out-of-bounds.js.map diff --git a/resources/invalid-mapping-segment-name-index-out-of-bounds.js.map b/resources/invalid-mapping-segment-name-index-out-of-bounds.js.map new file mode 100644 index 0000000..fb9d64c --- /dev/null +++ b/resources/invalid-mapping-segment-name-index-out-of-bounds.js.map @@ -0,0 +1,6 @@ +{ + "version": 3, + "names": ["foo"], + "sources": ["invalid-mapping-segment-name-index-out-of-bounds.js"], + "mappings": "AAAAC" +} diff --git a/resources/invalid-mapping-segment-source-index-out-of-bounds.js b/resources/invalid-mapping-segment-source-index-out-of-bounds.js new file mode 100644 index 0000000..2e5fbca --- /dev/null +++ b/resources/invalid-mapping-segment-source-index-out-of-bounds.js @@ -0,0 +1 @@ +//# sourceMappingURL=invalid-mapping-segment-source-index-out-of-bounds.js.map diff --git a/resources/invalid-mapping-segment-source-index-out-of-bounds.js.map b/resources/invalid-mapping-segment-source-index-out-of-bounds.js.map new file mode 100644 index 0000000..0e68bd5 --- /dev/null +++ b/resources/invalid-mapping-segment-source-index-out-of-bounds.js.map @@ -0,0 +1,6 @@ +{ + "version": 3, + "names": [], + "sources": ["invalid-mapping-segment-source-index-out-of-bounds.js"], + "mappings": "ACAA" +} diff --git a/source-map-spec-tests.json b/source-map-spec-tests.json index beaa542..6ecb43b 100644 --- a/source-map-spec-tests.json +++ b/source-map-spec-tests.json @@ -91,6 +91,20 @@ "sourceMapFile": "invalid-mapping-segment-with-three-fields.js.map", "sourceMapIsValid": false }, + { + "name": "invalidMappingSegmentWithSourceIndexOutOfBounds", + "description": "Test a source map that has a source index field that is out of bounds of the sources field", + "baseFile": "invalid-mapping-segment-source-index-out-of-bounds.js", + "sourceMapFile": "invalid-mapping-segment-source-index-out-of-bounds.js.map", + "sourceMapIsValid": false + }, + { + "name": "invalidMappingSegmentWithNameIndexOutOfBounds", + "description": "Test a source map that has a name index field that is out of bounds of the names field", + "baseFile": "invalid-mapping-segment-name-index-out-of-bounds.js", + "sourceMapFile": "invalid-mapping-segment-name-index-out-of-bounds.js.map", + "sourceMapIsValid": false + }, { "name": "invalidMappingSegmentWithNegativeColumn", "description": "Test a source map that has an invalid negative non-relative column field", From 5e31fba4665a07753ff544a1e06796d593945374 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Wed, 3 Apr 2024 18:27:18 -0700 Subject: [PATCH 35/68] Add a test using null as an original source --- resources/valid-mapping-null-sources.js | 2 ++ resources/valid-mapping-null-sources.js.map | 6 +++++ source-map-spec-tests.json | 27 +++++++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 resources/valid-mapping-null-sources.js create mode 100644 resources/valid-mapping-null-sources.js.map diff --git a/resources/valid-mapping-null-sources.js b/resources/valid-mapping-null-sources.js new file mode 100644 index 0000000..ee2acf0 --- /dev/null +++ b/resources/valid-mapping-null-sources.js @@ -0,0 +1,2 @@ +function foo(){return 42}function bar(){return 24}foo();bar(); +//# sourceMappingURL=valid-mapping-null-sources.js.map diff --git a/resources/valid-mapping-null-sources.js.map b/resources/valid-mapping-null-sources.js.map new file mode 100644 index 0000000..199cda9 --- /dev/null +++ b/resources/valid-mapping-null-sources.js.map @@ -0,0 +1,6 @@ +{ + "version":3, + "names": ["foo"], + "sources": [null], + "mappings":"AAAA,SAASA" +} diff --git a/source-map-spec-tests.json b/source-map-spec-tests.json index 6ecb43b..b2fe677 100644 --- a/source-map-spec-tests.json +++ b/source-map-spec-tests.json @@ -312,6 +312,33 @@ "mappedName": "bar" } ] + }, + { + "name": "validMappingNullSources", + "description": "Test a source map that has null sources", + "baseFile": "valid-mapping-null-sources.js", + "sourceMapFile": "valid-mapping-null-sources.js.map", + "sourceMapIsValid": true, + "testActions": [ + { + "actionType": "checkMapping", + "generatedLine": 0, + "generatedColumn": 0, + "originalSource": null, + "originalLine": 0, + "originalColumn": 0, + "mappedName": null + }, + { + "actionType": "checkMapping", + "generatedLine": 0, + "generatedColumn": 9, + "originalSource": null, + "originalLine": 0, + "originalColumn": 9, + "mappedName": "foo" + } + ] } ] } From 63eedab2a8b7f85637781388aa596e624d856534 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Thu, 4 Apr 2024 16:53:50 -0700 Subject: [PATCH 36/68] Add tests for invalid names/sources list --- resources/names-not-a-list-1.js | 1 + resources/names-not-a-list-1.js.map | 6 ++++++ resources/names-not-a-list-2.js | 1 + resources/names-not-a-list-2.js.map | 6 ++++++ resources/sources-not-a-list-1.js | 1 + resources/sources-not-a-list-1.js.map | 6 ++++++ resources/sources-not-a-list-2.js | 1 + resources/sources-not-a-list-2.js.map | 6 ++++++ source-map-spec-tests.json | 28 +++++++++++++++++++++++++++ 9 files changed, 56 insertions(+) create mode 100644 resources/names-not-a-list-1.js create mode 100644 resources/names-not-a-list-1.js.map create mode 100644 resources/names-not-a-list-2.js create mode 100644 resources/names-not-a-list-2.js.map create mode 100644 resources/sources-not-a-list-1.js create mode 100644 resources/sources-not-a-list-1.js.map create mode 100644 resources/sources-not-a-list-2.js create mode 100644 resources/sources-not-a-list-2.js.map diff --git a/resources/names-not-a-list-1.js b/resources/names-not-a-list-1.js new file mode 100644 index 0000000..dc65f19 --- /dev/null +++ b/resources/names-not-a-list-1.js @@ -0,0 +1 @@ +//# sourceMappingURL=names-not-a-list-1.js.map diff --git a/resources/names-not-a-list-1.js.map b/resources/names-not-a-list-1.js.map new file mode 100644 index 0000000..843f7cc --- /dev/null +++ b/resources/names-not-a-list-1.js.map @@ -0,0 +1,6 @@ +{ + "version" : "3", + "sources": ["source.js"], + "names": "not a list", + "mappings": "AAAAA" +} diff --git a/resources/names-not-a-list-2.js b/resources/names-not-a-list-2.js new file mode 100644 index 0000000..d7251f7 --- /dev/null +++ b/resources/names-not-a-list-2.js @@ -0,0 +1 @@ +//# sourceMappingURL=names-not-a-list-2.js.map diff --git a/resources/names-not-a-list-2.js.map b/resources/names-not-a-list-2.js.map new file mode 100644 index 0000000..cd7a42a --- /dev/null +++ b/resources/names-not-a-list-2.js.map @@ -0,0 +1,6 @@ +{ + "version" : "3", + "sources": ["source.js"], + "names": { "foo": 3 }, + "mappings": "AAAAA" +} diff --git a/resources/sources-not-a-list-1.js b/resources/sources-not-a-list-1.js new file mode 100644 index 0000000..7e33b7e --- /dev/null +++ b/resources/sources-not-a-list-1.js @@ -0,0 +1 @@ +//# sourceMappingURL=sources-not-a-list-1.js.map diff --git a/resources/sources-not-a-list-1.js.map b/resources/sources-not-a-list-1.js.map new file mode 100644 index 0000000..b2e2478 --- /dev/null +++ b/resources/sources-not-a-list-1.js.map @@ -0,0 +1,6 @@ +{ + "version" : "3", + "sources": "not a list", + "names": ["foo"], + "mappings": "AAAAA" +} diff --git a/resources/sources-not-a-list-2.js b/resources/sources-not-a-list-2.js new file mode 100644 index 0000000..4021f76 --- /dev/null +++ b/resources/sources-not-a-list-2.js @@ -0,0 +1 @@ +//# sourceMappingURL=sources-not-a-list-2.js.map diff --git a/resources/sources-not-a-list-2.js.map b/resources/sources-not-a-list-2.js.map new file mode 100644 index 0000000..6a6a863 --- /dev/null +++ b/resources/sources-not-a-list-2.js.map @@ -0,0 +1,6 @@ +{ + "version" : "3", + "sources": { "source.js": 3 }, + "names": ["foo"], + "mappings": "AAAAA" +} diff --git a/source-map-spec-tests.json b/source-map-spec-tests.json index b2fe677..800b750 100644 --- a/source-map-spec-tests.json +++ b/source-map-spec-tests.json @@ -35,6 +35,34 @@ "sourceMapFile": "version-too-low.js.map", "sourceMapIsValid": false }, + { + "name": "sourcesNotAList1", + "description": "Test a source map with a sources field that is not a valid list (string)", + "baseFile": "sources-not-a-list-1.js", + "sourceMapFile": "sources-not-a-list-1.js.map", + "sourceMapIsValid": false + }, + { + "name": "sourcesNotAList2", + "description": "Test a source map with a sources field that is not a valid list (object)", + "baseFile": "sources-not-a-list-2.js", + "sourceMapFile": "sources-not-a-list-2.js.map", + "sourceMapIsValid": false + }, + { + "name": "namesNotAList1", + "description": "Test a source map with a names field that is not a valid list (string)", + "baseFile": "names-not-a-list-1.js", + "sourceMapFile": "names-not-a-list-1.js.map", + "sourceMapIsValid": false + }, + { + "name": "namesNotAList2", + "description": "Test a source map with a names field that is not a valid list (object)", + "baseFile": "names-not-a-list-2.js", + "sourceMapFile": "names-not-a-list-2.js.map", + "sourceMapIsValid": false + }, { "name": "unrecognizedProperty", "description": "Test a source map that has an extra field not explicitly encoded in the spec", From 912edf2f596f90b0c24ea92b081db7be4d7b6246 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Thu, 4 Apr 2024 17:13:20 -0700 Subject: [PATCH 37/68] Fix sources/file fields in some tests These fields weren't being used consistently in the right way in the test cases, though it didn't matter for what they were testing. --- resources/invalid-mapping-not-a-string-1.js.map | 3 ++- resources/invalid-mapping-not-a-string-2.js.map | 3 ++- resources/invalid-mapping-segment-column-too-large.js.map | 3 ++- .../invalid-mapping-segment-name-index-out-of-bounds.js.map | 3 ++- resources/invalid-mapping-segment-name-index-too-large.js.map | 3 ++- resources/invalid-mapping-segment-negative-column.js.map | 3 ++- resources/invalid-mapping-segment-negative-name-index.js.map | 3 ++- .../invalid-mapping-segment-negative-original-column.js.map | 3 ++- .../invalid-mapping-segment-negative-original-line.js.map | 3 ++- resources/invalid-mapping-segment-negative-source-index.js.map | 3 ++- .../invalid-mapping-segment-original-column-too-large.js.map | 3 ++- .../invalid-mapping-segment-original-line-too-large.js.map | 3 ++- .../invalid-mapping-segment-source-index-out-of-bounds.js.map | 3 ++- .../invalid-mapping-segment-source-index-too-large.js.map | 3 ++- resources/invalid-mapping-segment-with-zero-fields.js.map | 3 ++- resources/valid-mapping-boundary-values.js.map | 3 ++- resources/valid-mapping-empty-groups.js.map | 3 ++- 17 files changed, 34 insertions(+), 17 deletions(-) diff --git a/resources/invalid-mapping-not-a-string-1.js.map b/resources/invalid-mapping-not-a-string-1.js.map index 54bf8d9..5bf3e2a 100644 --- a/resources/invalid-mapping-not-a-string-1.js.map +++ b/resources/invalid-mapping-not-a-string-1.js.map @@ -1,6 +1,7 @@ { "version": 3, "names": [], - "sources": ["invalid-mapping-not-a-string-1.js"], + "file": "invalid-mapping-not-a-string-1.js", + "sources": ["empty-original.js"], "mappings": 5 } diff --git a/resources/invalid-mapping-not-a-string-2.js.map b/resources/invalid-mapping-not-a-string-2.js.map index 77bd62e..4527e7f 100644 --- a/resources/invalid-mapping-not-a-string-2.js.map +++ b/resources/invalid-mapping-not-a-string-2.js.map @@ -1,6 +1,7 @@ { "version": 3, "names": [], - "sources": ["invalid-mapping-not-a-string-2.js"], + "file": "invalid-mapping-not-a-string-2.js", + "sources": ["empty-original.js"], "mappings": [1, 2, 3, 4] } diff --git a/resources/invalid-mapping-segment-column-too-large.js.map b/resources/invalid-mapping-segment-column-too-large.js.map index dc2c346..b4c059e 100644 --- a/resources/invalid-mapping-segment-column-too-large.js.map +++ b/resources/invalid-mapping-segment-column-too-large.js.map @@ -1,6 +1,7 @@ { "version": 3, "names": [], - "sources": ["invalid-mapping-segment-column-too-large.js"], + "file": "invalid-mapping-segment-column-too-large.js", + "sources": ["empty-original.js"], "mappings": "ggggggE" } diff --git a/resources/invalid-mapping-segment-name-index-out-of-bounds.js.map b/resources/invalid-mapping-segment-name-index-out-of-bounds.js.map index fb9d64c..8dd2ea6 100644 --- a/resources/invalid-mapping-segment-name-index-out-of-bounds.js.map +++ b/resources/invalid-mapping-segment-name-index-out-of-bounds.js.map @@ -1,6 +1,7 @@ { "version": 3, "names": ["foo"], - "sources": ["invalid-mapping-segment-name-index-out-of-bounds.js"], + "file": "invalid-mapping-segment-name-index-out-of-bounds.js", + "sources": ["empty-original.js"], "mappings": "AAAAC" } diff --git a/resources/invalid-mapping-segment-name-index-too-large.js.map b/resources/invalid-mapping-segment-name-index-too-large.js.map index e27eaf7..c7bf5b9 100644 --- a/resources/invalid-mapping-segment-name-index-too-large.js.map +++ b/resources/invalid-mapping-segment-name-index-too-large.js.map @@ -1,6 +1,7 @@ { "version": 3, "names": [], - "sources": ["invalid-mapping-segment-name-index-too-large.js"], + "file": "invalid-mapping-segment-name-index-too-large.js", + "sources": ["empty-original.js"], "mappings": "AAAAggggggE" } diff --git a/resources/invalid-mapping-segment-negative-column.js.map b/resources/invalid-mapping-segment-negative-column.js.map index fc78d88..403878b 100644 --- a/resources/invalid-mapping-segment-negative-column.js.map +++ b/resources/invalid-mapping-segment-negative-column.js.map @@ -1,6 +1,7 @@ { "version": 3, "names": [], - "sources": ["invalid-mapping-segment-negative-column.js"], + "file": "invalid-mapping-segment-negative-column.js", + "sources": ["empty-original.js"], "mappings": "F" } diff --git a/resources/invalid-mapping-segment-negative-name-index.js.map b/resources/invalid-mapping-segment-negative-name-index.js.map index 7b1717f..b94f636 100644 --- a/resources/invalid-mapping-segment-negative-name-index.js.map +++ b/resources/invalid-mapping-segment-negative-name-index.js.map @@ -1,6 +1,7 @@ { "version": 3, "names": [], - "sources": ["invalid-mapping-segment-negative-name-index.js"], + "file": "invalid-mapping-segment-negative-name-index.js", + "sources": ["empty-original.js"], "mappings": "AAAAF" } diff --git a/resources/invalid-mapping-segment-negative-original-column.js.map b/resources/invalid-mapping-segment-negative-original-column.js.map index 0469de0..011c639 100644 --- a/resources/invalid-mapping-segment-negative-original-column.js.map +++ b/resources/invalid-mapping-segment-negative-original-column.js.map @@ -1,6 +1,7 @@ { "version": 3, "names": [], - "sources": ["invalid-mapping-segment-negative-original-column.js"], + "file": "invalid-mapping-segment-negative-original-column.js", + "sources": ["empty-original.js"], "mappings": "AAAF" } diff --git a/resources/invalid-mapping-segment-negative-original-line.js.map b/resources/invalid-mapping-segment-negative-original-line.js.map index 1f33706..e7ec993 100644 --- a/resources/invalid-mapping-segment-negative-original-line.js.map +++ b/resources/invalid-mapping-segment-negative-original-line.js.map @@ -1,6 +1,7 @@ { "version": 3, "names": [], - "sources": ["invalid-mapping-segment-negative-original-line.js"], + "file": "invalid-mapping-segment-negative-original-line.js", + "sources": ["empty-original.js"], "mappings": "AAFA" } diff --git a/resources/invalid-mapping-segment-negative-source-index.js.map b/resources/invalid-mapping-segment-negative-source-index.js.map index 5453ad0..596c2f2 100644 --- a/resources/invalid-mapping-segment-negative-source-index.js.map +++ b/resources/invalid-mapping-segment-negative-source-index.js.map @@ -1,6 +1,7 @@ { "version": 3, "names": [], - "sources": ["invalid-mapping-segment-negative-source-index.js"], + "file": "invalid-mapping-segment-negative-source-index.js", + "sources": ["empty-original.js"], "mappings": "AFAA" } diff --git a/resources/invalid-mapping-segment-original-column-too-large.js.map b/resources/invalid-mapping-segment-original-column-too-large.js.map index 218fc20..ff2103f 100644 --- a/resources/invalid-mapping-segment-original-column-too-large.js.map +++ b/resources/invalid-mapping-segment-original-column-too-large.js.map @@ -1,6 +1,7 @@ { "version": 3, "names": [], - "sources": ["invalid-mapping-segment-original-column-too-large.js"], + "file": "invalid-mapping-segment-original-column-too-large.js", + "sources": ["empty-original.js"], "mappings": "AAAggggggE" } diff --git a/resources/invalid-mapping-segment-original-line-too-large.js.map b/resources/invalid-mapping-segment-original-line-too-large.js.map index d96075d..890f1c7 100644 --- a/resources/invalid-mapping-segment-original-line-too-large.js.map +++ b/resources/invalid-mapping-segment-original-line-too-large.js.map @@ -1,6 +1,7 @@ { "version": 3, "names": [], - "sources": ["invalid-mapping-segment-original-line-too-large.js"], + "file": "invalid-mapping-segment-original-line-too-large.js", + "sources": ["empty-original.js"], "mappings": "AAggggggEA" } diff --git a/resources/invalid-mapping-segment-source-index-out-of-bounds.js.map b/resources/invalid-mapping-segment-source-index-out-of-bounds.js.map index 0e68bd5..86dedb1 100644 --- a/resources/invalid-mapping-segment-source-index-out-of-bounds.js.map +++ b/resources/invalid-mapping-segment-source-index-out-of-bounds.js.map @@ -1,6 +1,7 @@ { "version": 3, "names": [], - "sources": ["invalid-mapping-segment-source-index-out-of-bounds.js"], + "file": "invalid-mapping-segment-source-index-out-of-bounds.js", + "sources": ["empty-original.js"], "mappings": "ACAA" } diff --git a/resources/invalid-mapping-segment-source-index-too-large.js.map b/resources/invalid-mapping-segment-source-index-too-large.js.map index c136e36..e9f858c 100644 --- a/resources/invalid-mapping-segment-source-index-too-large.js.map +++ b/resources/invalid-mapping-segment-source-index-too-large.js.map @@ -1,6 +1,7 @@ { "version": 3, "names": [], - "sources": ["invalid-mapping-segment-source-index-too-large.js"], + "file": "invalid-mapping-segment-source-index-too-large.js", + "sources": ["empty-original.js"], "mappings": "AggggggEAA" } diff --git a/resources/invalid-mapping-segment-with-zero-fields.js.map b/resources/invalid-mapping-segment-with-zero-fields.js.map index d848cc1..5a34d25 100644 --- a/resources/invalid-mapping-segment-with-zero-fields.js.map +++ b/resources/invalid-mapping-segment-with-zero-fields.js.map @@ -1,6 +1,7 @@ { "version": 3, "names": [], - "sources": ["invalid-mapping-segment-with-zero-fields.js"], + "file": "invalid-mapping-segment-with-zero-fields.js", + "sources": ["empty-original.js"], "mappings": ",,,," } diff --git a/resources/valid-mapping-boundary-values.js.map b/resources/valid-mapping-boundary-values.js.map index d80126b..4dd836e 100644 --- a/resources/valid-mapping-boundary-values.js.map +++ b/resources/valid-mapping-boundary-values.js.map @@ -1,6 +1,7 @@ { "version": 3, "names": ["foo"], - "sources": ["valid-mapping-boundary-values.js"], + "file": "valid-mapping-boundary-values.js", + "sources": ["empty-original.js"], "mappings": "+/////DA+/////D+/////DA" } diff --git a/resources/valid-mapping-empty-groups.js.map b/resources/valid-mapping-empty-groups.js.map index 8079ce8..53be4ae 100644 --- a/resources/valid-mapping-empty-groups.js.map +++ b/resources/valid-mapping-empty-groups.js.map @@ -1,6 +1,7 @@ { "version": 3, "names": [], - "sources": ["valid-mapping-empty-groups.js"], + "file": "valid-mapping-empty-groups.js", + "sources": ["empty-original.js"], "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;" } From fb619d25b16541443469e34aded454b53abd2fd8 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Thu, 4 Apr 2024 17:19:24 -0700 Subject: [PATCH 38/68] Add tests for missing sources/names fields These tests intentionally don't have any mappings, to see if implementations will detect the missing required fields without parsing the mappings. --- resources/names-missing.js | 1 + resources/names-missing.js.map | 5 +++++ resources/sources-missing.js | 1 + resources/sources-missing.js.map | 5 +++++ source-map-spec-tests.json | 14 ++++++++++++++ 5 files changed, 26 insertions(+) create mode 100644 resources/names-missing.js create mode 100644 resources/names-missing.js.map create mode 100644 resources/sources-missing.js create mode 100644 resources/sources-missing.js.map diff --git a/resources/names-missing.js b/resources/names-missing.js new file mode 100644 index 0000000..58781fd --- /dev/null +++ b/resources/names-missing.js @@ -0,0 +1 @@ +//# sourceMappingURL=names-missing.js.map diff --git a/resources/names-missing.js.map b/resources/names-missing.js.map new file mode 100644 index 0000000..7dc1b92 --- /dev/null +++ b/resources/names-missing.js.map @@ -0,0 +1,5 @@ +{ + "version" : "3", + "sources": ["empty-original.js"], + "mappings": "" +} diff --git a/resources/sources-missing.js b/resources/sources-missing.js new file mode 100644 index 0000000..779b865 --- /dev/null +++ b/resources/sources-missing.js @@ -0,0 +1 @@ +//# sourceMappingURL=sources-missing.js.map diff --git a/resources/sources-missing.js.map b/resources/sources-missing.js.map new file mode 100644 index 0000000..61122fc --- /dev/null +++ b/resources/sources-missing.js.map @@ -0,0 +1,5 @@ +{ + "version" : "3", + "names": ["foo"], + "mappings": "" +} diff --git a/source-map-spec-tests.json b/source-map-spec-tests.json index 800b750..ac53964 100644 --- a/source-map-spec-tests.json +++ b/source-map-spec-tests.json @@ -35,6 +35,13 @@ "sourceMapFile": "version-too-low.js.map", "sourceMapIsValid": false }, + { + "name": "sourcesMissing", + "description": "Test a source map that is missing a necessary sources field", + "baseFile": "sources-missing.js", + "sourceMapFile": "sources-missing.js.map", + "sourceMapIsValid": false + }, { "name": "sourcesNotAList1", "description": "Test a source map with a sources field that is not a valid list (string)", @@ -49,6 +56,13 @@ "sourceMapFile": "sources-not-a-list-2.js.map", "sourceMapIsValid": false }, + { + "name": "namesMissing", + "description": "Test a source map that is missing a necessary names field", + "baseFile": "names-missing.js", + "sourceMapFile": "names-missing.js.map", + "sourceMapIsValid": false + }, { "name": "namesNotAList1", "description": "Test a source map with a names field that is not a valid list (string)", From 492c81b749c1543bfb6e667bc9efb26ba8e689ca Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Fri, 5 Apr 2024 17:57:08 -0700 Subject: [PATCH 39/68] Add a version of basic mapping with index maps This will work in the WebKit harness with an upcoming commit, but doesn't currently work in Firefox. --- resources/basic-mapping-as-index-map.js | 2 + resources/basic-mapping-as-index-map.js.map | 23 ++++ source-map-spec-tests.json | 117 ++++++++++++++++++++ 3 files changed, 142 insertions(+) create mode 100644 resources/basic-mapping-as-index-map.js create mode 100644 resources/basic-mapping-as-index-map.js.map diff --git a/resources/basic-mapping-as-index-map.js b/resources/basic-mapping-as-index-map.js new file mode 100644 index 0000000..b9fae38 --- /dev/null +++ b/resources/basic-mapping-as-index-map.js @@ -0,0 +1,2 @@ +function foo(){return 42}function bar(){return 24}foo();bar(); +//# sourceMappingURL=basic-mapping-as-index-map.js.map diff --git a/resources/basic-mapping-as-index-map.js.map b/resources/basic-mapping-as-index-map.js.map new file mode 100644 index 0000000..12053a5 --- /dev/null +++ b/resources/basic-mapping-as-index-map.js.map @@ -0,0 +1,23 @@ +{ + "version": "3", + "sections": [ + { + "offset": { "line": 0, "column": 0 }, + "map": { + "version": "3", + "names": ["foo","bar"], + "sources": ["basic-mapping-original.js"], + "mappings": "AAAA,SAASA,MACP,OAAO,EACT,CACA" + } + }, + { + "offset": { "line": 0, "column": 34 }, + "map": { + "version": "3", + "names": ["foo","bar"], + "sources": ["basic-mapping-original.js"], + "mappings": "AAGSC,MACP,OAAO,EACT,CACAD,MACAC" + } + } + ] +} diff --git a/source-map-spec-tests.json b/source-map-spec-tests.json index ac53964..3091a3c 100644 --- a/source-map-spec-tests.json +++ b/source-map-spec-tests.json @@ -355,6 +355,123 @@ } ] }, + { + "name": "basicMappingWithIndexMap", + "description": "Test a version of basic-mapping.js.map that is split into sections with an index map", + "baseFile": "basic-mapping-as-index-map.js", + "sourceMapFile": "basic-mapping-as-index-map.js.map", + "sourceMapIsValid": true, + "testActions": [ + { + "actionType": "checkMapping", + "generatedLine": 0, + "generatedColumn": 0, + "originalSource": "basic-mapping-original.js", + "originalLine": 0, + "originalColumn": 0, + "mappedName": null + }, + { + "actionType": "checkMapping", + "generatedLine": 0, + "generatedColumn": 9, + "originalSource": "basic-mapping-original.js", + "originalLine": 0, + "originalColumn": 9, + "mappedName": "foo" + }, + { + "actionType": "checkMapping", + "originalSource": "basic-mapping-original.js", + "generatedLine": 0, + "generatedColumn": 15, + "originalLine": 1, + "originalColumn": 2, + "mappedName": null + }, + { + "actionType": "checkMapping", + "originalSource": "basic-mapping-original.js", + "generatedLine": 0, + "generatedColumn": 22, + "originalLine": 1, + "originalColumn": 9, + "mappedName": null + }, + { + "actionType": "checkMapping", + "originalSource": "basic-mapping-original.js", + "generatedLine": 0, + "generatedColumn": 24, + "originalLine": 2, + "originalColumn": 0, + "mappedName": null + }, + { + "actionType": "checkMapping", + "originalSource": "basic-mapping-original.js", + "generatedLine": 0, + "generatedColumn": 25, + "originalLine": 3, + "originalColumn": 0, + "mappedName": null + }, + { + "actionType": "checkMapping", + "generatedLine": 0, + "generatedColumn": 34, + "originalSource": "basic-mapping-original.js", + "originalLine": 3, + "originalColumn": 9, + "mappedName": "bar" + }, + { + "actionType": "checkMapping", + "originalSource": "basic-mapping-original.js", + "generatedLine": 0, + "generatedColumn": 40, + "originalLine": 4, + "originalColumn": 2, + "mappedName": null + }, + { + "actionType": "checkMapping", + "originalSource": "basic-mapping-original.js", + "generatedLine": 0, + "generatedColumn": 47, + "originalLine": 4, + "originalColumn": 9, + "mappedName": null + }, + { + "actionType": "checkMapping", + "originalSource": "basic-mapping-original.js", + "generatedLine": 0, + "generatedColumn": 49, + "originalLine": 5, + "originalColumn": 0, + "mappedName": null + }, + { + "actionType": "checkMapping", + "originalSource": "basic-mapping-original.js", + "generatedLine": 0, + "generatedColumn": 50, + "originalLine": 6, + "originalColumn": 0, + "mappedName": "foo" + }, + { + "actionType": "checkMapping", + "originalSource": "basic-mapping-original.js", + "generatedLine": 0, + "generatedColumn": 56, + "originalLine": 7, + "originalColumn": 0, + "mappedName": "bar" + } + ] + }, { "name": "validMappingNullSources", "description": "Test a source map that has null sources", From be5c912c5fdc869cee791ceb596ec8525e97969f Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Fri, 5 Apr 2024 18:00:01 -0700 Subject: [PATCH 40/68] Update WebKit test harness --- ...d-harness-for-source-maps-spec-tests.patch | 820 ++++++++++++++++-- webkit/source-map-spec.html | 12 +- 2 files changed, 760 insertions(+), 72 deletions(-) diff --git a/webkit/0001-Add-harness-for-source-maps-spec-tests.patch b/webkit/0001-Add-harness-for-source-maps-spec-tests.patch index fbab821..050bf04 100644 --- a/webkit/0001-Add-harness-for-source-maps-spec-tests.patch +++ b/webkit/0001-Add-harness-for-source-maps-spec-tests.patch @@ -1,4 +1,4 @@ -From a8069fe61364a3ac4ffd3434b4d9c87650b3a7d5 Mon Sep 17 00:00:00 2001 +From d2ac7108de0b2a76e072ba8d7d4a9e733d3782ef Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Mon, 11 Mar 2024 13:41:31 -0700 Subject: [PATCH] Add harness for source maps spec tests @@ -10,6 +10,10 @@ Reviewed by NOBODY (OOPS!). Explanation of why this fixes the bug (OOPS!). +* LayoutTests/inspector/model/resources/basic-mapping-as-index-map.js: Added. +(foo): +(bar): +* LayoutTests/inspector/model/resources/basic-mapping-as-index-map.js.map: Added. * LayoutTests/inspector/model/resources/basic-mapping-original.js: Added. (foo): (bar): @@ -17,9 +21,75 @@ Explanation of why this fixes the bug (OOPS!). (foo): (bar): * LayoutTests/inspector/model/resources/basic-mapping.js.map: Added. +* LayoutTests/inspector/model/resources/invalid-mapping-bad-separator.js: Added. +(foo): +(bar): +* LayoutTests/inspector/model/resources/invalid-mapping-bad-separator.js.map: Added. +* LayoutTests/inspector/model/resources/invalid-mapping-not-a-string-1.js: Added. +* LayoutTests/inspector/model/resources/invalid-mapping-not-a-string-1.js.map: Added. +* LayoutTests/inspector/model/resources/invalid-mapping-not-a-string-2.js: Added. +* LayoutTests/inspector/model/resources/invalid-mapping-not-a-string-2.js.map: Added. +* LayoutTests/inspector/model/resources/invalid-mapping-segment-column-too-large.js: Added. +* LayoutTests/inspector/model/resources/invalid-mapping-segment-column-too-large.js.map: Added. +* LayoutTests/inspector/model/resources/invalid-mapping-segment-name-index-out-of-bounds.js: Added. +* LayoutTests/inspector/model/resources/invalid-mapping-segment-name-index-out-of-bounds.js.map: Added. +* LayoutTests/inspector/model/resources/invalid-mapping-segment-name-index-too-large.js: Added. +* LayoutTests/inspector/model/resources/invalid-mapping-segment-name-index-too-large.js.map: Added. +* LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-column.js: Added. +* LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-column.js.map: Added. +* LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-name-index.js: Added. +* LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-name-index.js.map: Added. +* LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-original-column.js: Added. +* LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-original-column.js.map: Added. +* LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-original-line.js: Added. +* LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-original-line.js.map: Added. +* LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-source-index.js: Added. +* LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-source-index.js.map: Added. +* LayoutTests/inspector/model/resources/invalid-mapping-segment-original-column-too-large.js: Added. +* LayoutTests/inspector/model/resources/invalid-mapping-segment-original-column-too-large.js.map: Added. +* LayoutTests/inspector/model/resources/invalid-mapping-segment-original-line-too-large.js: Added. +* LayoutTests/inspector/model/resources/invalid-mapping-segment-original-line-too-large.js.map: Added. +* LayoutTests/inspector/model/resources/invalid-mapping-segment-source-index-out-of-bounds.js: Added. +* LayoutTests/inspector/model/resources/invalid-mapping-segment-source-index-out-of-bounds.js.map: Added. +* LayoutTests/inspector/model/resources/invalid-mapping-segment-source-index-too-large.js: Added. +* LayoutTests/inspector/model/resources/invalid-mapping-segment-source-index-too-large.js.map: Added. +* LayoutTests/inspector/model/resources/invalid-mapping-segment-with-three-fields.js: Added. +(foo): +(bar): +* LayoutTests/inspector/model/resources/invalid-mapping-segment-with-three-fields.js.map: Added. +* LayoutTests/inspector/model/resources/invalid-mapping-segment-with-two-fields.js: Added. +(foo): +(bar): +* LayoutTests/inspector/model/resources/invalid-mapping-segment-with-two-fields.js.map: Added. +* LayoutTests/inspector/model/resources/invalid-mapping-segment-with-zero-fields.js: Added. +* LayoutTests/inspector/model/resources/invalid-mapping-segment-with-zero-fields.js.map: Added. +* LayoutTests/inspector/model/resources/invalid-vlq-non-base64-char.js: Added. +* LayoutTests/inspector/model/resources/invalid-vlq-non-base64-char.js.map: Added. +* LayoutTests/inspector/model/resources/names-missing.js: Added. +* LayoutTests/inspector/model/resources/names-missing.js.map: Added. +* LayoutTests/inspector/model/resources/names-not-a-list-1.js: Added. +* LayoutTests/inspector/model/resources/names-not-a-list-1.js.map: Added. +* LayoutTests/inspector/model/resources/names-not-a-list-2.js: Added. +* LayoutTests/inspector/model/resources/names-not-a-list-2.js.map: Added. * LayoutTests/inspector/model/resources/source-map-spec-tests.json: Added. +* LayoutTests/inspector/model/resources/sources-missing.js: Added. +* LayoutTests/inspector/model/resources/sources-missing.js.map: Added. +* LayoutTests/inspector/model/resources/sources-not-a-list-1.js: Added. +* LayoutTests/inspector/model/resources/sources-not-a-list-1.js.map: Added. +* LayoutTests/inspector/model/resources/sources-not-a-list-2.js: Added. +* LayoutTests/inspector/model/resources/sources-not-a-list-2.js.map: Added. * LayoutTests/inspector/model/resources/unrecognized-property.js: Added. * LayoutTests/inspector/model/resources/unrecognized-property.js.map: Added. +* LayoutTests/inspector/model/resources/valid-mapping-boundary-values.js: Added. +* LayoutTests/inspector/model/resources/valid-mapping-boundary-values.js.map: Added. +* LayoutTests/inspector/model/resources/valid-mapping-empty-groups.js: Added. +* LayoutTests/inspector/model/resources/valid-mapping-empty-groups.js.map: Added. +* LayoutTests/inspector/model/resources/valid-mapping-large-vlq.js: Added. +* LayoutTests/inspector/model/resources/valid-mapping-large-vlq.js.map: Added. +* LayoutTests/inspector/model/resources/valid-mapping-null-sources.js: Added. +(foo): +(bar): +* LayoutTests/inspector/model/resources/valid-mapping-null-sources.js.map: Added. * LayoutTests/inspector/model/resources/version-not-a-number.js: Added. * LayoutTests/inspector/model/resources/version-not-a-number.js.map: Added. * LayoutTests/inspector/model/resources/version-numeric-string.js: Added. @@ -33,48 +103,72 @@ Explanation of why this fixes the bug (OOPS!). * LayoutTests/inspector/model/source-map-spec-expected.txt: Added. * LayoutTests/inspector/model/source-map-spec.html: Added. --- + .../resources/basic-mapping-as-index-map.js | 2 + + .../basic-mapping-as-index-map.js.map | 23 + .../model/resources/basic-mapping-original.js | 8 + .../model/resources/basic-mapping.js | 2 + .../model/resources/basic-mapping.js.map | 6 + .../invalid-mapping-bad-separator.js | 2 + .../invalid-mapping-bad-separator.js.map | 6 + .../invalid-mapping-not-a-string-1.js | 1 + - .../invalid-mapping-not-a-string-1.js.map | 6 + + .../invalid-mapping-not-a-string-1.js.map | 7 + .../invalid-mapping-not-a-string-2.js | 1 + - .../invalid-mapping-not-a-string-2.js.map | 6 + + .../invalid-mapping-not-a-string-2.js.map | 7 + ...nvalid-mapping-segment-column-too-large.js | 1 + - ...id-mapping-segment-column-too-large.js.map | 6 + + ...id-mapping-segment-column-too-large.js.map | 7 + + ...apping-segment-name-index-out-of-bounds.js | 1 + + ...ng-segment-name-index-out-of-bounds.js.map | 7 + ...id-mapping-segment-name-index-too-large.js | 1 + - ...apping-segment-name-index-too-large.js.map | 6 + + ...apping-segment-name-index-too-large.js.map | 7 + ...invalid-mapping-segment-negative-column.js | 1 + - ...lid-mapping-segment-negative-column.js.map | 6 + + ...lid-mapping-segment-negative-column.js.map | 7 + ...lid-mapping-segment-negative-name-index.js | 1 + - ...mapping-segment-negative-name-index.js.map | 6 + + ...mapping-segment-negative-name-index.js.map | 7 + ...apping-segment-negative-original-column.js | 1 + - ...ng-segment-negative-original-column.js.map | 6 + + ...ng-segment-negative-original-column.js.map | 7 + ...-mapping-segment-negative-original-line.js | 1 + - ...ping-segment-negative-original-line.js.map | 6 + + ...ping-segment-negative-original-line.js.map | 7 + ...d-mapping-segment-negative-source-index.js | 1 + - ...pping-segment-negative-source-index.js.map | 6 + + ...pping-segment-negative-source-index.js.map | 7 + ...pping-segment-original-column-too-large.js | 1 + - ...g-segment-original-column-too-large.js.map | 6 + + ...g-segment-original-column-too-large.js.map | 7 + ...mapping-segment-original-line-too-large.js | 1 + - ...ing-segment-original-line-too-large.js.map | 6 + + ...ing-segment-original-line-too-large.js.map | 7 + + ...ping-segment-source-index-out-of-bounds.js | 1 + + ...-segment-source-index-out-of-bounds.js.map | 7 + ...-mapping-segment-source-index-too-large.js | 1 + - ...ping-segment-source-index-too-large.js.map | 6 + + ...ping-segment-source-index-too-large.js.map | 7 + ...valid-mapping-segment-with-three-fields.js | 2 + ...d-mapping-segment-with-three-fields.js.map | 6 + ...invalid-mapping-segment-with-two-fields.js | 2 + ...lid-mapping-segment-with-two-fields.js.map | 6 + + ...nvalid-mapping-segment-with-zero-fields.js | 1 + + ...id-mapping-segment-with-zero-fields.js.map | 7 + .../resources/invalid-vlq-non-base64-char.js | 1 + .../invalid-vlq-non-base64-char.js.map | 6 + - .../resources/source-map-spec-tests.json | 199 ++++++++++++++++++ + .../model/resources/names-missing.js | 1 + + .../model/resources/names-missing.js.map | 5 + + .../model/resources/names-not-a-list-1.js | 1 + + .../model/resources/names-not-a-list-1.js.map | 6 + + .../model/resources/names-not-a-list-2.js | 1 + + .../model/resources/names-not-a-list-2.js.map | 6 + + .../resources/source-map-spec-tests.json | 503 ++++++++++++++++++ + .../model/resources/sources-missing.js | 1 + + .../model/resources/sources-missing.js.map | 5 + + .../model/resources/sources-not-a-list-1.js | 1 + + .../resources/sources-not-a-list-1.js.map | 6 + + .../model/resources/sources-not-a-list-2.js | 1 + + .../resources/sources-not-a-list-2.js.map | 6 + .../model/resources/unrecognized-property.js | 1 + .../resources/unrecognized-property.js.map | 8 + .../valid-mapping-boundary-values.js | 1 + - .../valid-mapping-boundary-values.js.map | 6 + + .../valid-mapping-boundary-values.js.map | 7 + + .../resources/valid-mapping-empty-groups.js | 1 + + .../valid-mapping-empty-groups.js.map | 7 + .../resources/valid-mapping-large-vlq.js | 1 + .../resources/valid-mapping-large-vlq.js.map | 6 + + .../resources/valid-mapping-null-sources.js | 2 + + .../valid-mapping-null-sources.js.map | 6 + .../model/resources/version-not-a-number.js | 1 + .../resources/version-not-a-number.js.map | 6 + .../model/resources/version-numeric-string.js | 1 + @@ -85,9 +179,11 @@ Explanation of why this fixes the bug (OOPS!). .../model/resources/version-too-low.js.map | 6 + .../model/resources/version-valid.js | 1 + .../model/resources/version-valid.js.map | 6 + - .../model/source-map-spec-expected.txt | 22 ++ - .../inspector/model/source-map-spec.html | 81 +++++++ - 54 files changed, 491 insertions(+) + .../model/source-map-spec-expected.txt | 22 + + .../inspector/model/source-map-spec.html | 83 +++ + 78 files changed, 915 insertions(+) + create mode 100644 LayoutTests/inspector/model/resources/basic-mapping-as-index-map.js + create mode 100644 LayoutTests/inspector/model/resources/basic-mapping-as-index-map.js.map create mode 100644 LayoutTests/inspector/model/resources/basic-mapping-original.js create mode 100644 LayoutTests/inspector/model/resources/basic-mapping.js create mode 100644 LayoutTests/inspector/model/resources/basic-mapping.js.map @@ -99,6 +195,8 @@ Explanation of why this fixes the bug (OOPS!). create mode 100644 LayoutTests/inspector/model/resources/invalid-mapping-not-a-string-2.js.map create mode 100644 LayoutTests/inspector/model/resources/invalid-mapping-segment-column-too-large.js create mode 100644 LayoutTests/inspector/model/resources/invalid-mapping-segment-column-too-large.js.map + create mode 100644 LayoutTests/inspector/model/resources/invalid-mapping-segment-name-index-out-of-bounds.js + create mode 100644 LayoutTests/inspector/model/resources/invalid-mapping-segment-name-index-out-of-bounds.js.map create mode 100644 LayoutTests/inspector/model/resources/invalid-mapping-segment-name-index-too-large.js create mode 100644 LayoutTests/inspector/model/resources/invalid-mapping-segment-name-index-too-large.js.map create mode 100644 LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-column.js @@ -115,21 +213,41 @@ Explanation of why this fixes the bug (OOPS!). create mode 100644 LayoutTests/inspector/model/resources/invalid-mapping-segment-original-column-too-large.js.map create mode 100644 LayoutTests/inspector/model/resources/invalid-mapping-segment-original-line-too-large.js create mode 100644 LayoutTests/inspector/model/resources/invalid-mapping-segment-original-line-too-large.js.map + create mode 100644 LayoutTests/inspector/model/resources/invalid-mapping-segment-source-index-out-of-bounds.js + create mode 100644 LayoutTests/inspector/model/resources/invalid-mapping-segment-source-index-out-of-bounds.js.map create mode 100644 LayoutTests/inspector/model/resources/invalid-mapping-segment-source-index-too-large.js create mode 100644 LayoutTests/inspector/model/resources/invalid-mapping-segment-source-index-too-large.js.map create mode 100644 LayoutTests/inspector/model/resources/invalid-mapping-segment-with-three-fields.js create mode 100644 LayoutTests/inspector/model/resources/invalid-mapping-segment-with-three-fields.js.map create mode 100644 LayoutTests/inspector/model/resources/invalid-mapping-segment-with-two-fields.js create mode 100644 LayoutTests/inspector/model/resources/invalid-mapping-segment-with-two-fields.js.map + create mode 100644 LayoutTests/inspector/model/resources/invalid-mapping-segment-with-zero-fields.js + create mode 100644 LayoutTests/inspector/model/resources/invalid-mapping-segment-with-zero-fields.js.map create mode 100644 LayoutTests/inspector/model/resources/invalid-vlq-non-base64-char.js create mode 100644 LayoutTests/inspector/model/resources/invalid-vlq-non-base64-char.js.map + create mode 100644 LayoutTests/inspector/model/resources/names-missing.js + create mode 100644 LayoutTests/inspector/model/resources/names-missing.js.map + create mode 100644 LayoutTests/inspector/model/resources/names-not-a-list-1.js + create mode 100644 LayoutTests/inspector/model/resources/names-not-a-list-1.js.map + create mode 100644 LayoutTests/inspector/model/resources/names-not-a-list-2.js + create mode 100644 LayoutTests/inspector/model/resources/names-not-a-list-2.js.map create mode 100644 LayoutTests/inspector/model/resources/source-map-spec-tests.json + create mode 100644 LayoutTests/inspector/model/resources/sources-missing.js + create mode 100644 LayoutTests/inspector/model/resources/sources-missing.js.map + create mode 100644 LayoutTests/inspector/model/resources/sources-not-a-list-1.js + create mode 100644 LayoutTests/inspector/model/resources/sources-not-a-list-1.js.map + create mode 100644 LayoutTests/inspector/model/resources/sources-not-a-list-2.js + create mode 100644 LayoutTests/inspector/model/resources/sources-not-a-list-2.js.map create mode 100644 LayoutTests/inspector/model/resources/unrecognized-property.js create mode 100644 LayoutTests/inspector/model/resources/unrecognized-property.js.map create mode 100644 LayoutTests/inspector/model/resources/valid-mapping-boundary-values.js create mode 100644 LayoutTests/inspector/model/resources/valid-mapping-boundary-values.js.map + create mode 100644 LayoutTests/inspector/model/resources/valid-mapping-empty-groups.js + create mode 100644 LayoutTests/inspector/model/resources/valid-mapping-empty-groups.js.map create mode 100644 LayoutTests/inspector/model/resources/valid-mapping-large-vlq.js create mode 100644 LayoutTests/inspector/model/resources/valid-mapping-large-vlq.js.map + create mode 100644 LayoutTests/inspector/model/resources/valid-mapping-null-sources.js + create mode 100644 LayoutTests/inspector/model/resources/valid-mapping-null-sources.js.map create mode 100644 LayoutTests/inspector/model/resources/version-not-a-number.js create mode 100644 LayoutTests/inspector/model/resources/version-not-a-number.js.map create mode 100644 LayoutTests/inspector/model/resources/version-numeric-string.js @@ -143,6 +261,43 @@ Explanation of why this fixes the bug (OOPS!). create mode 100644 LayoutTests/inspector/model/source-map-spec-expected.txt create mode 100644 LayoutTests/inspector/model/source-map-spec.html +diff --git a/LayoutTests/inspector/model/resources/basic-mapping-as-index-map.js b/LayoutTests/inspector/model/resources/basic-mapping-as-index-map.js +new file mode 100644 +index 000000000000..b9fae380437d +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/basic-mapping-as-index-map.js +@@ -0,0 +1,2 @@ ++function foo(){return 42}function bar(){return 24}foo();bar(); ++//# sourceMappingURL=basic-mapping-as-index-map.js.map +diff --git a/LayoutTests/inspector/model/resources/basic-mapping-as-index-map.js.map b/LayoutTests/inspector/model/resources/basic-mapping-as-index-map.js.map +new file mode 100644 +index 000000000000..12053a5698a6 +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/basic-mapping-as-index-map.js.map +@@ -0,0 +1,23 @@ ++{ ++ "version": "3", ++ "sections": [ ++ { ++ "offset": { "line": 0, "column": 0 }, ++ "map": { ++ "version": "3", ++ "names": ["foo","bar"], ++ "sources": ["basic-mapping-original.js"], ++ "mappings": "AAAA,SAASA,MACP,OAAO,EACT,CACA" ++ } ++ }, ++ { ++ "offset": { "line": 0, "column": 34 }, ++ "map": { ++ "version": "3", ++ "names": ["foo","bar"], ++ "sources": ["basic-mapping-original.js"], ++ "mappings": "AAGSC,MACP,OAAO,EACT,CACAD,MACAC" ++ } ++ } ++ ] ++} diff --git a/LayoutTests/inspector/model/resources/basic-mapping-original.js b/LayoutTests/inspector/model/resources/basic-mapping-original.js new file mode 100644 index 000000000000..301b186cb15e @@ -206,14 +361,15 @@ index 000000000000..cb38e2fe9d7b +//# sourceMappingURL=invalid-mapping-not-a-string-1.js.map diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-not-a-string-1.js.map b/LayoutTests/inspector/model/resources/invalid-mapping-not-a-string-1.js.map new file mode 100644 -index 000000000000..54bf8d953d74 +index 000000000000..5bf3e2a9d85b --- /dev/null +++ b/LayoutTests/inspector/model/resources/invalid-mapping-not-a-string-1.js.map -@@ -0,0 +1,6 @@ +@@ -0,0 +1,7 @@ +{ + "version": 3, + "names": [], -+ "sources": ["invalid-mapping-not-a-string-1.js"], ++ "file": "invalid-mapping-not-a-string-1.js", ++ "sources": ["empty-original.js"], + "mappings": 5 +} diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-not-a-string-2.js b/LayoutTests/inspector/model/resources/invalid-mapping-not-a-string-2.js @@ -225,14 +381,15 @@ index 000000000000..3d84abd6c6b4 +//# sourceMappingURL=invalid-mapping-not-a-string-2.js.map diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-not-a-string-2.js.map b/LayoutTests/inspector/model/resources/invalid-mapping-not-a-string-2.js.map new file mode 100644 -index 000000000000..77bd62e18452 +index 000000000000..4527e7f7641c --- /dev/null +++ b/LayoutTests/inspector/model/resources/invalid-mapping-not-a-string-2.js.map -@@ -0,0 +1,6 @@ +@@ -0,0 +1,7 @@ +{ + "version": 3, + "names": [], -+ "sources": ["invalid-mapping-not-a-string-2.js"], ++ "file": "invalid-mapping-not-a-string-2.js", ++ "sources": ["empty-original.js"], + "mappings": [1, 2, 3, 4] +} diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-segment-column-too-large.js b/LayoutTests/inspector/model/resources/invalid-mapping-segment-column-too-large.js @@ -244,16 +401,37 @@ index 000000000000..55591f874b1b +//# sourceMappingURL=invalid-mapping-segment-column-too-large.js.map diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-segment-column-too-large.js.map b/LayoutTests/inspector/model/resources/invalid-mapping-segment-column-too-large.js.map new file mode 100644 -index 000000000000..dc2c3464d12e +index 000000000000..b4c059e0151b --- /dev/null +++ b/LayoutTests/inspector/model/resources/invalid-mapping-segment-column-too-large.js.map -@@ -0,0 +1,6 @@ +@@ -0,0 +1,7 @@ +{ + "version": 3, + "names": [], -+ "sources": ["invalid-mapping-segment-column-too-large.js"], ++ "file": "invalid-mapping-segment-column-too-large.js", ++ "sources": ["empty-original.js"], + "mappings": "ggggggE" +} +diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-segment-name-index-out-of-bounds.js b/LayoutTests/inspector/model/resources/invalid-mapping-segment-name-index-out-of-bounds.js +new file mode 100644 +index 000000000000..2a6b434eff58 +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/invalid-mapping-segment-name-index-out-of-bounds.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=invalid-mapping-segment-name-index-out-of-bounds.js.map +diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-segment-name-index-out-of-bounds.js.map b/LayoutTests/inspector/model/resources/invalid-mapping-segment-name-index-out-of-bounds.js.map +new file mode 100644 +index 000000000000..8dd2ea6c2da0 +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/invalid-mapping-segment-name-index-out-of-bounds.js.map +@@ -0,0 +1,7 @@ ++{ ++ "version": 3, ++ "names": ["foo"], ++ "file": "invalid-mapping-segment-name-index-out-of-bounds.js", ++ "sources": ["empty-original.js"], ++ "mappings": "AAAAC" ++} diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-segment-name-index-too-large.js b/LayoutTests/inspector/model/resources/invalid-mapping-segment-name-index-too-large.js new file mode 100644 index 000000000000..709e34dbd326 @@ -263,14 +441,15 @@ index 000000000000..709e34dbd326 +//# sourceMappingURL=invalid-mapping-segment-name-index-too-large.js.map diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-segment-name-index-too-large.js.map b/LayoutTests/inspector/model/resources/invalid-mapping-segment-name-index-too-large.js.map new file mode 100644 -index 000000000000..e27eaf715f2c +index 000000000000..c7bf5b98d120 --- /dev/null +++ b/LayoutTests/inspector/model/resources/invalid-mapping-segment-name-index-too-large.js.map -@@ -0,0 +1,6 @@ +@@ -0,0 +1,7 @@ +{ + "version": 3, + "names": [], -+ "sources": ["invalid-mapping-segment-name-index-too-large.js"], ++ "file": "invalid-mapping-segment-name-index-too-large.js", ++ "sources": ["empty-original.js"], + "mappings": "AAAAggggggE" +} diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-column.js b/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-column.js @@ -282,14 +461,15 @@ index 000000000000..a202152d6fdf +//# sourceMappingURL=invalid-mapping-segment-negative-column.js.map diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-column.js.map b/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-column.js.map new file mode 100644 -index 000000000000..fc78d8888060 +index 000000000000..403878bfa47a --- /dev/null +++ b/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-column.js.map -@@ -0,0 +1,6 @@ +@@ -0,0 +1,7 @@ +{ + "version": 3, + "names": [], -+ "sources": ["invalid-mapping-segment-negative-column.js"], ++ "file": "invalid-mapping-segment-negative-column.js", ++ "sources": ["empty-original.js"], + "mappings": "F" +} diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-name-index.js b/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-name-index.js @@ -301,14 +481,15 @@ index 000000000000..3e3f63420467 +//# sourceMappingURL=invalid-mapping-segment-negative-name-index.js.map diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-name-index.js.map b/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-name-index.js.map new file mode 100644 -index 000000000000..7b1717fc92ff +index 000000000000..b94f63646e46 --- /dev/null +++ b/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-name-index.js.map -@@ -0,0 +1,6 @@ +@@ -0,0 +1,7 @@ +{ + "version": 3, + "names": [], -+ "sources": ["invalid-mapping-segment-negative-name-index.js"], ++ "file": "invalid-mapping-segment-negative-name-index.js", ++ "sources": ["empty-original.js"], + "mappings": "AAAAF" +} diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-original-column.js b/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-original-column.js @@ -320,14 +501,15 @@ index 000000000000..f21d5342b395 +//# sourceMappingURL=invalid-mapping-segment-negative-original-column.js.map diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-original-column.js.map b/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-original-column.js.map new file mode 100644 -index 000000000000..0469de0be003 +index 000000000000..011c639d3f91 --- /dev/null +++ b/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-original-column.js.map -@@ -0,0 +1,6 @@ +@@ -0,0 +1,7 @@ +{ + "version": 3, + "names": [], -+ "sources": ["invalid-mapping-segment-negative-original-column.js"], ++ "file": "invalid-mapping-segment-negative-original-column.js", ++ "sources": ["empty-original.js"], + "mappings": "AAAF" +} diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-original-line.js b/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-original-line.js @@ -339,14 +521,15 @@ index 000000000000..b37309601ce0 +//# sourceMappingURL=invalid-mapping-segment-negative-original-line.js.map diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-original-line.js.map b/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-original-line.js.map new file mode 100644 -index 000000000000..1f33706bc1f1 +index 000000000000..e7ec993eebda --- /dev/null +++ b/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-original-line.js.map -@@ -0,0 +1,6 @@ +@@ -0,0 +1,7 @@ +{ + "version": 3, + "names": [], -+ "sources": ["invalid-mapping-segment-negative-original-line.js"], ++ "file": "invalid-mapping-segment-negative-original-line.js", ++ "sources": ["empty-original.js"], + "mappings": "AAFA" +} diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-source-index.js b/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-source-index.js @@ -358,14 +541,15 @@ index 000000000000..6e05849b6a03 +//# sourceMappingURL=invalid-mapping-segment-negative-source-index.js.map diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-source-index.js.map b/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-source-index.js.map new file mode 100644 -index 000000000000..5453ad0b3058 +index 000000000000..596c2f298bbe --- /dev/null +++ b/LayoutTests/inspector/model/resources/invalid-mapping-segment-negative-source-index.js.map -@@ -0,0 +1,6 @@ +@@ -0,0 +1,7 @@ +{ + "version": 3, + "names": [], -+ "sources": ["invalid-mapping-segment-negative-source-index.js"], ++ "file": "invalid-mapping-segment-negative-source-index.js", ++ "sources": ["empty-original.js"], + "mappings": "AFAA" +} diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-segment-original-column-too-large.js b/LayoutTests/inspector/model/resources/invalid-mapping-segment-original-column-too-large.js @@ -377,14 +561,15 @@ index 000000000000..0936ed7ea8fd +//# sourceMappingURL=invalid-mapping-segment-original-column-too-large.js.map diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-segment-original-column-too-large.js.map b/LayoutTests/inspector/model/resources/invalid-mapping-segment-original-column-too-large.js.map new file mode 100644 -index 000000000000..218fc2021913 +index 000000000000..ff2103fe24fe --- /dev/null +++ b/LayoutTests/inspector/model/resources/invalid-mapping-segment-original-column-too-large.js.map -@@ -0,0 +1,6 @@ +@@ -0,0 +1,7 @@ +{ + "version": 3, + "names": [], -+ "sources": ["invalid-mapping-segment-original-column-too-large.js"], ++ "file": "invalid-mapping-segment-original-column-too-large.js", ++ "sources": ["empty-original.js"], + "mappings": "AAAggggggE" +} diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-segment-original-line-too-large.js b/LayoutTests/inspector/model/resources/invalid-mapping-segment-original-line-too-large.js @@ -396,16 +581,37 @@ index 000000000000..9b3aa5a361ae +//# sourceMappingURL=invalid-mapping-segment-original-line-too-large.js.map diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-segment-original-line-too-large.js.map b/LayoutTests/inspector/model/resources/invalid-mapping-segment-original-line-too-large.js.map new file mode 100644 -index 000000000000..d96075dc0b85 +index 000000000000..890f1c71fc5b --- /dev/null +++ b/LayoutTests/inspector/model/resources/invalid-mapping-segment-original-line-too-large.js.map -@@ -0,0 +1,6 @@ +@@ -0,0 +1,7 @@ +{ + "version": 3, + "names": [], -+ "sources": ["invalid-mapping-segment-original-line-too-large.js"], ++ "file": "invalid-mapping-segment-original-line-too-large.js", ++ "sources": ["empty-original.js"], + "mappings": "AAggggggEA" +} +diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-segment-source-index-out-of-bounds.js b/LayoutTests/inspector/model/resources/invalid-mapping-segment-source-index-out-of-bounds.js +new file mode 100644 +index 000000000000..2e5fbca26825 +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/invalid-mapping-segment-source-index-out-of-bounds.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=invalid-mapping-segment-source-index-out-of-bounds.js.map +diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-segment-source-index-out-of-bounds.js.map b/LayoutTests/inspector/model/resources/invalid-mapping-segment-source-index-out-of-bounds.js.map +new file mode 100644 +index 000000000000..86dedb114fa9 +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/invalid-mapping-segment-source-index-out-of-bounds.js.map +@@ -0,0 +1,7 @@ ++{ ++ "version": 3, ++ "names": [], ++ "file": "invalid-mapping-segment-source-index-out-of-bounds.js", ++ "sources": ["empty-original.js"], ++ "mappings": "ACAA" ++} diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-segment-source-index-too-large.js b/LayoutTests/inspector/model/resources/invalid-mapping-segment-source-index-too-large.js new file mode 100644 index 000000000000..3f4943e1272d @@ -415,14 +621,15 @@ index 000000000000..3f4943e1272d +//# sourceMappingURL=invalid-mapping-segment-source-index-too-large.js.map diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-segment-source-index-too-large.js.map b/LayoutTests/inspector/model/resources/invalid-mapping-segment-source-index-too-large.js.map new file mode 100644 -index 000000000000..c136e3637301 +index 000000000000..e9f858c6e15d --- /dev/null +++ b/LayoutTests/inspector/model/resources/invalid-mapping-segment-source-index-too-large.js.map -@@ -0,0 +1,6 @@ +@@ -0,0 +1,7 @@ +{ + "version": 3, + "names": [], -+ "sources": ["invalid-mapping-segment-source-index-too-large.js"], ++ "file": "invalid-mapping-segment-source-index-too-large.js", ++ "sources": ["empty-original.js"], + "mappings": "AggggggEAA" +} diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-segment-with-three-fields.js b/LayoutTests/inspector/model/resources/invalid-mapping-segment-with-three-fields.js @@ -465,6 +672,26 @@ index 000000000000..73cf00fa1c96 + "sources": ["basic-mapping-original.js"], + "mappings": "AA" +} +diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-segment-with-zero-fields.js b/LayoutTests/inspector/model/resources/invalid-mapping-segment-with-zero-fields.js +new file mode 100644 +index 000000000000..9d5332a56ca5 +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/invalid-mapping-segment-with-zero-fields.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=invalid-mapping-segment-column-with-zero-fields.js.map +diff --git a/LayoutTests/inspector/model/resources/invalid-mapping-segment-with-zero-fields.js.map b/LayoutTests/inspector/model/resources/invalid-mapping-segment-with-zero-fields.js.map +new file mode 100644 +index 000000000000..5a34d25b645e +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/invalid-mapping-segment-with-zero-fields.js.map +@@ -0,0 +1,7 @@ ++{ ++ "version": 3, ++ "names": [], ++ "file": "invalid-mapping-segment-with-zero-fields.js", ++ "sources": ["empty-original.js"], ++ "mappings": ",,,," ++} diff --git a/LayoutTests/inspector/model/resources/invalid-vlq-non-base64-char.js b/LayoutTests/inspector/model/resources/invalid-vlq-non-base64-char.js new file mode 100644 index 000000000000..d1b20b41a29f @@ -484,12 +711,68 @@ index 000000000000..4fa1ac576885 + "names": [], + "mappings": "A$%?!" +} +diff --git a/LayoutTests/inspector/model/resources/names-missing.js b/LayoutTests/inspector/model/resources/names-missing.js +new file mode 100644 +index 000000000000..58781fd88705 +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/names-missing.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=names-missing.js.map +diff --git a/LayoutTests/inspector/model/resources/names-missing.js.map b/LayoutTests/inspector/model/resources/names-missing.js.map +new file mode 100644 +index 000000000000..7dc1b929e485 +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/names-missing.js.map +@@ -0,0 +1,5 @@ ++{ ++ "version" : "3", ++ "sources": ["empty-original.js"], ++ "mappings": "" ++} +diff --git a/LayoutTests/inspector/model/resources/names-not-a-list-1.js b/LayoutTests/inspector/model/resources/names-not-a-list-1.js +new file mode 100644 +index 000000000000..dc65f1972b5a +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/names-not-a-list-1.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=names-not-a-list-1.js.map +diff --git a/LayoutTests/inspector/model/resources/names-not-a-list-1.js.map b/LayoutTests/inspector/model/resources/names-not-a-list-1.js.map +new file mode 100644 +index 000000000000..843f7cc2e6fd +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/names-not-a-list-1.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version" : "3", ++ "sources": ["source.js"], ++ "names": "not a list", ++ "mappings": "AAAAA" ++} +diff --git a/LayoutTests/inspector/model/resources/names-not-a-list-2.js b/LayoutTests/inspector/model/resources/names-not-a-list-2.js +new file mode 100644 +index 000000000000..d7251f78da84 +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/names-not-a-list-2.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=names-not-a-list-2.js.map +diff --git a/LayoutTests/inspector/model/resources/names-not-a-list-2.js.map b/LayoutTests/inspector/model/resources/names-not-a-list-2.js.map +new file mode 100644 +index 000000000000..cd7a42a74c4f +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/names-not-a-list-2.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version" : "3", ++ "sources": ["source.js"], ++ "names": { "foo": 3 }, ++ "mappings": "AAAAA" ++} diff --git a/LayoutTests/inspector/model/resources/source-map-spec-tests.json b/LayoutTests/inspector/model/resources/source-map-spec-tests.json new file mode 100644 -index 000000000000..60f4effc775a +index 000000000000..3091a3c93273 --- /dev/null +++ b/LayoutTests/inspector/model/resources/source-map-spec-tests.json -@@ -0,0 +1,199 @@ +@@ -0,0 +1,503 @@ +{ + "tests": [ + { @@ -528,6 +811,48 @@ index 000000000000..60f4effc775a + "sourceMapIsValid": false + }, + { ++ "name": "sourcesMissing", ++ "description": "Test a source map that is missing a necessary sources field", ++ "baseFile": "sources-missing.js", ++ "sourceMapFile": "sources-missing.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "sourcesNotAList1", ++ "description": "Test a source map with a sources field that is not a valid list (string)", ++ "baseFile": "sources-not-a-list-1.js", ++ "sourceMapFile": "sources-not-a-list-1.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "sourcesNotAList2", ++ "description": "Test a source map with a sources field that is not a valid list (object)", ++ "baseFile": "sources-not-a-list-2.js", ++ "sourceMapFile": "sources-not-a-list-2.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "namesMissing", ++ "description": "Test a source map that is missing a necessary names field", ++ "baseFile": "names-missing.js", ++ "sourceMapFile": "names-missing.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "namesNotAList1", ++ "description": "Test a source map with a names field that is not a valid list (string)", ++ "baseFile": "names-not-a-list-1.js", ++ "sourceMapFile": "names-not-a-list-1.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "namesNotAList2", ++ "description": "Test a source map with a names field that is not a valid list (object)", ++ "baseFile": "names-not-a-list-2.js", ++ "sourceMapFile": "names-not-a-list-2.js.map", ++ "sourceMapIsValid": false ++ }, ++ { + "name": "unrecognizedProperty", + "description": "Test a source map that has an extra field not explicitly encoded in the spec", + "baseFile": "unrecognized-property.js", @@ -563,6 +888,13 @@ index 000000000000..60f4effc775a + "sourceMapIsValid": false + }, + { ++ "name": "invalidMappingSegmentWithZeroFields", ++ "description": "Test a source map that has the wrong number (zero) of segments fields", ++ "baseFile": "invalid-mapping-segment-with-zero-fields.js", ++ "sourceMapFile": "invalid-mapping-segment-with-zero-fields.js.map", ++ "sourceMapIsValid": false ++ }, ++ { + "name": "invalidMappingSegmentWithTwoFields", + "description": "Test a source map that has the wrong number (two) of segments fields", + "baseFile": "invalid-mapping-segment-with-two-fields.js", @@ -577,6 +909,20 @@ index 000000000000..60f4effc775a + "sourceMapIsValid": false + }, + { ++ "name": "invalidMappingSegmentWithSourceIndexOutOfBounds", ++ "description": "Test a source map that has a source index field that is out of bounds of the sources field", ++ "baseFile": "invalid-mapping-segment-source-index-out-of-bounds.js", ++ "sourceMapFile": "invalid-mapping-segment-source-index-out-of-bounds.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "invalidMappingSegmentWithNameIndexOutOfBounds", ++ "description": "Test a source map that has a name index field that is out of bounds of the names field", ++ "baseFile": "invalid-mapping-segment-name-index-out-of-bounds.js", ++ "sourceMapFile": "invalid-mapping-segment-name-index-out-of-bounds.js.map", ++ "sourceMapIsValid": false ++ }, ++ { + "name": "invalidMappingSegmentWithNegativeColumn", + "description": "Test a source map that has an invalid negative non-relative column field", + "baseFile": "invalid-mapping-segment-negative-column.js", @@ -661,6 +1007,13 @@ index 000000000000..60f4effc775a + "sourceMapIsValid": true + }, + { ++ "name": "validMappingEmptyGroups", ++ "description": "Test a source map with a mapping that has many empty groups", ++ "baseFile": "valid-mapping-empty-groups.js", ++ "sourceMapFile": "valid-mapping-empty-groups.js.map", ++ "sourceMapIsValid": true ++ }, ++ { + "name": "basicMapping", + "description": "Test a simple source map that has several valid mappings", + "baseFile": "basic-mapping.js", @@ -669,26 +1022,316 @@ index 000000000000..60f4effc775a + "testActions": [ + { + "actionType": "checkMapping", ++ "generatedLine": 0, ++ "generatedColumn": 0, + "originalSource": "basic-mapping-original.js", + "originalLine": 0, -+ "originalColumn": 9, ++ "originalColumn": 0, ++ "mappedName": null ++ }, ++ { ++ "actionType": "checkMapping", + "generatedLine": 0, + "generatedColumn": 9, ++ "originalSource": "basic-mapping-original.js", ++ "originalLine": 0, ++ "originalColumn": 9, + "mappedName": "foo" + }, + { + "actionType": "checkMapping", + "originalSource": "basic-mapping-original.js", ++ "generatedLine": 0, ++ "generatedColumn": 15, ++ "originalLine": 1, ++ "originalColumn": 2, ++ "mappedName": null ++ }, ++ { ++ "actionType": "checkMapping", ++ "originalSource": "basic-mapping-original.js", ++ "generatedLine": 0, ++ "generatedColumn": 22, ++ "originalLine": 1, ++ "originalColumn": 9, ++ "mappedName": null ++ }, ++ { ++ "actionType": "checkMapping", ++ "originalSource": "basic-mapping-original.js", ++ "generatedLine": 0, ++ "generatedColumn": 24, ++ "originalLine": 2, ++ "originalColumn": 0, ++ "mappedName": null ++ }, ++ { ++ "actionType": "checkMapping", ++ "originalSource": "basic-mapping-original.js", ++ "generatedLine": 0, ++ "generatedColumn": 25, ++ "originalLine": 3, ++ "originalColumn": 0, ++ "mappedName": null ++ }, ++ { ++ "actionType": "checkMapping", ++ "generatedLine": 0, ++ "generatedColumn": 34, ++ "originalSource": "basic-mapping-original.js", + "originalLine": 3, + "originalColumn": 9, ++ "mappedName": "bar" ++ }, ++ { ++ "actionType": "checkMapping", ++ "originalSource": "basic-mapping-original.js", ++ "generatedLine": 0, ++ "generatedColumn": 40, ++ "originalLine": 4, ++ "originalColumn": 2, ++ "mappedName": null ++ }, ++ { ++ "actionType": "checkMapping", ++ "originalSource": "basic-mapping-original.js", ++ "generatedLine": 0, ++ "generatedColumn": 47, ++ "originalLine": 4, ++ "originalColumn": 9, ++ "mappedName": null ++ }, ++ { ++ "actionType": "checkMapping", ++ "originalSource": "basic-mapping-original.js", ++ "generatedLine": 0, ++ "generatedColumn": 49, ++ "originalLine": 5, ++ "originalColumn": 0, ++ "mappedName": null ++ }, ++ { ++ "actionType": "checkMapping", ++ "originalSource": "basic-mapping-original.js", ++ "generatedLine": 0, ++ "generatedColumn": 50, ++ "originalLine": 6, ++ "originalColumn": 0, ++ "mappedName": "foo" ++ }, ++ { ++ "actionType": "checkMapping", ++ "originalSource": "basic-mapping-original.js", ++ "generatedLine": 0, ++ "generatedColumn": 56, ++ "originalLine": 7, ++ "originalColumn": 0, ++ "mappedName": "bar" ++ } ++ ] ++ }, ++ { ++ "name": "basicMappingWithIndexMap", ++ "description": "Test a version of basic-mapping.js.map that is split into sections with an index map", ++ "baseFile": "basic-mapping-as-index-map.js", ++ "sourceMapFile": "basic-mapping-as-index-map.js.map", ++ "sourceMapIsValid": true, ++ "testActions": [ ++ { ++ "actionType": "checkMapping", ++ "generatedLine": 0, ++ "generatedColumn": 0, ++ "originalSource": "basic-mapping-original.js", ++ "originalLine": 0, ++ "originalColumn": 0, ++ "mappedName": null ++ }, ++ { ++ "actionType": "checkMapping", ++ "generatedLine": 0, ++ "generatedColumn": 9, ++ "originalSource": "basic-mapping-original.js", ++ "originalLine": 0, ++ "originalColumn": 9, ++ "mappedName": "foo" ++ }, ++ { ++ "actionType": "checkMapping", ++ "originalSource": "basic-mapping-original.js", ++ "generatedLine": 0, ++ "generatedColumn": 15, ++ "originalLine": 1, ++ "originalColumn": 2, ++ "mappedName": null ++ }, ++ { ++ "actionType": "checkMapping", ++ "originalSource": "basic-mapping-original.js", ++ "generatedLine": 0, ++ "generatedColumn": 22, ++ "originalLine": 1, ++ "originalColumn": 9, ++ "mappedName": null ++ }, ++ { ++ "actionType": "checkMapping", ++ "originalSource": "basic-mapping-original.js", ++ "generatedLine": 0, ++ "generatedColumn": 24, ++ "originalLine": 2, ++ "originalColumn": 0, ++ "mappedName": null ++ }, ++ { ++ "actionType": "checkMapping", ++ "originalSource": "basic-mapping-original.js", ++ "generatedLine": 0, ++ "generatedColumn": 25, ++ "originalLine": 3, ++ "originalColumn": 0, ++ "mappedName": null ++ }, ++ { ++ "actionType": "checkMapping", + "generatedLine": 0, + "generatedColumn": 34, ++ "originalSource": "basic-mapping-original.js", ++ "originalLine": 3, ++ "originalColumn": 9, ++ "mappedName": "bar" ++ }, ++ { ++ "actionType": "checkMapping", ++ "originalSource": "basic-mapping-original.js", ++ "generatedLine": 0, ++ "generatedColumn": 40, ++ "originalLine": 4, ++ "originalColumn": 2, ++ "mappedName": null ++ }, ++ { ++ "actionType": "checkMapping", ++ "originalSource": "basic-mapping-original.js", ++ "generatedLine": 0, ++ "generatedColumn": 47, ++ "originalLine": 4, ++ "originalColumn": 9, ++ "mappedName": null ++ }, ++ { ++ "actionType": "checkMapping", ++ "originalSource": "basic-mapping-original.js", ++ "generatedLine": 0, ++ "generatedColumn": 49, ++ "originalLine": 5, ++ "originalColumn": 0, ++ "mappedName": null ++ }, ++ { ++ "actionType": "checkMapping", ++ "originalSource": "basic-mapping-original.js", ++ "generatedLine": 0, ++ "generatedColumn": 50, ++ "originalLine": 6, ++ "originalColumn": 0, ++ "mappedName": "foo" ++ }, ++ { ++ "actionType": "checkMapping", ++ "originalSource": "basic-mapping-original.js", ++ "generatedLine": 0, ++ "generatedColumn": 56, ++ "originalLine": 7, ++ "originalColumn": 0, + "mappedName": "bar" + } + ] ++ }, ++ { ++ "name": "validMappingNullSources", ++ "description": "Test a source map that has null sources", ++ "baseFile": "valid-mapping-null-sources.js", ++ "sourceMapFile": "valid-mapping-null-sources.js.map", ++ "sourceMapIsValid": true, ++ "testActions": [ ++ { ++ "actionType": "checkMapping", ++ "generatedLine": 0, ++ "generatedColumn": 0, ++ "originalSource": null, ++ "originalLine": 0, ++ "originalColumn": 0, ++ "mappedName": null ++ }, ++ { ++ "actionType": "checkMapping", ++ "generatedLine": 0, ++ "generatedColumn": 9, ++ "originalSource": null, ++ "originalLine": 0, ++ "originalColumn": 9, ++ "mappedName": "foo" ++ } ++ ] + } + ] +} +diff --git a/LayoutTests/inspector/model/resources/sources-missing.js b/LayoutTests/inspector/model/resources/sources-missing.js +new file mode 100644 +index 000000000000..779b865e2769 +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/sources-missing.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=sources-missing.js.map +diff --git a/LayoutTests/inspector/model/resources/sources-missing.js.map b/LayoutTests/inspector/model/resources/sources-missing.js.map +new file mode 100644 +index 000000000000..61122fcb3f25 +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/sources-missing.js.map +@@ -0,0 +1,5 @@ ++{ ++ "version" : "3", ++ "names": ["foo"], ++ "mappings": "" ++} +diff --git a/LayoutTests/inspector/model/resources/sources-not-a-list-1.js b/LayoutTests/inspector/model/resources/sources-not-a-list-1.js +new file mode 100644 +index 000000000000..7e33b7e86725 +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/sources-not-a-list-1.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=sources-not-a-list-1.js.map +diff --git a/LayoutTests/inspector/model/resources/sources-not-a-list-1.js.map b/LayoutTests/inspector/model/resources/sources-not-a-list-1.js.map +new file mode 100644 +index 000000000000..b2e24787bc16 +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/sources-not-a-list-1.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version" : "3", ++ "sources": "not a list", ++ "names": ["foo"], ++ "mappings": "AAAAA" ++} +diff --git a/LayoutTests/inspector/model/resources/sources-not-a-list-2.js b/LayoutTests/inspector/model/resources/sources-not-a-list-2.js +new file mode 100644 +index 000000000000..4021f763fc88 +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/sources-not-a-list-2.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=sources-not-a-list-2.js.map +diff --git a/LayoutTests/inspector/model/resources/sources-not-a-list-2.js.map b/LayoutTests/inspector/model/resources/sources-not-a-list-2.js.map +new file mode 100644 +index 000000000000..6a6a8635729c +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/sources-not-a-list-2.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version" : "3", ++ "sources": { "source.js": 3 }, ++ "names": ["foo"], ++ "mappings": "AAAAA" ++} diff --git a/LayoutTests/inspector/model/resources/unrecognized-property.js b/LayoutTests/inspector/model/resources/unrecognized-property.js new file mode 100644 index 000000000000..19dfb0e2e6c7 @@ -719,16 +1362,37 @@ index 000000000000..3c49709e05ac +//# sourceMappingURL=valid-mapping-boundary-values.js.map diff --git a/LayoutTests/inspector/model/resources/valid-mapping-boundary-values.js.map b/LayoutTests/inspector/model/resources/valid-mapping-boundary-values.js.map new file mode 100644 -index 000000000000..d80126ba9efe +index 000000000000..4dd836e63d8f --- /dev/null +++ b/LayoutTests/inspector/model/resources/valid-mapping-boundary-values.js.map -@@ -0,0 +1,6 @@ +@@ -0,0 +1,7 @@ +{ + "version": 3, + "names": ["foo"], -+ "sources": ["valid-mapping-boundary-values.js"], ++ "file": "valid-mapping-boundary-values.js", ++ "sources": ["empty-original.js"], + "mappings": "+/////DA+/////D+/////DA" +} +diff --git a/LayoutTests/inspector/model/resources/valid-mapping-empty-groups.js b/LayoutTests/inspector/model/resources/valid-mapping-empty-groups.js +new file mode 100644 +index 000000000000..a2b767b619a0 +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/valid-mapping-empty-groups.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=valid-mapping-empty-groups.js.map +diff --git a/LayoutTests/inspector/model/resources/valid-mapping-empty-groups.js.map b/LayoutTests/inspector/model/resources/valid-mapping-empty-groups.js.map +new file mode 100644 +index 000000000000..53be4ae4ae91 +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/valid-mapping-empty-groups.js.map +@@ -0,0 +1,7 @@ ++{ ++ "version": 3, ++ "names": [], ++ "file": "valid-mapping-empty-groups.js", ++ "sources": ["empty-original.js"], ++ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;" ++} diff --git a/LayoutTests/inspector/model/resources/valid-mapping-large-vlq.js b/LayoutTests/inspector/model/resources/valid-mapping-large-vlq.js new file mode 100644 index 000000000000..b0cd8978132a @@ -748,6 +1412,26 @@ index 000000000000..76e18704c4b1 + "sources": ["valid-mapping-large-vlq.js"], + "mappings": "igggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggA" +} +diff --git a/LayoutTests/inspector/model/resources/valid-mapping-null-sources.js b/LayoutTests/inspector/model/resources/valid-mapping-null-sources.js +new file mode 100644 +index 000000000000..ee2acf0f5b2f +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/valid-mapping-null-sources.js +@@ -0,0 +1,2 @@ ++function foo(){return 42}function bar(){return 24}foo();bar(); ++//# sourceMappingURL=valid-mapping-null-sources.js.map +diff --git a/LayoutTests/inspector/model/resources/valid-mapping-null-sources.js.map b/LayoutTests/inspector/model/resources/valid-mapping-null-sources.js.map +new file mode 100644 +index 000000000000..199cda936955 +--- /dev/null ++++ b/LayoutTests/inspector/model/resources/valid-mapping-null-sources.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version":3, ++ "names": ["foo"], ++ "sources": [null], ++ "mappings":"AAAA,SAASA" ++} diff --git a/LayoutTests/inspector/model/resources/version-not-a-number.js b/LayoutTests/inspector/model/resources/version-not-a-number.js new file mode 100644 index 000000000000..ae2342e2ffe5 @@ -873,10 +1557,10 @@ index 000000000000..c74ab5bcfb32 + diff --git a/LayoutTests/inspector/model/source-map-spec.html b/LayoutTests/inspector/model/source-map-spec.html new file mode 100644 -index 000000000000..82a056d8bc80 +index 000000000000..b30b1dd526fc --- /dev/null +++ b/LayoutTests/inspector/model/source-map-spec.html -@@ -0,0 +1,81 @@ +@@ -0,0 +1,83 @@ + + + @@ -901,9 +1585,9 @@ index 000000000000..82a056d8bc80 + function checkMapping(resource, testCase, action) + { + const location = resource.createSourceCodeLocation(action.generatedLine, action.generatedColumn); -+ InspectorTest.expectEqual(location.displayLineNumber, action.originalLine); -+ InspectorTest.expectEqual(location.displayColumnNumber, action.originalColumn); -+ InspectorTest.expectEqual(location.displaySourceCode.displayName, action.originalSource); ++ InspectorTest.expectEqual(location.displayLineNumber, action.originalLine, "Original line should match"); ++ InspectorTest.expectEqual(location.displayColumnNumber, action.originalColumn, "Original column should match"); ++ InspectorTest.expectEqual(location.displaySourceCode.displayName, action.originalSource, "Original source should match"); + } + + function withTimeout(promise, seconds) @@ -924,7 +1608,7 @@ index 000000000000..82a056d8bc80 + const testDescriptions = event.data.json; + + for (const testCase of testDescriptions.tests) { -+ console.log(testCase.name); ++ InspectorTest.log(testCase.name); + InspectorTest.evaluateInPage(`triggerScriptResource('${testCase.baseFile}')`); + let resourceEvent = await WI.Frame.awaitEvent(WI.Frame.Event.ResourceWasAdded); + let resource = resourceEvent.data.resource; @@ -933,7 +1617,9 @@ index 000000000000..82a056d8bc80 + if (testCase.sourceMapIsValid) { + InspectorTest.expectEqual(resource.sourceMaps.length, 1, "Resource should have loaded 1 SourceMap."); + InspectorTest.expectThat(resource.sourceMaps[0] instanceof WI.SourceMap, "SourceMap should be a WI.SourceMap instance."); -+ const loadedSourceMap = resource.sourceMaps[0]; ++ if (!(resource.sourceMaps[0] instanceof WI.SourceMap)) { ++ continue; ++ } + } else { + const hasFailedSourceMap = WI.networkManager.isSourceMapURL(absoluteURL(testCase.sourceMapFile, resource.displayURL)); + InspectorTest.expectThat(hasFailedSourceMap, "Expected that there is an associated failed source map URL"); diff --git a/webkit/source-map-spec.html b/webkit/source-map-spec.html index 82a056d..b30b1dd 100644 --- a/webkit/source-map-spec.html +++ b/webkit/source-map-spec.html @@ -22,9 +22,9 @@ function checkMapping(resource, testCase, action) { const location = resource.createSourceCodeLocation(action.generatedLine, action.generatedColumn); - InspectorTest.expectEqual(location.displayLineNumber, action.originalLine); - InspectorTest.expectEqual(location.displayColumnNumber, action.originalColumn); - InspectorTest.expectEqual(location.displaySourceCode.displayName, action.originalSource); + InspectorTest.expectEqual(location.displayLineNumber, action.originalLine, "Original line should match"); + InspectorTest.expectEqual(location.displayColumnNumber, action.originalColumn, "Original column should match"); + InspectorTest.expectEqual(location.displaySourceCode.displayName, action.originalSource, "Original source should match"); } function withTimeout(promise, seconds) @@ -45,7 +45,7 @@ const testDescriptions = event.data.json; for (const testCase of testDescriptions.tests) { - console.log(testCase.name); + InspectorTest.log(testCase.name); InspectorTest.evaluateInPage(`triggerScriptResource('${testCase.baseFile}')`); let resourceEvent = await WI.Frame.awaitEvent(WI.Frame.Event.ResourceWasAdded); let resource = resourceEvent.data.resource; @@ -54,7 +54,9 @@ if (testCase.sourceMapIsValid) { InspectorTest.expectEqual(resource.sourceMaps.length, 1, "Resource should have loaded 1 SourceMap."); InspectorTest.expectThat(resource.sourceMaps[0] instanceof WI.SourceMap, "SourceMap should be a WI.SourceMap instance."); - const loadedSourceMap = resource.sourceMaps[0]; + if (!(resource.sourceMaps[0] instanceof WI.SourceMap)) { + continue; + } } else { const hasFailedSourceMap = WI.networkManager.isSourceMapURL(absoluteURL(testCase.sourceMapFile, resource.displayURL)); InspectorTest.expectThat(hasFailedSourceMap, "Expected that there is an associated failed source map URL"); From f99f1c0063f191c3872a9ac6ea9617926868a77d Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Mon, 8 Apr 2024 12:43:42 -0700 Subject: [PATCH 41/68] Add more error cases for version, sources, names --- resources/names-not-string.js | 1 + resources/names-not-string.js.map | 6 ++++++ resources/sources-not-string-or-null.js | 1 + resources/sources-not-string-or-null.js.map | 6 ++++++ resources/version-missing.js | 1 + resources/version-missing.js.map | 5 +++++ source-map-spec-tests.json | 21 +++++++++++++++++++++ 7 files changed, 41 insertions(+) create mode 100644 resources/names-not-string.js create mode 100644 resources/names-not-string.js.map create mode 100644 resources/sources-not-string-or-null.js create mode 100644 resources/sources-not-string-or-null.js.map create mode 100644 resources/version-missing.js create mode 100644 resources/version-missing.js.map diff --git a/resources/names-not-string.js b/resources/names-not-string.js new file mode 100644 index 0000000..8dc7b48 --- /dev/null +++ b/resources/names-not-string.js @@ -0,0 +1 @@ +//# sourceMappingURL=names-not-string.js.map diff --git a/resources/names-not-string.js.map b/resources/names-not-string.js.map new file mode 100644 index 0000000..cf41136 --- /dev/null +++ b/resources/names-not-string.js.map @@ -0,0 +1,6 @@ +{ + "version" : "3", + "sources": ["source.js"], + "names": [null, 3, true, false, {}, []], + "mappings": "AAAAA" +} diff --git a/resources/sources-not-string-or-null.js b/resources/sources-not-string-or-null.js new file mode 100644 index 0000000..7dca97a --- /dev/null +++ b/resources/sources-not-string-or-null.js @@ -0,0 +1 @@ +//# sourceMappingURL=sources-not-string-or-null.js.map diff --git a/resources/sources-not-string-or-null.js.map b/resources/sources-not-string-or-null.js.map new file mode 100644 index 0000000..213d8aa --- /dev/null +++ b/resources/sources-not-string-or-null.js.map @@ -0,0 +1,6 @@ +{ + "version" : "3", + "sources": [3, {}, true, false, []], + "names": ["foo"], + "mappings": "AAAAA" +} diff --git a/resources/version-missing.js b/resources/version-missing.js new file mode 100644 index 0000000..c32d1f1 --- /dev/null +++ b/resources/version-missing.js @@ -0,0 +1 @@ +//# sourceMappingURL=version-missing.js.map diff --git a/resources/version-missing.js.map b/resources/version-missing.js.map new file mode 100644 index 0000000..49d8ce7 --- /dev/null +++ b/resources/version-missing.js.map @@ -0,0 +1,5 @@ +{ + "sources": [], + "names": [], + "mappings": "" +} diff --git a/source-map-spec-tests.json b/source-map-spec-tests.json index 3091a3c..500ae1a 100644 --- a/source-map-spec-tests.json +++ b/source-map-spec-tests.json @@ -7,6 +7,13 @@ "sourceMapFile": "version-valid.js.map", "sourceMapIsValid": true }, + { + "name": "versionMissing", + "description": "Test a source map that is missing a version field", + "baseFile": "version-missing.js", + "sourceMapFile": "version-missing.js.map", + "sourceMapIsValid": false + }, { "name": "versionNotANumber", "description": "Test a source map with a version field that is not a number", @@ -56,6 +63,13 @@ "sourceMapFile": "sources-not-a-list-2.js.map", "sourceMapIsValid": false }, + { + "name": "sourcesNotStringOrNull", + "description": "Test a source map with a sources list that has non-string and non-null items", + "baseFile": "sources-not-string-or-null.js", + "sourceMapFile": "sources-not-string-or-null.js.map", + "sourceMapIsValid": false + }, { "name": "namesMissing", "description": "Test a source map that is missing a necessary names field", @@ -77,6 +91,13 @@ "sourceMapFile": "names-not-a-list-2.js.map", "sourceMapIsValid": false }, + { + "name": "namesNotString", + "description": "Test a source map with a names list that has non-string items", + "baseFile": "names-not-string.js", + "sourceMapFile": "names-not-string.js.map", + "sourceMapIsValid": false + }, { "name": "unrecognizedProperty", "description": "Test a source map that has an extra field not explicitly encoded in the spec", From f4772b7d8953cafa2633295d36ffb8f7ea414139 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Mon, 8 Apr 2024 14:03:05 -0700 Subject: [PATCH 42/68] Add some invalid test cases for index maps --- resources/index-map-invalid-base-mappings.js | 1 + .../index-map-invalid-base-mappings.js.map | 15 ++++++ resources/index-map-invalid-overlap.js | 1 + resources/index-map-invalid-overlap.js.map | 23 +++++++++ resources/index-map-missing-offset-column.js | 1 + .../index-map-missing-offset-column.js.map | 14 ++++++ resources/index-map-missing-offset-line.js | 1 + .../index-map-missing-offset-line.js.map | 14 ++++++ resources/index-map-missing-offset.js | 1 + resources/index-map-missing-offset.js.map | 13 +++++ .../index-map-offset-column-wrong-type.js | 1 + .../index-map-offset-column-wrong-type.js.map | 14 ++++++ resources/index-map-offset-line-wrong-type.js | 1 + .../index-map-offset-line-wrong-type.js.map | 14 ++++++ source-map-spec-tests.json | 49 +++++++++++++++++++ 15 files changed, 163 insertions(+) create mode 100644 resources/index-map-invalid-base-mappings.js create mode 100644 resources/index-map-invalid-base-mappings.js.map create mode 100644 resources/index-map-invalid-overlap.js create mode 100644 resources/index-map-invalid-overlap.js.map create mode 100644 resources/index-map-missing-offset-column.js create mode 100644 resources/index-map-missing-offset-column.js.map create mode 100644 resources/index-map-missing-offset-line.js create mode 100644 resources/index-map-missing-offset-line.js.map create mode 100644 resources/index-map-missing-offset.js create mode 100644 resources/index-map-missing-offset.js.map create mode 100644 resources/index-map-offset-column-wrong-type.js create mode 100644 resources/index-map-offset-column-wrong-type.js.map create mode 100644 resources/index-map-offset-line-wrong-type.js create mode 100644 resources/index-map-offset-line-wrong-type.js.map diff --git a/resources/index-map-invalid-base-mappings.js b/resources/index-map-invalid-base-mappings.js new file mode 100644 index 0000000..e90bef0 --- /dev/null +++ b/resources/index-map-invalid-base-mappings.js @@ -0,0 +1 @@ +//# sourceMappingURL=index-map-invalid-base-mappings.js.map diff --git a/resources/index-map-invalid-base-mappings.js.map b/resources/index-map-invalid-base-mappings.js.map new file mode 100644 index 0000000..2764fda --- /dev/null +++ b/resources/index-map-invalid-base-mappings.js.map @@ -0,0 +1,15 @@ +{ + "version": "3", + "mappings": "AAAA", + "sections": [ + { + "offset": { "line": 0, "column": 0 }, + "map": { + "version": "3", + "names": [], + "sources": ["empty-original.js"], + "mappings": "AAAA" + } + }, + ] +} diff --git a/resources/index-map-invalid-overlap.js b/resources/index-map-invalid-overlap.js new file mode 100644 index 0000000..9aff8dc --- /dev/null +++ b/resources/index-map-invalid-overlap.js @@ -0,0 +1 @@ +//# sourceMappingURL=index-map-invalid-overlap.js.map diff --git a/resources/index-map-invalid-overlap.js.map b/resources/index-map-invalid-overlap.js.map new file mode 100644 index 0000000..8aa2858 --- /dev/null +++ b/resources/index-map-invalid-overlap.js.map @@ -0,0 +1,23 @@ +{ + "version": "3", + "sections": [ + { + "offset": { "line": 0, "column": 0 }, + "map": { + "version": "3", + "names": [], + "sources": ["empty-original.js"], + "mappings": "AAAA" + } + }, + { + "offset": { "line": 0, "column": 0 }, + "map": { + "version": "3", + "names": [], + "sources": ["empty-original.js"], + "mappings": "AAAA" + } + } + ] +} diff --git a/resources/index-map-missing-offset-column.js b/resources/index-map-missing-offset-column.js new file mode 100644 index 0000000..fe69174 --- /dev/null +++ b/resources/index-map-missing-offset-column.js @@ -0,0 +1 @@ +//# sourceMappingURL=index-map-missing-offset-column.js.map diff --git a/resources/index-map-missing-offset-column.js.map b/resources/index-map-missing-offset-column.js.map new file mode 100644 index 0000000..42783a6 --- /dev/null +++ b/resources/index-map-missing-offset-column.js.map @@ -0,0 +1,14 @@ +{ + "version": "3", + "sections": [ + { + "offset": { "line": 0 }, + "map": { + "version": "3", + "names": [], + "sources": ["empty-original.js"], + "mappings": "AAAA" + } + }, + ] +} diff --git a/resources/index-map-missing-offset-line.js b/resources/index-map-missing-offset-line.js new file mode 100644 index 0000000..ba8614e --- /dev/null +++ b/resources/index-map-missing-offset-line.js @@ -0,0 +1 @@ +//# sourceMappingURL=index-map-missing-offset-line.js.map diff --git a/resources/index-map-missing-offset-line.js.map b/resources/index-map-missing-offset-line.js.map new file mode 100644 index 0000000..4a7e41a --- /dev/null +++ b/resources/index-map-missing-offset-line.js.map @@ -0,0 +1,14 @@ +{ + "version": "3", + "sections": [ + { + "offset": { "column": 0 }, + "map": { + "version": "3", + "names": [], + "sources": ["empty-original.js"], + "mappings": "AAAA" + } + }, + ] +} diff --git a/resources/index-map-missing-offset.js b/resources/index-map-missing-offset.js new file mode 100644 index 0000000..9ca2cf3 --- /dev/null +++ b/resources/index-map-missing-offset.js @@ -0,0 +1 @@ +//# sourceMappingURL=index-map-missing-offset.js.map diff --git a/resources/index-map-missing-offset.js.map b/resources/index-map-missing-offset.js.map new file mode 100644 index 0000000..144d280 --- /dev/null +++ b/resources/index-map-missing-offset.js.map @@ -0,0 +1,13 @@ +{ + "version": "3", + "sections": [ + { + "map": { + "version": "3", + "names": [], + "sources": ["empty-original.js"], + "mappings": "AAAA" + } + }, + ] +} diff --git a/resources/index-map-offset-column-wrong-type.js b/resources/index-map-offset-column-wrong-type.js new file mode 100644 index 0000000..ed1e9ec --- /dev/null +++ b/resources/index-map-offset-column-wrong-type.js @@ -0,0 +1 @@ +//# sourceMappingURL=index-map-offset-column-wrong-type.js.map diff --git a/resources/index-map-offset-column-wrong-type.js.map b/resources/index-map-offset-column-wrong-type.js.map new file mode 100644 index 0000000..81864a0 --- /dev/null +++ b/resources/index-map-offset-column-wrong-type.js.map @@ -0,0 +1,14 @@ +{ + "version": "3", + "sections": [ + { + "offset": { "line": 0, "column": true }, + "map": { + "version": "3", + "names": [], + "sources": ["empty-original.js"], + "mappings": "AAAA" + } + }, + ] +} diff --git a/resources/index-map-offset-line-wrong-type.js b/resources/index-map-offset-line-wrong-type.js new file mode 100644 index 0000000..d58f2af --- /dev/null +++ b/resources/index-map-offset-line-wrong-type.js @@ -0,0 +1 @@ +//# sourceMappingURL=index-map-offset-line-wrong-type.js.map diff --git a/resources/index-map-offset-line-wrong-type.js.map b/resources/index-map-offset-line-wrong-type.js.map new file mode 100644 index 0000000..23e1a46 --- /dev/null +++ b/resources/index-map-offset-line-wrong-type.js.map @@ -0,0 +1,14 @@ +{ + "version": "3", + "sections": [ + { + "offset": { "line": true, "column": 0 }, + "map": { + "version": "3", + "names": [], + "sources": ["empty-original.js"], + "mappings": "AAAA" + } + }, + ] +} diff --git a/source-map-spec-tests.json b/source-map-spec-tests.json index 500ae1a..7e7350b 100644 --- a/source-map-spec-tests.json +++ b/source-map-spec-tests.json @@ -259,6 +259,55 @@ "sourceMapFile": "valid-mapping-empty-groups.js.map", "sourceMapIsValid": true }, + { + "name": "indexMapInvalidBaseMapings", + "description": "Test that an index map cannot also have a regular mappings field", + "baseFile": "index-map-invalid-base-mappings.js", + "sourceMapFile": "index-map-invalid-base-mappings.js.map", + "sourceMapIsValid": false + }, + { + "name": "indexMapInvalidOverlap", + "description": "Test that an invalid index map with multiple sections that overlap", + "baseFile": "index-map-invalid-overlap.js", + "sourceMapFile": "index-map-invalid-overlap.js.map", + "sourceMapIsValid": false + }, + { + "name": "indexMapMissingOffset", + "description": "Test that an index map that is missing a section offset", + "baseFile": "index-map-missing-offset.js", + "sourceMapFile": "index-map-missing-offset.js.map", + "sourceMapIsValid": false + }, + { + "name": "indexMapMissingOffsetLine", + "description": "Test that an index map that is missing a section offset's line field", + "baseFile": "index-map-missing-offset-line.js", + "sourceMapFile": "index-map-missing-offset-line.js.map", + "sourceMapIsValid": false + }, + { + "name": "indexMapMissingOffsetColumn", + "description": "Test that an index map that is missing a section offset's column field", + "baseFile": "index-map-missing-offset-column.js", + "sourceMapFile": "index-map-missing-offset-column.js.map", + "sourceMapIsValid": false + }, + { + "name": "indexMapOffsetLineWrongType", + "description": "Test that an index map that has an offset line field with the wrong type of value", + "baseFile": "index-map-offset-line-wrong-type.js", + "sourceMapFile": "index-map-offset-line-wrong-type.js.map", + "sourceMapIsValid": false + }, + { + "name": "indexMapOffsetColumnWrongType", + "description": "Test that an index map that has an offset column field with the wrong type of value", + "baseFile": "index-map-offset-column-wrong-type.js", + "sourceMapFile": "index-map-offset-column-wrong-type.js.map", + "sourceMapIsValid": false + }, { "name": "basicMapping", "description": "Test a simple source map that has several valid mappings", From a059ec972e6c32154a9e2fcdbed33f625e05b3b2 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Mon, 8 Apr 2024 14:23:31 -0700 Subject: [PATCH 43/68] Fix unintentionally wrong version fields --- resources/basic-mapping-as-index-map.js.map | 6 +++--- resources/index-map-invalid-base-mappings.js.map | 4 ++-- resources/index-map-invalid-overlap.js.map | 6 +++--- resources/index-map-missing-offset-column.js.map | 4 ++-- resources/index-map-missing-offset-line.js.map | 4 ++-- resources/index-map-missing-offset.js.map | 4 ++-- resources/index-map-offset-column-wrong-type.js.map | 4 ++-- resources/index-map-offset-line-wrong-type.js.map | 4 ++-- resources/names-missing.js.map | 2 +- resources/names-not-a-list-1.js.map | 2 +- resources/names-not-a-list-2.js.map | 2 +- resources/names-not-string.js.map | 2 +- resources/sources-missing.js.map | 2 +- resources/sources-not-a-list-1.js.map | 2 +- resources/sources-not-a-list-2.js.map | 2 +- resources/sources-not-string-or-null.js.map | 2 +- 16 files changed, 26 insertions(+), 26 deletions(-) diff --git a/resources/basic-mapping-as-index-map.js.map b/resources/basic-mapping-as-index-map.js.map index 12053a5..0863d44 100644 --- a/resources/basic-mapping-as-index-map.js.map +++ b/resources/basic-mapping-as-index-map.js.map @@ -1,10 +1,10 @@ { - "version": "3", + "version": 3, "sections": [ { "offset": { "line": 0, "column": 0 }, "map": { - "version": "3", + "version": 3, "names": ["foo","bar"], "sources": ["basic-mapping-original.js"], "mappings": "AAAA,SAASA,MACP,OAAO,EACT,CACA" @@ -13,7 +13,7 @@ { "offset": { "line": 0, "column": 34 }, "map": { - "version": "3", + "version": 3, "names": ["foo","bar"], "sources": ["basic-mapping-original.js"], "mappings": "AAGSC,MACP,OAAO,EACT,CACAD,MACAC" diff --git a/resources/index-map-invalid-base-mappings.js.map b/resources/index-map-invalid-base-mappings.js.map index 2764fda..d4bd447 100644 --- a/resources/index-map-invalid-base-mappings.js.map +++ b/resources/index-map-invalid-base-mappings.js.map @@ -1,11 +1,11 @@ { - "version": "3", + "version": 3, "mappings": "AAAA", "sections": [ { "offset": { "line": 0, "column": 0 }, "map": { - "version": "3", + "version": 3, "names": [], "sources": ["empty-original.js"], "mappings": "AAAA" diff --git a/resources/index-map-invalid-overlap.js.map b/resources/index-map-invalid-overlap.js.map index 8aa2858..8d42546 100644 --- a/resources/index-map-invalid-overlap.js.map +++ b/resources/index-map-invalid-overlap.js.map @@ -1,10 +1,10 @@ { - "version": "3", + "version": 3, "sections": [ { "offset": { "line": 0, "column": 0 }, "map": { - "version": "3", + "version": 3, "names": [], "sources": ["empty-original.js"], "mappings": "AAAA" @@ -13,7 +13,7 @@ { "offset": { "line": 0, "column": 0 }, "map": { - "version": "3", + "version": 3, "names": [], "sources": ["empty-original.js"], "mappings": "AAAA" diff --git a/resources/index-map-missing-offset-column.js.map b/resources/index-map-missing-offset-column.js.map index 42783a6..629b43d 100644 --- a/resources/index-map-missing-offset-column.js.map +++ b/resources/index-map-missing-offset-column.js.map @@ -1,10 +1,10 @@ { - "version": "3", + "version": 3, "sections": [ { "offset": { "line": 0 }, "map": { - "version": "3", + "version": 3, "names": [], "sources": ["empty-original.js"], "mappings": "AAAA" diff --git a/resources/index-map-missing-offset-line.js.map b/resources/index-map-missing-offset-line.js.map index 4a7e41a..9ec4f3e 100644 --- a/resources/index-map-missing-offset-line.js.map +++ b/resources/index-map-missing-offset-line.js.map @@ -1,10 +1,10 @@ { - "version": "3", + "version": 3, "sections": [ { "offset": { "column": 0 }, "map": { - "version": "3", + "version": 3, "names": [], "sources": ["empty-original.js"], "mappings": "AAAA" diff --git a/resources/index-map-missing-offset.js.map b/resources/index-map-missing-offset.js.map index 144d280..6769627 100644 --- a/resources/index-map-missing-offset.js.map +++ b/resources/index-map-missing-offset.js.map @@ -1,9 +1,9 @@ { - "version": "3", + "version": 3, "sections": [ { "map": { - "version": "3", + "version": 3, "names": [], "sources": ["empty-original.js"], "mappings": "AAAA" diff --git a/resources/index-map-offset-column-wrong-type.js.map b/resources/index-map-offset-column-wrong-type.js.map index 81864a0..d8a599a 100644 --- a/resources/index-map-offset-column-wrong-type.js.map +++ b/resources/index-map-offset-column-wrong-type.js.map @@ -1,10 +1,10 @@ { - "version": "3", + "version": 3, "sections": [ { "offset": { "line": 0, "column": true }, "map": { - "version": "3", + "version": 3, "names": [], "sources": ["empty-original.js"], "mappings": "AAAA" diff --git a/resources/index-map-offset-line-wrong-type.js.map b/resources/index-map-offset-line-wrong-type.js.map index 23e1a46..faf2e50 100644 --- a/resources/index-map-offset-line-wrong-type.js.map +++ b/resources/index-map-offset-line-wrong-type.js.map @@ -1,10 +1,10 @@ { - "version": "3", + "version": 3, "sections": [ { "offset": { "line": true, "column": 0 }, "map": { - "version": "3", + "version": 3, "names": [], "sources": ["empty-original.js"], "mappings": "AAAA" diff --git a/resources/names-missing.js.map b/resources/names-missing.js.map index 7dc1b92..82170bf 100644 --- a/resources/names-missing.js.map +++ b/resources/names-missing.js.map @@ -1,5 +1,5 @@ { - "version" : "3", + "version" : 3, "sources": ["empty-original.js"], "mappings": "" } diff --git a/resources/names-not-a-list-1.js.map b/resources/names-not-a-list-1.js.map index 843f7cc..fe1edae 100644 --- a/resources/names-not-a-list-1.js.map +++ b/resources/names-not-a-list-1.js.map @@ -1,5 +1,5 @@ { - "version" : "3", + "version" : 3, "sources": ["source.js"], "names": "not a list", "mappings": "AAAAA" diff --git a/resources/names-not-a-list-2.js.map b/resources/names-not-a-list-2.js.map index cd7a42a..3388d2b 100644 --- a/resources/names-not-a-list-2.js.map +++ b/resources/names-not-a-list-2.js.map @@ -1,5 +1,5 @@ { - "version" : "3", + "version" : 3, "sources": ["source.js"], "names": { "foo": 3 }, "mappings": "AAAAA" diff --git a/resources/names-not-string.js.map b/resources/names-not-string.js.map index cf41136..c0feb07 100644 --- a/resources/names-not-string.js.map +++ b/resources/names-not-string.js.map @@ -1,5 +1,5 @@ { - "version" : "3", + "version" : 3, "sources": ["source.js"], "names": [null, 3, true, false, {}, []], "mappings": "AAAAA" diff --git a/resources/sources-missing.js.map b/resources/sources-missing.js.map index 61122fc..92aff4f 100644 --- a/resources/sources-missing.js.map +++ b/resources/sources-missing.js.map @@ -1,5 +1,5 @@ { - "version" : "3", + "version" : 3, "names": ["foo"], "mappings": "" } diff --git a/resources/sources-not-a-list-1.js.map b/resources/sources-not-a-list-1.js.map index b2e2478..2633051 100644 --- a/resources/sources-not-a-list-1.js.map +++ b/resources/sources-not-a-list-1.js.map @@ -1,5 +1,5 @@ { - "version" : "3", + "version" : 3, "sources": "not a list", "names": ["foo"], "mappings": "AAAAA" diff --git a/resources/sources-not-a-list-2.js.map b/resources/sources-not-a-list-2.js.map index 6a6a863..2ed8596 100644 --- a/resources/sources-not-a-list-2.js.map +++ b/resources/sources-not-a-list-2.js.map @@ -1,5 +1,5 @@ { - "version" : "3", + "version" : 3, "sources": { "source.js": 3 }, "names": ["foo"], "mappings": "AAAAA" diff --git a/resources/sources-not-string-or-null.js.map b/resources/sources-not-string-or-null.js.map index 213d8aa..db25561 100644 --- a/resources/sources-not-string-or-null.js.map +++ b/resources/sources-not-string-or-null.js.map @@ -1,5 +1,5 @@ { - "version" : "3", + "version" : 3, "sources": [3, {}, true, false, []], "names": ["foo"], "mappings": "AAAAA" From 39c63a3635320c799fe46c633896ad9476971580 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Tue, 9 Apr 2024 15:11:31 -0700 Subject: [PATCH 44/68] Add a test for index map order (and fix typo) --- resources/index-map-invalid-order.js | 1 + resources/index-map-invalid-order.js.map | 23 +++++++++++++++++++++++ source-map-spec-tests.json | 9 ++++++++- 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 resources/index-map-invalid-order.js create mode 100644 resources/index-map-invalid-order.js.map diff --git a/resources/index-map-invalid-order.js b/resources/index-map-invalid-order.js new file mode 100644 index 0000000..263fa3c --- /dev/null +++ b/resources/index-map-invalid-order.js @@ -0,0 +1 @@ +//# sourceMappingURL=index-map-invalid-order.js.map diff --git a/resources/index-map-invalid-order.js.map b/resources/index-map-invalid-order.js.map new file mode 100644 index 0000000..82da69d --- /dev/null +++ b/resources/index-map-invalid-order.js.map @@ -0,0 +1,23 @@ +{ + "version": 3, + "sections": [ + { + "offset": { "line": 1, "column": 4 }, + "map": { + "version": 3, + "names": [], + "sources": ["empty-original.js"], + "mappings": "AAAA" + } + }, + { + "offset": { "line": 0, "column": 0 }, + "map": { + "version": 3, + "names": [], + "sources": ["empty-original.js"], + "mappings": "AAAA" + } + } + ] +} diff --git a/source-map-spec-tests.json b/source-map-spec-tests.json index 7e7350b..6190bd0 100644 --- a/source-map-spec-tests.json +++ b/source-map-spec-tests.json @@ -260,7 +260,7 @@ "sourceMapIsValid": true }, { - "name": "indexMapInvalidBaseMapings", + "name": "indexMapInvalidBaseMappings", "description": "Test that an index map cannot also have a regular mappings field", "baseFile": "index-map-invalid-base-mappings.js", "sourceMapFile": "index-map-invalid-base-mappings.js.map", @@ -273,6 +273,13 @@ "sourceMapFile": "index-map-invalid-overlap.js.map", "sourceMapIsValid": false }, + { + "name": "indexMapInvalidOrder", + "description": "Test that an invalid index map with multiple sections in the wrong order", + "baseFile": "index-map-invalid-order.js", + "sourceMapFile": "index-map-invalid-order.js.map", + "sourceMapIsValid": false + }, { "name": "indexMapMissingOffset", "description": "Test that an index map that is missing a section offset", From 412a89536cb5d20267c94480f8b8b400f3ead8c0 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Wed, 10 Apr 2024 16:17:06 -0700 Subject: [PATCH 45/68] Add additional tests for index map structure Also remove extra commas --- .../index-map-invalid-base-mappings.js.map | 2 +- resources/index-map-missing-map.js | 1 + resources/index-map-missing-map.js.map | 8 ++++++ resources/index-map-missing-offset.js.map | 2 +- resources/index-map-wrong-type-map.js | 1 + resources/index-map-wrong-type-map.js.map | 9 ++++++ resources/index-map-wrong-type-offset.js | 1 + resources/index-map-wrong-type-offset.js.map | 14 ++++++++++ resources/index-map-wrong-type-sections.js | 1 + .../index-map-wrong-type-sections.js.map | 4 +++ source-map-spec-tests.json | 28 +++++++++++++++++++ 11 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 resources/index-map-missing-map.js create mode 100644 resources/index-map-missing-map.js.map create mode 100644 resources/index-map-wrong-type-map.js create mode 100644 resources/index-map-wrong-type-map.js.map create mode 100644 resources/index-map-wrong-type-offset.js create mode 100644 resources/index-map-wrong-type-offset.js.map create mode 100644 resources/index-map-wrong-type-sections.js create mode 100644 resources/index-map-wrong-type-sections.js.map diff --git a/resources/index-map-invalid-base-mappings.js.map b/resources/index-map-invalid-base-mappings.js.map index d4bd447..b489c1f 100644 --- a/resources/index-map-invalid-base-mappings.js.map +++ b/resources/index-map-invalid-base-mappings.js.map @@ -10,6 +10,6 @@ "sources": ["empty-original.js"], "mappings": "AAAA" } - }, + } ] } diff --git a/resources/index-map-missing-map.js b/resources/index-map-missing-map.js new file mode 100644 index 0000000..86c8e9a --- /dev/null +++ b/resources/index-map-missing-map.js @@ -0,0 +1 @@ +//# sourceMappingURL=index-map-missing-map.js.map diff --git a/resources/index-map-missing-map.js.map b/resources/index-map-missing-map.js.map new file mode 100644 index 0000000..3bce47e --- /dev/null +++ b/resources/index-map-missing-map.js.map @@ -0,0 +1,8 @@ +{ + "version": 3, + "sections": [ + { + "offset": { "line": 0, "column": 0 } + } + ] +} diff --git a/resources/index-map-missing-offset.js.map b/resources/index-map-missing-offset.js.map index 6769627..7285138 100644 --- a/resources/index-map-missing-offset.js.map +++ b/resources/index-map-missing-offset.js.map @@ -8,6 +8,6 @@ "sources": ["empty-original.js"], "mappings": "AAAA" } - }, + } ] } diff --git a/resources/index-map-wrong-type-map.js b/resources/index-map-wrong-type-map.js new file mode 100644 index 0000000..d31d6d6 --- /dev/null +++ b/resources/index-map-wrong-type-map.js @@ -0,0 +1 @@ +//# sourceMappingURL=index-map-wrong-type-map.js.map diff --git a/resources/index-map-wrong-type-map.js.map b/resources/index-map-wrong-type-map.js.map new file mode 100644 index 0000000..0963f62 --- /dev/null +++ b/resources/index-map-wrong-type-map.js.map @@ -0,0 +1,9 @@ +{ + "version": 3, + "sections": [ + { + "offset": { "line": 0, "column": 0 }, + "map": "not a map" + } + ] +} diff --git a/resources/index-map-wrong-type-offset.js b/resources/index-map-wrong-type-offset.js new file mode 100644 index 0000000..048e124 --- /dev/null +++ b/resources/index-map-wrong-type-offset.js @@ -0,0 +1 @@ +//# sourceMappingURL=index-map-wrong-type-offset.js.map diff --git a/resources/index-map-wrong-type-offset.js.map b/resources/index-map-wrong-type-offset.js.map new file mode 100644 index 0000000..59f324d --- /dev/null +++ b/resources/index-map-wrong-type-offset.js.map @@ -0,0 +1,14 @@ +{ + "version": 3, + "sections": [ + { + offset: "not an offset", + "map": { + "version": 3, + "names": [], + "sources": ["empty-original.js"], + "mappings": "AAAA" + } + } + ] +} diff --git a/resources/index-map-wrong-type-sections.js b/resources/index-map-wrong-type-sections.js new file mode 100644 index 0000000..011eca8 --- /dev/null +++ b/resources/index-map-wrong-type-sections.js @@ -0,0 +1 @@ +//# sourceMappingURL=index-map-wrong-type-sections.js.map diff --git a/resources/index-map-wrong-type-sections.js.map b/resources/index-map-wrong-type-sections.js.map new file mode 100644 index 0000000..dbfb4ea --- /dev/null +++ b/resources/index-map-wrong-type-sections.js.map @@ -0,0 +1,4 @@ +{ + "version": 3, + "sections": "not a sections list" +} diff --git a/source-map-spec-tests.json b/source-map-spec-tests.json index 6190bd0..0246f3f 100644 --- a/source-map-spec-tests.json +++ b/source-map-spec-tests.json @@ -259,6 +259,27 @@ "sourceMapFile": "valid-mapping-empty-groups.js.map", "sourceMapIsValid": true }, + { + "name": "indexMapWrongTypeSections", + "description": "Test an index map with a sections field with the wrong type", + "baseFile": "index-map-wrong-type-sections.js", + "sourceMapFile": "index-map-wrong-type-sections.js.map", + "sourceMapIsValid": false + }, + { + "name": "indexMapWrongTypeOffset", + "description": "Test an index map with an offset field with the wrong type", + "baseFile": "index-map-wrong-type-offset.js", + "sourceMapFile": "index-map-wrong-type-offset.js.map", + "sourceMapIsValid": false + }, + { + "name": "indexMapWrongTypeMap", + "description": "Test an index map with a map field with the wrong type", + "baseFile": "index-map-wrong-type-map.js", + "sourceMapFile": "index-map-wrong-type-map.js.map", + "sourceMapIsValid": false + }, { "name": "indexMapInvalidBaseMappings", "description": "Test that an index map cannot also have a regular mappings field", @@ -280,6 +301,13 @@ "sourceMapFile": "index-map-invalid-order.js.map", "sourceMapIsValid": false }, + { + "name": "indexMapMissingMap", + "description": "Test that an index map that is missing a section map", + "baseFile": "index-map-missing-map.js", + "sourceMapFile": "index-map-missing-map.js.map", + "sourceMapIsValid": false + }, { "name": "indexMapMissingOffset", "description": "Test that an index map that is missing a section offset", From 14d506a4b72331952aafdaa4599a4c6d47770582 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Fri, 12 Apr 2024 13:17:59 -0700 Subject: [PATCH 46/68] Refine testing for sources/sourcesContent fields It's not explicitly spelled out in the spec (FIXME) but it doesn't make sense to have a null source and source content for a particular source entry, so it might make sense to make that invalid. It should likely be valid to have a null source entry as long as a source content exists. --- resources/sources-and-sources-content-both-null.js | 1 + resources/sources-and-sources-content-both-null.js.map | 7 +++++++ resources/valid-mapping-null-sources.js.map | 1 + source-map-spec-tests.json | 7 +++++++ 4 files changed, 16 insertions(+) create mode 100644 resources/sources-and-sources-content-both-null.js create mode 100644 resources/sources-and-sources-content-both-null.js.map diff --git a/resources/sources-and-sources-content-both-null.js b/resources/sources-and-sources-content-both-null.js new file mode 100644 index 0000000..9263eba --- /dev/null +++ b/resources/sources-and-sources-content-both-null.js @@ -0,0 +1 @@ +//# sourceMappingURL=sources-and-sources-content-both-null.js.map diff --git a/resources/sources-and-sources-content-both-null.js.map b/resources/sources-and-sources-content-both-null.js.map new file mode 100644 index 0000000..09a7c1f --- /dev/null +++ b/resources/sources-and-sources-content-both-null.js.map @@ -0,0 +1,7 @@ +{ + "version": 3, + "names": ["foo"], + "sources": [null], + "sourcesContent": [null], + "mappings":"AAAA,SAASA" +} diff --git a/resources/valid-mapping-null-sources.js.map b/resources/valid-mapping-null-sources.js.map index 199cda9..43af039 100644 --- a/resources/valid-mapping-null-sources.js.map +++ b/resources/valid-mapping-null-sources.js.map @@ -2,5 +2,6 @@ "version":3, "names": ["foo"], "sources": [null], + "sourcesContent": ["function foo()\n{ return 42; }\nfunction bar()\n { return 24; }\nfoo();\nbar();"], "mappings":"AAAA,SAASA" } diff --git a/source-map-spec-tests.json b/source-map-spec-tests.json index 0246f3f..678efd0 100644 --- a/source-map-spec-tests.json +++ b/source-map-spec-tests.json @@ -70,6 +70,13 @@ "sourceMapFile": "sources-not-string-or-null.js.map", "sourceMapIsValid": false }, + { + "name": "sourcesAndSourcesContentBothNull", + "description": "Test a source map that has both null sources and sourcesContent entries", + "baseFile": "sources-and-sources-content-both-null.js", + "sourceMapFile": "sources-and-sources-content-both-null.js.map", + "sourceMapIsValid": false + }, { "name": "namesMissing", "description": "Test a source map that is missing a necessary names field", From 0d0711028db6c2a56259666886ac20a478fc759c Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Thu, 18 Apr 2024 16:04:13 -0700 Subject: [PATCH 47/68] Fix JSON format errors Fixes some unintentional errors in formatting --- resources/index-map-missing-offset-column.js.map | 2 +- resources/index-map-missing-offset-line.js.map | 2 +- resources/index-map-offset-column-wrong-type.js.map | 2 +- resources/index-map-offset-line-wrong-type.js.map | 2 +- resources/index-map-wrong-type-offset.js.map | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/resources/index-map-missing-offset-column.js.map b/resources/index-map-missing-offset-column.js.map index 629b43d..aa48bbb 100644 --- a/resources/index-map-missing-offset-column.js.map +++ b/resources/index-map-missing-offset-column.js.map @@ -9,6 +9,6 @@ "sources": ["empty-original.js"], "mappings": "AAAA" } - }, + } ] } diff --git a/resources/index-map-missing-offset-line.js.map b/resources/index-map-missing-offset-line.js.map index 9ec4f3e..3d60444 100644 --- a/resources/index-map-missing-offset-line.js.map +++ b/resources/index-map-missing-offset-line.js.map @@ -9,6 +9,6 @@ "sources": ["empty-original.js"], "mappings": "AAAA" } - }, + } ] } diff --git a/resources/index-map-offset-column-wrong-type.js.map b/resources/index-map-offset-column-wrong-type.js.map index d8a599a..b43e79a 100644 --- a/resources/index-map-offset-column-wrong-type.js.map +++ b/resources/index-map-offset-column-wrong-type.js.map @@ -9,6 +9,6 @@ "sources": ["empty-original.js"], "mappings": "AAAA" } - }, + } ] } diff --git a/resources/index-map-offset-line-wrong-type.js.map b/resources/index-map-offset-line-wrong-type.js.map index faf2e50..81dbcd6 100644 --- a/resources/index-map-offset-line-wrong-type.js.map +++ b/resources/index-map-offset-line-wrong-type.js.map @@ -9,6 +9,6 @@ "sources": ["empty-original.js"], "mappings": "AAAA" } - }, + } ] } diff --git a/resources/index-map-wrong-type-offset.js.map b/resources/index-map-wrong-type-offset.js.map index 59f324d..fbc6e4e 100644 --- a/resources/index-map-wrong-type-offset.js.map +++ b/resources/index-map-wrong-type-offset.js.map @@ -2,7 +2,7 @@ "version": 3, "sections": [ { - offset: "not an offset", + "offset": "not an offset", "map": { "version": 3, "names": [], From b65ad328bb5d15d20cebb97ac6d15c0cb37a3dd0 Mon Sep 17 00:00:00 2001 From: Agata Belkius Date: Tue, 9 Apr 2024 23:40:35 +0100 Subject: [PATCH 48/68] add chrome test harness --- chrome/SourceMapSpec_test.ts | 109 ++ chrome/sourcemaps-tests-harness-chrome.patch | 1509 ++++++++++++++++++ 2 files changed, 1618 insertions(+) create mode 100644 chrome/SourceMapSpec_test.ts create mode 100644 chrome/sourcemaps-tests-harness-chrome.patch diff --git a/chrome/SourceMapSpec_test.ts b/chrome/SourceMapSpec_test.ts new file mode 100644 index 0000000..4c94a18 --- /dev/null +++ b/chrome/SourceMapSpec_test.ts @@ -0,0 +1,109 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +const {assert} = chai; + +import type * as Platform from '../../../../../front_end/core/platform/platform.js'; +import {assertNotNullOrUndefined} from '../../../../../front_end/core/platform/platform.js'; +import { SourceMapV3 } from '../../../../../front_end/core/sdk/SourceMap.js'; +import * as SDK from '../../../../../front_end/core/sdk/sdk.js'; +import {describeWithEnvironment} from '../../helpers/EnvironmentHelpers.js'; + +interface TestSpec { + name: string; + description: string; + baseFile: string; + sourceMapFile: string; + sourceMapIsValid: boolean; + testActions?: TestAction[]; +} + +interface TestAction { + actionType: string; + generatedLine: number; + generatedColumn: number; + originalSource: string; + originalLine: number; + originalColumn: number; + mappedName: null | string; +} + +const testCases = await loadTestCasesFromFixture('source-map-spec-tests.json'); + +describeWithEnvironment.only('SourceMapSpec', async () => { + console.log(testCases); + testCases.forEach(async ({ + baseFile, + sourceMapFile, + testActions, + sourceMapIsValid + }) => { + it('checks mappings', async () => { + if (!sourceMapIsValid) { + return; + } + + const baseFileUrl = baseFile as Platform.DevToolsPath.UrlString; + const sourceMapFileUrl = sourceMapFile as Platform.DevToolsPath.UrlString; + console.log(`loading sourcemap: ${sourceMapFile}`); + const sourceMapContent = await loadSourceMapFromFixture(sourceMapFile); + + const sourceMap = new SDK.SourceMap.SourceMap( + baseFileUrl, + sourceMapFileUrl, + sourceMapContent); + + + if (testActions !== undefined) { + testActions.forEach(({ + actionType, + originalSource, + originalLine, + originalColumn, + generatedLine, + generatedColumn + }) => { + if (actionType === "checkMapping" && sourceMapIsValid) { + const actual = sourceMap.findEntry(generatedLine, generatedColumn); + assertNotNullOrUndefined(actual); + + assert.strictEqual(actual.sourceURL, originalSource, 'unexpected source URL'); + assert.strictEqual(actual.sourceLineNumber, originalLine, 'unexpected source line number'); + assert.strictEqual(actual.sourceColumnNumber, originalColumn, 'unexpected source column number'); + } + }); + } + }); + }); +}); + +async function loadTestCasesFromFixture(filename: string): Promise { + console.log('!!!!loading test cases'); + const testSpec = await getFixtureFileContents<{ tests: TestSpec[] }>(filename); + return testSpec?.tests ?? []; +}; + +async function loadSourceMapFromFixture(filename: string): Promise { + return getFixtureFileContents(filename); +}; + +async function getFixtureFileContents(filename: string): + Promise { + + const url = new URL(`/fixtures/sourcemaps/${filename}`, window.location.origin); + + const response = await fetch(url); + + if (response.status !== 200) { + throw new Error(`Unable to load ${url}`); + } + + const contentType = response.headers.get('content-type'); + const isGzipEncoded = contentType !== null && contentType.includes('gzip'); + let buffer = await response.arrayBuffer(); + + const decoder = new TextDecoder('utf-8'); + const contents = JSON.parse(decoder.decode(buffer)) as T; + return contents; +} diff --git a/chrome/sourcemaps-tests-harness-chrome.patch b/chrome/sourcemaps-tests-harness-chrome.patch new file mode 100644 index 0000000..c0994a1 --- /dev/null +++ b/chrome/sourcemaps-tests-harness-chrome.patch @@ -0,0 +1,1509 @@ +diff --git a/test/e2e/sources/sourcemap_test.ts b/test/e2e/sources/sourcemap_test.ts +index 2db3bc0bab..a672132c18 100644 +--- a/test/e2e/sources/sourcemap_test.ts ++++ b/test/e2e/sources/sourcemap_test.ts +@@ -63,728 +63,788 @@ async function waitForTextContent(selector: string) { + const DEVTOOLS_LINK = '.toolbar-item .devtools-link'; + const INFOBAR_TEXT = '.infobar-info-text'; + +-describe('The Sources Tab', async function() { +- // Some of these tests that use instrumentation breakpoints +- // can be slower on mac and windows. Increase the timeout for them. +- if (this.timeout() !== 0) { +- this.timeout(10000); +- } +- +- it('steps over a source line mapping to a range with several statements', async () => { +- const {target, frontend} = getBrowserAndPages(); +- +- await openSourceCodeEditorForFile('sourcemap-stepping-source.js', 'sourcemap-stepping.html'); +- let scriptEvaluation: Promise; +- +- // DevTools is contracting long filenames with ellipses. +- // Let us match the location with regexp to match even contracted locations. +- const breakLocationRegExp = /.*source\.js:12$/; +- const stepLocationRegExp = /.*source\.js:13$/; +- +- await step('Run to breakpoint', async () => { +- await addBreakpointForLine(frontend, 12); +- +- scriptEvaluation = target.evaluate('singleline();'); +- +- const scriptLocation = await waitForStackTopMatch(breakLocationRegExp); +- assert.match(scriptLocation, breakLocationRegExp); +- }); +- +- await step('Step over the mapped line', async () => { +- await click(STEP_OVER_BUTTON); +- +- const stepLocation = await waitForStackTopMatch(stepLocationRegExp); +- assert.match(stepLocation, stepLocationRegExp); +- }); +- +- await step('Resume', async () => { +- await click(RESUME_BUTTON); +- await scriptEvaluation; +- }); +- }); +- +- it('steps over a source line with mappings to several adjacent target lines', async () => { +- const {target, frontend} = getBrowserAndPages(); +- await openSourceCodeEditorForFile('sourcemap-stepping-source.js', 'sourcemap-stepping.html'); +- +- let scriptEvaluation: Promise; +- +- // DevTools is contracting long filenames with ellipses. +- // Let us match the location with regexp to match even contracted locations. +- const breakLocationRegExp = /.*source\.js:4$/; +- const stepLocationRegExp = /.*source\.js:5$/; +- +- await step('Run to breakpoint', async () => { +- await addBreakpointForLine(frontend, 4); +- +- scriptEvaluation = target.evaluate('multiline();'); +- +- const scriptLocation = await waitForStackTopMatch(breakLocationRegExp); +- assert.match(scriptLocation, breakLocationRegExp); +- }); +- +- await step('Step over the mapped line', async () => { +- await click(STEP_OVER_BUTTON); +- +- const stepLocation = await waitForStackTopMatch(stepLocationRegExp); +- assert.match(stepLocation, stepLocationRegExp); +- }); +- +- await step('Resume', async () => { +- await click(RESUME_BUTTON); +- await scriptEvaluation; +- }); +- }); +- +- it('steps out from a function, with source maps available (crbug/1283188)', async () => { +- const {target, frontend} = getBrowserAndPages(); +- await openSourceCodeEditorForFile('sourcemap-stepping-source.js', 'sourcemap-stepping.html'); +- +- let scriptEvaluation: Promise; +- +- // DevTools is contracting long filenames with ellipses. +- // Let us match the location with regexp to match even contracted locations. +- const breakLocationRegExp = /.*source\.js:4$/; +- const stepLocationRegExp = /sourcemap-stepping.html:6$/; +- +- await step('Run to breakpoint', async () => { +- await addBreakpointForLine(frontend, 4); +- +- scriptEvaluation = target.evaluate('outer();'); +- +- const scriptLocation = await waitForStackTopMatch(breakLocationRegExp); +- assert.match(scriptLocation, breakLocationRegExp); +- }); +- +- await step('Step out from breakpoint', async () => { +- await click(STEP_OUT_BUTTON); +- +- const stepLocation = await waitForStackTopMatch(stepLocationRegExp); +- assert.match(stepLocation, stepLocationRegExp); +- }); +- +- await step('Resume', async () => { +- await click(RESUME_BUTTON); +- await scriptEvaluation; +- }); +- }); +- +- it('stepping works at the end of a sourcemapped script (crbug/1305956)', async () => { +- const {target} = getBrowserAndPages(); +- await openSourceCodeEditorForFile('sourcemap-stepping-at-end.js', 'sourcemap-stepping-at-end.html'); +- +- // DevTools is contracting long filenames with ellipses. +- // Let us match the location with regexp to match even contracted locations. +- const breakLocationRegExp = /.*at-end\.js:2$/; +- const stepLocationRegExp = /.*at-end.html:6$/; +- +- for (const [description, button] of [ +- ['into', STEP_INTO_BUTTON], +- ['out', STEP_OUT_BUTTON], +- ['over', STEP_OVER_BUTTON], +- ]) { +- let scriptEvaluation: Promise; +- await step('Run to debugger statement', async () => { +- scriptEvaluation = target.evaluate('outer();'); +- +- const scriptLocation = await waitForStackTopMatch(breakLocationRegExp); +- assert.match(scriptLocation, breakLocationRegExp); +- }); +- +- await step(`Step ${description} from debugger statement`, async () => { +- await click(button); +- +- const stepLocation = await waitForStackTopMatch(stepLocationRegExp); +- assert.match(stepLocation, stepLocationRegExp); +- }); +- +- await step('Resume', async () => { +- await click(RESUME_BUTTON); +- await scriptEvaluation; +- }); +- } +- }); +- +- it('shows unminified identifiers in scopes and console', async () => { +- const {target, frontend} = getBrowserAndPages(); +- await openSourceCodeEditorForFile('sourcemap-minified.js', 'sourcemap-minified.html'); +- +- let scriptEvaluation: Promise; +- const breakLocationRegExp = /sourcemap-minified\.js:1$/; +- +- await step('Run to debugger statement', async () => { +- scriptEvaluation = target.evaluate('sayHello(" world");'); +- +- const scriptLocation = await waitForStackTopMatch(breakLocationRegExp); +- assert.match(scriptLocation, breakLocationRegExp); +- }); +- +- await step('Check local variable is eventually un-minified', async () => { +- const unminifiedVariable = 'element: div'; +- await openSoftContextMenuAndClickOnItem('.cm-line', 'Add source map…'); +- +- // Enter the source map URL into the appropriate input box. +- await click('.add-source-map'); +- await typeText('sourcemap-minified.map'); +- await frontend.keyboard.press('Enter'); +- +- const scopeValues = await waitForFunction(async () => { +- const values = await getValuesForScope('Local', 0, 0); +- return (values && values.includes(unminifiedVariable)) ? values : undefined; +- }); +- assert.include(scopeValues, unminifiedVariable); +- }); +- +- await step('Check that expression evaluation understands unminified name', async () => { +- await frontend.evaluate(`(async () => { +- const Root = await import('./core/root/root.js'); +- Root.Runtime.experiments.setEnabled('evaluateExpressionsWithSourceMaps', true); +- })()`); +- +- await click(CONSOLE_TAB_SELECTOR); +- await focusConsolePrompt(); +- await pasteText('`Hello${text}!`'); +- await frontend.keyboard.press('Enter'); +- +- // Wait for the console to be usable again. +- await frontend.waitForFunction(() => { +- return document.querySelectorAll('.console-user-command-result').length === 1; +- }); +- const messages = await getCurrentConsoleMessages(); +- +- assert.deepEqual(messages, ['\'Hello world!\'']); +- +- await openSourcesPanel(); +- }); +- +- await step('Resume', async () => { +- await click(RESUME_BUTTON); +- await scriptEvaluation; +- }); +- }); +- +- it('shows unminified identifiers in scopes with minified names clash and nested scopes', async () => { +- const {target, frontend} = getBrowserAndPages(); +- await openSourceCodeEditorForFile('sourcemap-scopes-minified.js', 'sourcemap-scopes-minified.html'); +- +- let scriptEvaluation: Promise; +- const breakLocationOuterRegExp = /sourcemap-scopes-minified\.js:2$/; +- const breakLocationInnerRegExp = /sourcemap-scopes-minified\.js:5$/; +- +- const outerUnminifiedVariable = 'arg0: 10'; +- const innerUnminifiedVariable = 'loop_var: 0'; +- +- await step('Run to outer scope breakpoint', async () => { +- await addBreakpointForLine(frontend, 2); ++// describe('The Sources Tab', async function() { ++// // Some of these tests that use instrumentation breakpoints ++// // can be slower on mac and windows. Increase the timeout for them. ++// if (this.timeout() !== 0) { ++// this.timeout(10000); ++// } + +- scriptEvaluation = target.evaluate('foo(10);'); ++// it('steps over a source line mapping to a range with several statements', async () => { ++// const {target, frontend} = getBrowserAndPages(); + +- const scriptLocation = await waitForStackTopMatch(breakLocationOuterRegExp); +- assert.match(scriptLocation, breakLocationOuterRegExp); +- }); +- +- await step('Check local scope variable is eventually un-minified', async () => { +- const scopeValues = await waitForFunction(async () => { +- const values = await getValuesForScope('Local', 0, 0); +- return (values && values.includes(outerUnminifiedVariable)) ? values : undefined; +- }); +- assert.include(scopeValues, outerUnminifiedVariable); +- }); +- +- await step('Resume from outer breakpoint', async () => { +- await addBreakpointForLine(frontend, 5); +- await click(RESUME_BUTTON); +- const scriptLocation = await waitForStackTopMatch(breakLocationInnerRegExp); +- assert.match(scriptLocation, breakLocationInnerRegExp); +- }); +- +- await step('Check local and block scope variables are eventually un-minified', async () => { +- const blockScopeValues = await waitForFunction(async () => { +- const values = await getValuesForScope('Block', 0, 0); +- return (values && values.includes(innerUnminifiedVariable)) ? values : undefined; +- }); +- assert.include(blockScopeValues, innerUnminifiedVariable); +- +- const scopeValues = await waitForFunction(async () => { +- const values = await getValuesForScope('Local', 0, 0); +- return (values && values.includes(outerUnminifiedVariable)) ? values : undefined; +- }); +- assert.include(scopeValues, outerUnminifiedVariable); +- }); +- +- await step('Resume from inner breakpoint', async () => { +- await removeBreakpointForLine(frontend, 2); +- await removeBreakpointForLine(frontend, 5); +- await click(RESUME_BUTTON); +- await scriptEvaluation; +- }); +- }); +- +- it('shows unminified function name in stack trace', async () => { +- const {target, frontend} = getBrowserAndPages(); +- await openSourceCodeEditorForFile( +- 'sourcemap-minified-function-name-compiled.js', 'sourcemap-minified-function-name.html'); ++// await openSourceCodeEditorForFile('sourcemap-stepping-source.js', 'sourcemap-stepping.html'); ++// let scriptEvaluation: Promise; + +- let scriptEvaluation: Promise; +- const breakLocationOuterRegExp = /sourcemap-.*-compiled\.js:1$/; ++// // DevTools is contracting long filenames with ellipses. ++// // Let us match the location with regexp to match even contracted locations. ++// const breakLocationRegExp = /.*source\.js:12$/; ++// const stepLocationRegExp = /.*source\.js:13$/; + +- await step('Run to breakpoint', async () => { +- scriptEvaluation = target.evaluate('o(1, 2)'); ++// await step('Run to breakpoint', async () => { ++// await addBreakpointForLine(frontend, 12); + +- const scriptLocation = await waitForStackTopMatch(breakLocationOuterRegExp); +- assert.match(scriptLocation, breakLocationOuterRegExp); +- }); +- +- await step('Add source map', async () => { +- await openSoftContextMenuAndClickOnItem('.cm-line', 'Add source map…'); ++// scriptEvaluation = target.evaluate('singleline();'); + +- // Enter the source map URL into the appropriate input box. +- await click('.add-source-map'); +- await typeText('sourcemap-minified-function-name-compiled.map'); +- await frontend.keyboard.press('Enter'); +- }); ++// const scriptLocation = await waitForStackTopMatch(breakLocationRegExp); ++// assert.match(scriptLocation, breakLocationRegExp); ++// }); + +- await step('Check function name is eventually un-minified', async () => { +- const functionName = await waitForFunction(async () => { +- const functionName = await waitForTextContent('.call-frame-title-text'); +- return functionName && functionName === 'unminified' ? functionName : undefined; +- }); +- assert.strictEqual(functionName, 'unminified'); +- }); ++// await step('Step over the mapped line', async () => { ++// await click(STEP_OVER_BUTTON); + +- await step('Resume execution', async () => { +- await click(RESUME_BUTTON); +- await scriptEvaluation; +- }); +- }); ++// const stepLocation = await waitForStackTopMatch(stepLocationRegExp); ++// assert.match(stepLocation, stepLocationRegExp); ++// }); + +- // TODO(crbug.com/1346228) Flaky - timeouts. +- it.skip('[crbug.com/1346228] automatically ignore-lists third party code from source maps', async function() { +- const {target} = getBrowserAndPages(); +- await openSourceCodeEditorForFile('webpack-main.js', 'webpack-index.html'); ++// await step('Resume', async () => { ++// await click(RESUME_BUTTON); ++// await scriptEvaluation; ++// }); ++// }); ++ ++// it('steps over a source line with mappings to several adjacent target lines', async () => { ++// const {target, frontend} = getBrowserAndPages(); ++// await openSourceCodeEditorForFile('sourcemap-stepping-source.js', 'sourcemap-stepping.html'); ++ ++// let scriptEvaluation: Promise; + +- let scriptEvaluation: Promise; +- const breakLocationOuterRegExp = /index\.js:12$/; ++// // DevTools is contracting long filenames with ellipses. ++// // Let us match the location with regexp to match even contracted locations. ++// const breakLocationRegExp = /.*source\.js:4$/; ++// const stepLocationRegExp = /.*source\.js:5$/; + +- await step('Run to breakpoint', async () => { +- scriptEvaluation = target.evaluate('window.foo()'); ++// await step('Run to breakpoint', async () => { ++// await addBreakpointForLine(frontend, 4); + +- const scriptLocation = await waitForStackTopMatch(breakLocationOuterRegExp); +- assert.match(scriptLocation, breakLocationOuterRegExp); +- assert.deepEqual(await getCallFrameNames(), ['baz', 'bar', 'foo', '(anonymous)']); +- }); ++// scriptEvaluation = target.evaluate('multiline();'); + +- await step('Toggle to show ignore-listed frames', async () => { +- await click('.ignore-listed-message-label'); +- await waitFor('.ignore-listed-call-frame:not(.hidden)'); +- assert.deepEqual(await getCallFrameNames(), ['baz', 'vendor', 'bar', 'foo', '(anonymous)']); +- }); ++// const scriptLocation = await waitForStackTopMatch(breakLocationRegExp); ++// assert.match(scriptLocation, breakLocationRegExp); ++// }); + +- await step('Toggle back off', async () => { +- await click('.ignore-listed-message-label'); +- await waitFor('.ignore-listed-call-frame.hidden'); +- assert.deepEqual(await getCallFrameNames(), ['baz', 'bar', 'foo', '(anonymous)']); +- }); ++// await step('Step over the mapped line', async () => { ++// await click(STEP_OVER_BUTTON); + +- await step('Resume execution', async () => { +- await click(RESUME_BUTTON); +- await scriptEvaluation; +- }); +- }); ++// const stepLocation = await waitForStackTopMatch(stepLocationRegExp); ++// assert.match(stepLocation, stepLocationRegExp); ++// }); + +- it('updates decorators for removed breakpoints in case of code-splitting (crbug.com/1251675)', async () => { +- const {frontend} = getBrowserAndPages(); +- await openSourceCodeEditorForFile('sourcemap-disjoint.js', 'sourcemap-disjoint.html'); +- assert.deepEqual(await getBreakpointDecorators(), []); +- await addBreakpointForLine(frontend, 2); +- assert.deepEqual(await getBreakpointDecorators(), [2]); +- await removeBreakpointForLine(frontend, 2); +- assert.deepEqual(await getBreakpointDecorators(), []); +- }); +- +- it('reliably hits breakpoints on worker with source map', async () => { +- await enableExperiment('instrumentationBreakpoints'); +- const {target, frontend} = getBrowserAndPages(); +- await openSourceCodeEditorForFile('sourcemap-stepping-source.js', 'sourcemap-breakpoint.html'); +- +- await step('Add a breakpoint at first line of function multiline', async () => { +- await addBreakpointForLine(frontend, 4); +- }); +- +- await step('Navigate to a different site to refresh devtools and remove back-end state', async () => { +- await refreshDevToolsAndRemoveBackendState(target); +- }); +- +- await step('Navigate back to test page', () => { +- void goToResource('sources/sourcemap-breakpoint.html'); +- }); +- +- await step('wait for pause and check if we stopped at line 4', async () => { +- await waitFor(PAUSE_INDICATOR_SELECTOR); +- await waitForFunction(async () => { +- const topCallFrame = await retrieveTopCallFrameWithoutResuming(); +- return topCallFrame === 'sourcemap-stepping-source.js:4'; +- }); +- }); +- +- await step('Resume', async () => { +- await click(RESUME_BUTTON); +- }); +- }); +- +- it('links to the correct origins for source-mapped resources', async () => { +- await goToResource('sources/sourcemap-origin.html'); +- await openSourcesPanel(); +- +- await step('Check origin of source-mapped JavaScript', async () => { +- await openFileInEditor('sourcemap-origin.js'); +- const linkText = await waitForTextContent(DEVTOOLS_LINK); +- assert.strictEqual(linkText, 'sourcemap-origin.min.js'); +- }); +- +- await step('Check origin of source-mapped SASS', async () => { +- await openFileInEditor('sourcemap-origin.scss'); +- const linkText = await waitForTextContent(DEVTOOLS_LINK); +- assert.strictEqual(linkText, 'sourcemap-origin.css'); +- }); +- +- await step('Check origin of source-mapped JavaScript with URL clash', async () => { +- await openFileInEditor('sourcemap-origin.clash.js'); +- const linkText = await waitForTextContent(DEVTOOLS_LINK); +- assert.strictEqual(linkText, 'sourcemap-origin.clash.js'); +- }); +- }); +- +- it('shows Source map loaded infobar', async () => { +- await goToResource('sources/sourcemap-origin.html'); +- await openSourcesPanel(); +- +- await step('Get infobar text', async () => { +- await openFileInEditor('sourcemap-origin.min.js'); +- const infobarText = await waitForTextContent(INFOBAR_TEXT); +- assert.strictEqual(infobarText, 'Source map loaded.'); +- }); +- }); +- +- it('shows Source map loaded infobar after attaching', async () => { +- const {frontend} = getBrowserAndPages(); +- await openSourceCodeEditorForFile('sourcemap-minified.js', 'sourcemap-minified.html'); +- +- await step('Attach source map', async () => { +- await openSoftContextMenuAndClickOnItem('.cm-line', 'Add source map…'); +- +- // Enter the source map URL into the appropriate input box. +- await click('.add-source-map'); +- await typeText('sourcemap-minified.map'); +- await frontend.keyboard.press('Enter'); +- }); +- +- await step('Get infobar text', async () => { +- const infobarText = await waitForTextContent(INFOBAR_TEXT); +- assert.strictEqual(infobarText, 'Source map loaded.'); +- }); +- }); +- +- it('shows Source map skipped infobar', async () => { +- await setIgnoreListPattern('.min.js'); +- await openSourceCodeEditorForFile('sourcemap-origin.min.js', 'sourcemap-origin.html'); +- +- await step('Get infobar texts', async () => { +- await openFileInEditor('sourcemap-origin.min.js'); +- await waitFor('.infobar-warning'); +- await waitFor('.infobar-info'); +- const infobarTexts = await getVisibleTextContents(INFOBAR_TEXT); +- assert.deepEqual( +- infobarTexts, ['This script is on the debugger\'s ignore list', 'Source map skipped for this file.']); +- }); +- }); +- +- it('shows Source map error infobar after failing to attach', async () => { +- const {frontend} = getBrowserAndPages(); +- await openSourceCodeEditorForFile('sourcemap-minified.js', 'sourcemap-minified.html'); +- +- await step('Attach source map', async () => { +- await openSoftContextMenuAndClickOnItem('.cm-line', 'Add source map…'); +- +- // Enter the source map URL into the appropriate input box. +- await click('.add-source-map'); +- await typeText('sourcemap-invalid.map'); +- await frontend.keyboard.press('Enter'); +- }); +- +- await step('Get infobar text', async () => { +- const infobarText = await waitForTextContent(INFOBAR_TEXT); +- assert.strictEqual(infobarText, 'Source map failed to load.'); +- }); +- }); +- +- describe('can deal with code-splitting', () => { +- it('sets multiple breakpoints in case of code-splitting', async () => { +- const {target, frontend} = getBrowserAndPages(); +- await openSourceCodeEditorForFile('sourcemap-codesplit.ts', 'sourcemap-codesplit.html'); +- await addBreakpointForLine(frontend, 3); +- +- for (let i = 0; i < 2; ++i) { +- const scriptLocation = await retrieveTopCallFrameScriptLocation(`functions[${i}]();`, target); +- assert.deepEqual(scriptLocation, 'sourcemap-codesplit.ts:3'); +- } +- }); +- +- it('restores breakpoints correctly in case of code-splitting (crbug.com/1412033)', async () => { +- const {target, frontend} = getBrowserAndPages(); +- +- // Load the initial setup with only one script pointing to `codesplitting-bar.ts`... +- await openSourceCodeEditorForFile('codesplitting-bar.ts', 'codesplitting.html'); +- +- // ...and set a breakpoint inside `bar()`. +- await addBreakpointForLine(frontend, 2); +- +- // Now load the second script pointing to `codesplitting-bar.ts`... +- await target.evaluate('addSecond();'); +- +- // ...wait for the new origin to be listed... +- const linkTexts = await waitForFunction(async () => { +- const links = await $$(DEVTOOLS_LINK); +- const linkTexts = await Promise.all(links.map(node => node.evaluate(({textContent}) => textContent))); +- if (linkTexts.length === 1 && linkTexts[0] === 'codesplitting-first.js') { +- return undefined; +- } +- return linkTexts; +- }); +- assert.sameMembers(linkTexts, ['codesplitting-first.js', 'codesplitting-second.js']); +- +- // ...and eventually wait for the breakpoint to be restored in line 2. +- await waitForFunction(async () => await isBreakpointSet(2)); +- +- // Eventually we should stop on the breakpoint in the `codesplitting-second.js`. +- await waitForFunction(() => { +- return Promise.race([ +- target.evaluate('second()').then(() => false), +- waitFor(PAUSE_INDICATOR_SELECTOR).then(() => true), +- ]); +- }); +- await click(RESUME_BUTTON); +- }); +- +- it('hits breakpoints reliably after reload in case of code-splitting (crbug.com/1490369)', async () => { +- const {target, frontend} = getBrowserAndPages(); +- +- // Set the breakpoint inside `shared()` in `shared.js`. +- await openSourceCodeEditorForFile('shared.js', 'codesplitting-race.html'); +- await addBreakpointForLine(frontend, 2); +- await waitForFunction(async () => await isBreakpointSet(2)); +- +- // Reload the page. +- const reloadPromise = target.reload(); +- +- // Now the debugger should pause twice reliably. +- await waitFor(PAUSE_INDICATOR_SELECTOR); +- await click(RESUME_BUTTON); +- await waitFor(PAUSE_INDICATOR_SELECTOR); +- await click(RESUME_BUTTON); +- +- await reloadPromise; +- }); +- }); +- +- describe('can deal with hot module replacement', () => { +- // The tests in here simulate Hot Module Replacement (HMR) workflows related +- // to how DevTools deals with source maps in these situations. +- +- it('correctly handles URL clashes between compiled and source-mapped scripts', async () => { +- const {target} = getBrowserAndPages(); +- +- // Load the "initial bundle"... +- await openSourceCodeEditorForFile('index.js', 'sourcemap-hmr.html'); +- +- // ...and check that index.js content is as expected. +- // In particular, this asserts that the front-end does not get creative in +- // appending suffixes like '? [sm]' to the index.js here. +- const initialContent = await retrieveCodeMirrorEditorContent(); +- assert.deepEqual(initialContent, [ +- 'globalThis.hello = () => {', +- ' console.log("Hello world!");', +- '}', +- '', +- ]); +- +- // Simulate the hot module replacement for index.js... +- await target.evaluate('update();'); +- +- // ...and wait for its content to load (should just replace +- // the existing tab contents for index.js). We perform this +- // check by waiting until the editor contents differ from +- // the initial contents, and then asserting that it looks +- // as expected afterwards. +- const updatedContent = await waitForFunction(async () => { +- const content = await retrieveCodeMirrorEditorContent(); +- if (content.length !== initialContent.length) { +- return content; +- } +- for (let i = 0; i < content.length; ++i) { +- if (content[i] !== initialContent[i]) { +- return content; +- } +- } +- return undefined; +- }); +- assert.deepEqual(updatedContent, [ +- 'globalThis.hello = () => {', +- ' console.log("Hello UPDATED world!");', +- '}', +- '', +- ]); +- }); +- +- it('correctly maintains breakpoints from initial bundle to replacement', async () => { +- const {target, frontend} = getBrowserAndPages(); +- +- // Load the "initial bundle" and set a breakpoint on the second line. +- await openSourceCodeEditorForFile('index.js', 'sourcemap-hmr.html'); +- await addBreakpointForLine(frontend, 2); +- +- // Simulate the hot module replacement for index.js +- await target.evaluate('update();'); +- +- // Wait for the "hot module replacement" to take effect for index.js. +- await waitForFunction(async () => { +- const content = await retrieveCodeMirrorEditorContent(); +- return content[1].includes('UPDATED'); +- }); +- +- // Wait for the breakpoint to appear on line 2 of the updated index.js. +- await waitForFunction(async () => await isBreakpointSet(2)); +- }); +- +- it('correctly maintains breakpoints from replacement to initial bundle (across reloads)', async () => { +- const {target, frontend} = getBrowserAndPages(); +- +- // Load the "initial bundle". +- await openSourceCodeEditorForFile('index.js', 'sourcemap-hmr.html'); +- +- // Simulate the hot module replacement for index.js +- await target.evaluate('update();'); +- +- // Wait for the "hot module replacement" to take effect for index.js. +- await waitForFunction(async () => { +- const content = await retrieveCodeMirrorEditorContent(); +- return content[1].includes('UPDATED'); +- }); +- +- // Set a breakpoint on the second line. +- await addBreakpointForLine(frontend, 2); +- +- // Reload the page and re-open (the initial) index.js. +- await reloadPageAndWaitForSourceFile(target, 'index.js'); +- +- // Check that the breakpoint still exists on line 2. +- assert.isTrue(await isBreakpointSet(2)); +- }); +- }); +- +- it('can attach sourcemaps to CSS files from a context menu', async () => { +- await openSourceCodeEditorForFile('sourcemap-css.css', 'sourcemap-css-noinline.html'); +- +- await click('aria/Code editor', {clickOptions: {button: 'right'}}); +- await click('aria/Add source map…'); +- await waitFor('.add-source-map'); +- await typeText('sourcemap-css-absolute.map'); +- await pressKey('Enter'); +- +- await waitFor('[aria-label="app.scss, file"]'); +- }); +-}); +- +-describe('The Elements Tab', async () => { +- async function clickStyleValueWithModifiers(selector: string, name: string, value: string, location: string) { +- const element = await waitForCSSPropertyValue(selector, name, value, location); +- // Click with offset to skip swatches. +- await withControlOrMetaKey(() => clickElement(element, {clickOptions: {offset: {x: 20, y: 5}}})); +- } +- +- it('links to the right SASS source for inline CSS with relative sourcemap (crbug.com/787792)', async () => { +- await goToResource('sources/sourcemap-css-inline-relative.html'); +- await step('Prepare elements tab', async () => { +- await waitForElementsStyleSection(); +- await waitForContentOfSelectedElementsNode('\u200B'); +- await focusElementsTree(); +- await clickNthChildOfSelectedElementNode(1); +- }); +- await clickStyleValueWithModifiers('body .text', 'color', 'green', 'app.scss:6'); +- await waitForElementWithTextContent('Line 12, Column 9'); +- }); +- +- it('links to the right SASS source for inline CSS with absolute sourcemap (crbug.com/787792)', async () => { +- await goToResource('sources/sourcemap-css-dynamic-link.html'); +- await step('Prepare elements tab', async () => { +- await waitForElementsStyleSection(); +- await waitForContentOfSelectedElementsNode('\u200B'); +- await focusElementsTree(); +- await clickNthChildOfSelectedElementNode(1); +- }); +- await clickStyleValueWithModifiers('body .text', 'color', 'green', 'app.scss:6'); +- await waitForElementWithTextContent('Line 12, Column 9'); +- }); +- +- it('links to the right SASS source for dynamically added CSS style tags (crbug.com/787792)', async () => { +- await goToResource('sources/sourcemap-css-dynamic.html'); +- await step('Prepare elements tab', async () => { +- await waitForElementsStyleSection(); +- await waitForContentOfSelectedElementsNode('\u200B'); +- await focusElementsTree(); +- await clickNthChildOfSelectedElementNode(1); +- }); +- await clickStyleValueWithModifiers('body .text', 'color', 'green', 'app.scss:6'); +- await waitForElementWithTextContent('Line 12, Column 9'); +- }); +- +- it('links to the right SASS source for dynamically added CSS link tags (crbug.com/787792)', async () => { +- await goToResource('sources/sourcemap-css-dynamic-link.html'); +- await step('Prepare elements tab', async () => { +- await waitForElementsStyleSection(); +- await waitForContentOfSelectedElementsNode('\u200B'); +- await focusElementsTree(); +- await clickNthChildOfSelectedElementNode(1); +- }); +- await clickStyleValueWithModifiers('body .text', 'color', 'green', 'app.scss:6'); +- await waitForElementWithTextContent('Line 12, Column 9'); +- }); +-}); ++// await step('Resume', async () => { ++// await click(RESUME_BUTTON); ++// await scriptEvaluation; ++// }); ++// }); ++ ++// it('steps out from a function, with source maps available (crbug/1283188)', async () => { ++// const {target, frontend} = getBrowserAndPages(); ++// await openSourceCodeEditorForFile('sourcemap-stepping-source.js', 'sourcemap-stepping.html'); ++ ++// let scriptEvaluation: Promise; ++ ++// // DevTools is contracting long filenames with ellipses. ++// // Let us match the location with regexp to match even contracted locations. ++// const breakLocationRegExp = /.*source\.js:4$/; ++// const stepLocationRegExp = /sourcemap-stepping.html:6$/; ++ ++// await step('Run to breakpoint', async () => { ++// await addBreakpointForLine(frontend, 4); ++ ++// scriptEvaluation = target.evaluate('outer();'); ++ ++// const scriptLocation = await waitForStackTopMatch(breakLocationRegExp); ++// assert.match(scriptLocation, breakLocationRegExp); ++// }); ++ ++// await step('Step out from breakpoint', async () => { ++// await click(STEP_OUT_BUTTON); ++ ++// const stepLocation = await waitForStackTopMatch(stepLocationRegExp); ++// assert.match(stepLocation, stepLocationRegExp); ++// }); ++ ++// await step('Resume', async () => { ++// await click(RESUME_BUTTON); ++// await scriptEvaluation; ++// }); ++// }); ++ ++// it('stepping works at the end of a sourcemapped script (crbug/1305956)', async () => { ++// const {target} = getBrowserAndPages(); ++// await openSourceCodeEditorForFile('sourcemap-stepping-at-end.js', 'sourcemap-stepping-at-end.html'); ++ ++// // DevTools is contracting long filenames with ellipses. ++// // Let us match the location with regexp to match even contracted locations. ++// const breakLocationRegExp = /.*at-end\.js:2$/; ++// const stepLocationRegExp = /.*at-end.html:6$/; ++ ++// for (const [description, button] of [ ++// ['into', STEP_INTO_BUTTON], ++// ['out', STEP_OUT_BUTTON], ++// ['over', STEP_OVER_BUTTON], ++// ]) { ++// let scriptEvaluation: Promise; ++// await step('Run to debugger statement', async () => { ++// scriptEvaluation = target.evaluate('outer();'); ++ ++// const scriptLocation = await waitForStackTopMatch(breakLocationRegExp); ++// assert.match(scriptLocation, breakLocationRegExp); ++// }); ++ ++// await step(`Step ${description} from debugger statement`, async () => { ++// await click(button); ++ ++// const stepLocation = await waitForStackTopMatch(stepLocationRegExp); ++// assert.match(stepLocation, stepLocationRegExp); ++// }); ++ ++// await step('Resume', async () => { ++// await click(RESUME_BUTTON); ++// await scriptEvaluation; ++// }); ++// } ++// }); ++ ++// it('shows unminified identifiers in scopes and console', async () => { ++// const {target, frontend} = getBrowserAndPages(); ++// await openSourceCodeEditorForFile('sourcemap-minified.js', 'sourcemap-minified.html'); ++ ++// let scriptEvaluation: Promise; ++// const breakLocationRegExp = /sourcemap-minified\.js:1$/; ++ ++// await step('Run to debugger statement', async () => { ++// scriptEvaluation = target.evaluate('sayHello(" world");'); ++ ++// const scriptLocation = await waitForStackTopMatch(breakLocationRegExp); ++// assert.match(scriptLocation, breakLocationRegExp); ++// }); ++ ++// await step('Check local variable is eventually un-minified', async () => { ++// const unminifiedVariable = 'element: div'; ++// await openSoftContextMenuAndClickOnItem('.cm-line', 'Add source map…'); ++ ++// // Enter the source map URL into the appropriate input box. ++// await click('.add-source-map'); ++// await typeText('sourcemap-minified.map'); ++// await frontend.keyboard.press('Enter'); ++ ++// const scopeValues = await waitForFunction(async () => { ++// const values = await getValuesForScope('Local', 0, 0); ++// return (values && values.includes(unminifiedVariable)) ? values : undefined; ++// }); ++// assert.include(scopeValues, unminifiedVariable); ++// }); ++ ++// await step('Check that expression evaluation understands unminified name', async () => { ++// await frontend.evaluate(`(async () => { ++// const Root = await import('./core/root/root.js'); ++// Root.Runtime.experiments.setEnabled('evaluateExpressionsWithSourceMaps', true); ++// })()`); ++ ++// await click(CONSOLE_TAB_SELECTOR); ++// await focusConsolePrompt(); ++// await pasteText('`Hello${text}!`'); ++// await frontend.keyboard.press('Enter'); ++ ++// // Wait for the console to be usable again. ++// await frontend.waitForFunction(() => { ++// return document.querySelectorAll('.console-user-command-result').length === 1; ++// }); ++// const messages = await getCurrentConsoleMessages(); ++ ++// assert.deepEqual(messages, ['\'Hello world!\'']); ++ ++// await openSourcesPanel(); ++// }); ++ ++// await step('Resume', async () => { ++// await click(RESUME_BUTTON); ++// await scriptEvaluation; ++// }); ++// }); ++ ++// it('shows unminified identifiers in scopes with minified names clash and nested scopes', async () => { ++// const {target, frontend} = getBrowserAndPages(); ++// await openSourceCodeEditorForFile('sourcemap-scopes-minified.js', 'sourcemap-scopes-minified.html'); ++ ++// let scriptEvaluation: Promise; ++// const breakLocationOuterRegExp = /sourcemap-scopes-minified\.js:2$/; ++// const breakLocationInnerRegExp = /sourcemap-scopes-minified\.js:5$/; ++ ++// const outerUnminifiedVariable = 'arg0: 10'; ++// const innerUnminifiedVariable = 'loop_var: 0'; ++ ++// await step('Run to outer scope breakpoint', async () => { ++// await addBreakpointForLine(frontend, 2); ++ ++// scriptEvaluation = target.evaluate('foo(10);'); ++ ++// const scriptLocation = await waitForStackTopMatch(breakLocationOuterRegExp); ++// assert.match(scriptLocation, breakLocationOuterRegExp); ++// }); ++ ++// await step('Check local scope variable is eventually un-minified', async () => { ++// const scopeValues = await waitForFunction(async () => { ++// const values = await getValuesForScope('Local', 0, 0); ++// return (values && values.includes(outerUnminifiedVariable)) ? values : undefined; ++// }); ++// assert.include(scopeValues, outerUnminifiedVariable); ++// }); ++ ++// await step('Resume from outer breakpoint', async () => { ++// await addBreakpointForLine(frontend, 5); ++// await click(RESUME_BUTTON); ++// const scriptLocation = await waitForStackTopMatch(breakLocationInnerRegExp); ++// assert.match(scriptLocation, breakLocationInnerRegExp); ++// }); ++ ++// await step('Check local and block scope variables are eventually un-minified', async () => { ++// const blockScopeValues = await waitForFunction(async () => { ++// const values = await getValuesForScope('Block', 0, 0); ++// return (values && values.includes(innerUnminifiedVariable)) ? values : undefined; ++// }); ++// assert.include(blockScopeValues, innerUnminifiedVariable); ++ ++// const scopeValues = await waitForFunction(async () => { ++// const values = await getValuesForScope('Local', 0, 0); ++// return (values && values.includes(outerUnminifiedVariable)) ? values : undefined; ++// }); ++// assert.include(scopeValues, outerUnminifiedVariable); ++// }); ++ ++// await step('Resume from inner breakpoint', async () => { ++// await removeBreakpointForLine(frontend, 2); ++// await removeBreakpointForLine(frontend, 5); ++// await click(RESUME_BUTTON); ++// await scriptEvaluation; ++// }); ++// }); ++ ++// it('shows unminified function name in stack trace', async () => { ++// const {target, frontend} = getBrowserAndPages(); ++// await openSourceCodeEditorForFile( ++// 'sourcemap-minified-function-name-compiled.js', 'sourcemap-minified-function-name.html'); ++ ++// let scriptEvaluation: Promise; ++// const breakLocationOuterRegExp = /sourcemap-.*-compiled\.js:1$/; ++ ++// await step('Run to breakpoint', async () => { ++// scriptEvaluation = target.evaluate('o(1, 2)'); ++ ++// const scriptLocation = await waitForStackTopMatch(breakLocationOuterRegExp); ++// assert.match(scriptLocation, breakLocationOuterRegExp); ++// }); ++ ++// await step('Add source map', async () => { ++// await openSoftContextMenuAndClickOnItem('.cm-line', 'Add source map…'); ++ ++// // Enter the source map URL into the appropriate input box. ++// await click('.add-source-map'); ++// await typeText('sourcemap-minified-function-name-compiled.map'); ++// await frontend.keyboard.press('Enter'); ++// }); ++ ++// await step('Check function name is eventually un-minified', async () => { ++// const functionName = await waitForFunction(async () => { ++// const functionName = await waitForTextContent('.call-frame-title-text'); ++// return functionName && functionName === 'unminified' ? functionName : undefined; ++// }); ++// assert.strictEqual(functionName, 'unminified'); ++// }); ++ ++// await step('Resume execution', async () => { ++// await click(RESUME_BUTTON); ++// await scriptEvaluation; ++// }); ++// }); ++ ++// // TODO(crbug.com/1346228) Flaky - timeouts. ++// it.skip('[crbug.com/1346228] automatically ignore-lists third party code from source maps', async function() { ++// const {target} = getBrowserAndPages(); ++// await openSourceCodeEditorForFile('webpack-main.js', 'webpack-index.html'); ++ ++// let scriptEvaluation: Promise; ++// const breakLocationOuterRegExp = /index\.js:12$/; ++ ++// await step('Run to breakpoint', async () => { ++// scriptEvaluation = target.evaluate('window.foo()'); ++ ++// const scriptLocation = await waitForStackTopMatch(breakLocationOuterRegExp); ++// assert.match(scriptLocation, breakLocationOuterRegExp); ++// assert.deepEqual(await getCallFrameNames(), ['baz', 'bar', 'foo', '(anonymous)']); ++// }); ++ ++// await step('Toggle to show ignore-listed frames', async () => { ++// await click('.ignore-listed-message-label'); ++// await waitFor('.ignore-listed-call-frame:not(.hidden)'); ++// assert.deepEqual(await getCallFrameNames(), ['baz', 'vendor', 'bar', 'foo', '(anonymous)']); ++// }); ++ ++// await step('Toggle back off', async () => { ++// await click('.ignore-listed-message-label'); ++// await waitFor('.ignore-listed-call-frame.hidden'); ++// assert.deepEqual(await getCallFrameNames(), ['baz', 'bar', 'foo', '(anonymous)']); ++// }); ++ ++// await step('Resume execution', async () => { ++// await click(RESUME_BUTTON); ++// await scriptEvaluation; ++// }); ++// }); ++ ++// it('updates decorators for removed breakpoints in case of code-splitting (crbug.com/1251675)', async () => { ++// const {frontend} = getBrowserAndPages(); ++// await openSourceCodeEditorForFile('sourcemap-disjoint.js', 'sourcemap-disjoint.html'); ++// assert.deepEqual(await getBreakpointDecorators(), []); ++// await addBreakpointForLine(frontend, 2); ++// assert.deepEqual(await getBreakpointDecorators(), [2]); ++// await removeBreakpointForLine(frontend, 2); ++// assert.deepEqual(await getBreakpointDecorators(), []); ++// }); ++ ++// it('reliably hits breakpoints on worker with source map', async () => { ++// await enableExperiment('instrumentationBreakpoints'); ++// const {target, frontend} = getBrowserAndPages(); ++// await openSourceCodeEditorForFile('sourcemap-stepping-source.js', 'sourcemap-breakpoint.html'); ++ ++// await step('Add a breakpoint at first line of function multiline', async () => { ++// await addBreakpointForLine(frontend, 4); ++// }); ++ ++// await step('Navigate to a different site to refresh devtools and remove back-end state', async () => { ++// await refreshDevToolsAndRemoveBackendState(target); ++// }); ++ ++// await step('Navigate back to test page', () => { ++// void goToResource('sources/sourcemap-breakpoint.html'); ++// }); ++ ++// await step('wait for pause and check if we stopped at line 4', async () => { ++// await waitFor(PAUSE_INDICATOR_SELECTOR); ++// await waitForFunction(async () => { ++// const topCallFrame = await retrieveTopCallFrameWithoutResuming(); ++// return topCallFrame === 'sourcemap-stepping-source.js:4'; ++// }); ++// }); ++ ++// await step('Resume', async () => { ++// await click(RESUME_BUTTON); ++// }); ++// }); ++ ++// it('links to the correct origins for source-mapped resources', async () => { ++// await goToResource('sources/sourcemap-origin.html'); ++// await openSourcesPanel(); ++ ++// await step('Check origin of source-mapped JavaScript', async () => { ++// await openFileInEditor('sourcemap-origin.js'); ++// const linkText = await waitForTextContent(DEVTOOLS_LINK); ++// assert.strictEqual(linkText, 'sourcemap-origin.min.js'); ++// }); ++ ++// await step('Check origin of source-mapped SASS', async () => { ++// await openFileInEditor('sourcemap-origin.scss'); ++// const linkText = await waitForTextContent(DEVTOOLS_LINK); ++// assert.strictEqual(linkText, 'sourcemap-origin.css'); ++// }); ++ ++// await step('Check origin of source-mapped JavaScript with URL clash', async () => { ++// await openFileInEditor('sourcemap-origin.clash.js'); ++// const linkText = await waitForTextContent(DEVTOOLS_LINK); ++// assert.strictEqual(linkText, 'sourcemap-origin.clash.js'); ++// }); ++// }); ++ ++// it('shows Source map loaded infobar', async () => { ++// await goToResource('sources/sourcemap-origin.html'); ++// await openSourcesPanel(); ++ ++// await step('Get infobar text', async () => { ++// await openFileInEditor('sourcemap-origin.min.js'); ++// const infobarText = await waitForTextContent(INFOBAR_TEXT); ++// assert.strictEqual(infobarText, 'Source map loaded.'); ++// }); ++// }); ++ ++// it('shows Source map loaded infobar after attaching', async () => { ++// const {frontend} = getBrowserAndPages(); ++// await openSourceCodeEditorForFile('sourcemap-minified.js', 'sourcemap-minified.html'); ++ ++// await step('Attach source map', async () => { ++// await openSoftContextMenuAndClickOnItem('.cm-line', 'Add source map…'); ++ ++// // Enter the source map URL into the appropriate input box. ++// await click('.add-source-map'); ++// await typeText('sourcemap-minified.map'); ++// await frontend.keyboard.press('Enter'); ++// }); ++ ++// await step('Get infobar text', async () => { ++// const infobarText = await waitForTextContent(INFOBAR_TEXT); ++// assert.strictEqual(infobarText, 'Source map loaded.'); ++// }); ++// }); ++ ++// it('shows Source map skipped infobar', async () => { ++// await setIgnoreListPattern('.min.js'); ++// await openSourceCodeEditorForFile('sourcemap-origin.min.js', 'sourcemap-origin.html'); ++ ++// await step('Get infobar texts', async () => { ++// await openFileInEditor('sourcemap-origin.min.js'); ++// await waitFor('.infobar-warning'); ++// await waitFor('.infobar-info'); ++// const infobarTexts = await getVisibleTextContents(INFOBAR_TEXT); ++// assert.deepEqual( ++// infobarTexts, ['This script is on the debugger\'s ignore list', 'Source map skipped for this file.']); ++// }); ++// }); ++ ++// it('shows Source map error infobar after failing to attach', async () => { ++// const {frontend} = getBrowserAndPages(); ++// await openSourceCodeEditorForFile('sourcemap-minified.js', 'sourcemap-minified.html'); ++ ++// await step('Attach source map', async () => { ++// await openSoftContextMenuAndClickOnItem('.cm-line', 'Add source map…'); ++ ++// // Enter the source map URL into the appropriate input box. ++// await click('.add-source-map'); ++// await typeText('sourcemap-invalid.map'); ++// await frontend.keyboard.press('Enter'); ++// }); ++ ++// await step('Get infobar text', async () => { ++// const infobarText = await waitForTextContent(INFOBAR_TEXT); ++// assert.strictEqual(infobarText, 'Source map failed to load.'); ++// }); ++// }); ++ ++// describe('can deal with code-splitting', () => { ++// it('sets multiple breakpoints in case of code-splitting', async () => { ++// const {target, frontend} = getBrowserAndPages(); ++// await openSourceCodeEditorForFile('sourcemap-codesplit.ts', 'sourcemap-codesplit.html'); ++// await addBreakpointForLine(frontend, 3); ++ ++// for (let i = 0; i < 2; ++i) { ++// const scriptLocation = await retrieveTopCallFrameScriptLocation(`functions[${i}]();`, target); ++// assert.deepEqual(scriptLocation, 'sourcemap-codesplit.ts:3'); ++// } ++// }); ++ ++// it('restores breakpoints correctly in case of code-splitting (crbug.com/1412033)', async () => { ++// const {target, frontend} = getBrowserAndPages(); ++ ++// // Load the initial setup with only one script pointing to `codesplitting-bar.ts`... ++// await openSourceCodeEditorForFile('codesplitting-bar.ts', 'codesplitting.html'); ++ ++// // ...and set a breakpoint inside `bar()`. ++// await addBreakpointForLine(frontend, 2); ++ ++// // Now load the second script pointing to `codesplitting-bar.ts`... ++// await target.evaluate('addSecond();'); ++ ++// // ...wait for the new origin to be listed... ++// const linkTexts = await waitForFunction(async () => { ++// const links = await $$(DEVTOOLS_LINK); ++// const linkTexts = await Promise.all(links.map(node => node.evaluate(({textContent}) => textContent))); ++// if (linkTexts.length === 1 && linkTexts[0] === 'codesplitting-first.js') { ++// return undefined; ++// } ++// return linkTexts; ++// }); ++// assert.sameMembers(linkTexts, ['codesplitting-first.js', 'codesplitting-second.js']); ++ ++// // ...and eventually wait for the breakpoint to be restored in line 2. ++// await waitForFunction(async () => await isBreakpointSet(2)); ++ ++// // Eventually we should stop on the breakpoint in the `codesplitting-second.js`. ++// await waitForFunction(() => { ++// return Promise.race([ ++// target.evaluate('second()').then(() => false), ++// waitFor(PAUSE_INDICATOR_SELECTOR).then(() => true), ++// ]); ++// }); ++// await click(RESUME_BUTTON); ++// }); ++ ++// it('hits breakpoints reliably after reload in case of code-splitting (crbug.com/1490369)', async () => { ++// const {target, frontend} = getBrowserAndPages(); ++ ++// // Set the breakpoint inside `shared()` in `shared.js`. ++// await openSourceCodeEditorForFile('shared.js', 'codesplitting-race.html'); ++// await addBreakpointForLine(frontend, 2); ++// await waitForFunction(async () => await isBreakpointSet(2)); ++ ++// // Reload the page. ++// const reloadPromise = target.reload(); ++ ++// // Now the debugger should pause twice reliably. ++// await waitFor(PAUSE_INDICATOR_SELECTOR); ++// await click(RESUME_BUTTON); ++// await waitFor(PAUSE_INDICATOR_SELECTOR); ++// await click(RESUME_BUTTON); ++ ++// await reloadPromise; ++// }); ++// }); ++ ++// describe('can deal with hot module replacement', () => { ++// // The tests in here simulate Hot Module Replacement (HMR) workflows related ++// // to how DevTools deals with source maps in these situations. ++ ++// it('correctly handles URL clashes between compiled and source-mapped scripts', async () => { ++// const {target} = getBrowserAndPages(); ++ ++// // Load the "initial bundle"... ++// await openSourceCodeEditorForFile('index.js', 'sourcemap-hmr.html'); ++ ++// // ...and check that index.js content is as expected. ++// // In particular, this asserts that the front-end does not get creative in ++// // appending suffixes like '? [sm]' to the index.js here. ++// const initialContent = await retrieveCodeMirrorEditorContent(); ++// assert.deepEqual(initialContent, [ ++// 'globalThis.hello = () => {', ++// ' console.log("Hello world!");', ++// '}', ++// '', ++// ]); ++ ++// // Simulate the hot module replacement for index.js... ++// await target.evaluate('update();'); ++ ++// // ...and wait for its content to load (should just replace ++// // the existing tab contents for index.js). We perform this ++// // check by waiting until the editor contents differ from ++// // the initial contents, and then asserting that it looks ++// // as expected afterwards. ++// const updatedContent = await waitForFunction(async () => { ++// const content = await retrieveCodeMirrorEditorContent(); ++// if (content.length !== initialContent.length) { ++// return content; ++// } ++// for (let i = 0; i < content.length; ++i) { ++// if (content[i] !== initialContent[i]) { ++// return content; ++// } ++// } ++// return undefined; ++// }); ++// assert.deepEqual(updatedContent, [ ++// 'globalThis.hello = () => {', ++// ' console.log("Hello UPDATED world!");', ++// '}', ++// '', ++// ]); ++// }); ++ ++// it('correctly maintains breakpoints from initial bundle to replacement', async () => { ++// const {target, frontend} = getBrowserAndPages(); ++ ++// // Load the "initial bundle" and set a breakpoint on the second line. ++// await openSourceCodeEditorForFile('index.js', 'sourcemap-hmr.html'); ++// await addBreakpointForLine(frontend, 2); ++ ++// // Simulate the hot module replacement for index.js ++// await target.evaluate('update();'); ++ ++// // Wait for the "hot module replacement" to take effect for index.js. ++// await waitForFunction(async () => { ++// const content = await retrieveCodeMirrorEditorContent(); ++// return content[1].includes('UPDATED'); ++// }); ++ ++// // Wait for the breakpoint to appear on line 2 of the updated index.js. ++// await waitForFunction(async () => await isBreakpointSet(2)); ++// }); ++ ++// it('correctly maintains breakpoints from replacement to initial bundle (across reloads)', async () => { ++// const {target, frontend} = getBrowserAndPages(); ++ ++// // Load the "initial bundle". ++// await openSourceCodeEditorForFile('index.js', 'sourcemap-hmr.html'); ++ ++// // Simulate the hot module replacement for index.js ++// await target.evaluate('update();'); ++ ++// // Wait for the "hot module replacement" to take effect for index.js. ++// await waitForFunction(async () => { ++// const content = await retrieveCodeMirrorEditorContent(); ++// return content[1].includes('UPDATED'); ++// }); ++ ++// // Set a breakpoint on the second line. ++// await addBreakpointForLine(frontend, 2); ++ ++// // Reload the page and re-open (the initial) index.js. ++// await reloadPageAndWaitForSourceFile(target, 'index.js'); ++ ++// // Check that the breakpoint still exists on line 2. ++// assert.isTrue(await isBreakpointSet(2)); ++// }); ++// }); ++ ++// it('can attach sourcemaps to CSS files from a context menu', async () => { ++// await openSourceCodeEditorForFile('sourcemap-css.css', 'sourcemap-css-noinline.html'); ++ ++// await click('aria/Code editor', {clickOptions: {button: 'right'}}); ++// await click('aria/Add source map…'); ++// await waitFor('.add-source-map'); ++// await typeText('sourcemap-css-absolute.map'); ++// await pressKey('Enter'); ++ ++// await waitFor('[aria-label="app.scss, file"]'); ++// }); ++// }); ++ ++// describe('The Elements Tab', async () => { ++// async function clickStyleValueWithModifiers(selector: string, name: string, value: string, location: string) { ++// const element = await waitForCSSPropertyValue(selector, name, value, location); ++// // Click with offset to skip swatches. ++// await withControlOrMetaKey(() => clickElement(element, {clickOptions: {offset: {x: 20, y: 5}}})); ++// } ++ ++// it('links to the right SASS source for inline CSS with relative sourcemap (crbug.com/787792)', async () => { ++// await goToResource('sources/sourcemap-css-inline-relative.html'); ++// await step('Prepare elements tab', async () => { ++// await waitForElementsStyleSection(); ++// await waitForContentOfSelectedElementsNode('\u200B'); ++// await focusElementsTree(); ++// await clickNthChildOfSelectedElementNode(1); ++// }); ++// await clickStyleValueWithModifiers('body .text', 'color', 'green', 'app.scss:6'); ++// await waitForElementWithTextContent('Line 12, Column 9'); ++// }); ++ ++// it('links to the right SASS source for inline CSS with absolute sourcemap (crbug.com/787792)', async () => { ++// await goToResource('sources/sourcemap-css-dynamic-link.html'); ++// await step('Prepare elements tab', async () => { ++// await waitForElementsStyleSection(); ++// await waitForContentOfSelectedElementsNode('\u200B'); ++// await focusElementsTree(); ++// await clickNthChildOfSelectedElementNode(1); ++// }); ++// await clickStyleValueWithModifiers('body .text', 'color', 'green', 'app.scss:6'); ++// await waitForElementWithTextContent('Line 12, Column 9'); ++// }); ++ ++// it('links to the right SASS source for dynamically added CSS style tags (crbug.com/787792)', async () => { ++// await goToResource('sources/sourcemap-css-dynamic.html'); ++// await step('Prepare elements tab', async () => { ++// await waitForElementsStyleSection(); ++// await waitForContentOfSelectedElementsNode('\u200B'); ++// await focusElementsTree(); ++// await clickNthChildOfSelectedElementNode(1); ++// }); ++// await clickStyleValueWithModifiers('body .text', 'color', 'green', 'app.scss:6'); ++// await waitForElementWithTextContent('Line 12, Column 9'); ++// }); ++ ++// it('links to the right SASS source for dynamically added CSS link tags (crbug.com/787792)', async () => { ++// await goToResource('sources/sourcemap-css-dynamic-link.html'); ++// await step('Prepare elements tab', async () => { ++// await waitForElementsStyleSection(); ++// await waitForContentOfSelectedElementsNode('\u200B'); ++// await focusElementsTree(); ++// await clickNthChildOfSelectedElementNode(1); ++// }); ++// await clickStyleValueWithModifiers('body .text', 'color', 'green', 'app.scss:6'); ++// await waitForElementWithTextContent('Line 12, Column 9'); ++// }); ++// }); + + describe('Sourcemaps Standarization Tests', async () => { +- it('checks that the name in stacktrace in the console is unminified', async () => { ++ it('checks that the name in stacktrace in the console is unminified', async (done) => { + // this could be extracted to the test harness (maybe also the match function and the initial setup) + // like so: +- // const result = prepare(generatedFile, htmlFile) +- // assert(result, matchExpresssion) ++ // prepare(generatedFile, htmlFile) ++ // assert(matchExpresssion) + const generatedFile = 'simple-throw.js'; + const htmlFile = 'simple-throw.html'; + const matchExpression = /.*at\ wat/; + +- // this would be 'prepare' ++ // this would be 'prepare + const {target, frontend} = getBrowserAndPages(); +- +- await openSourceCodeEditorForFile(generatedFile, htmlFile); +- await step('open console', async () => { ++ ++ step('check console messages', async () => { ++ await openSourceCodeEditorForFile(generatedFile, htmlFile); + await frontend.evaluate(`(async () => { + const Root = await import('./core/root/root.js'); + Root.Runtime.experiments.setEnabled('evaluateExpressionsWithSourceMaps', true); + })()`); ++ // await frontend.evaluate(`SimpleThrow.outerWrap();`); + + await click(CONSOLE_TAB_SELECTOR); +- await focusConsolePrompt(); +- await pasteText('outerWat();'); +- await frontend.keyboard.press('Enter'); +- +- // Wait for the console to be usable again. +- await frontend.waitForFunction(() => { +- return document.querySelectorAll('.console-user-command-result').length === 1; +- }); ++ // await focusConsolePrompt(); ++ // await pasteText('SimpleThrow.outerWat();'); ++ // await frontend.keyboard.press('Enter'); ++ ++ // // Wait for the console to be usable again. ++ // await frontend.waitForFunction(() => { ++ // return document.querySelectorAll('.console-user-command-result').length === 1; ++ // }); ++ // // which would return the messages or would expose another function to get the ++ const messages = await getCurrentConsoleMessages(); ++ console.log(messages); ++ // and then this would be assert' ++ assert.match(messages[0], matchExpression); + }); +- +- // which would return the messages or would expose another function to get the messages +- const messages = await getCurrentConsoleMessages(); +- // and then this would be 'assert' +- assert.match(messages[0], matchExpression); + }); + }); ++ ++ ++// it('shows unminified identifiers in scopes and console', async () => { ++// const {target, frontend} = getBrowserAndPages(); ++// await openSourceCodeEditorForFile('sourcemap-minified.js', 'sourcemap-minified.html'); ++ ++// let scriptEvaluation: Promise; ++// const breakLocationRegExp = /sourcemap-minified\.js:1$/; ++ ++// await step('Run to debugger statement', async () => { ++// scriptEvaluation = target.evaluate('sayHello(" world");'); ++ ++// const scriptLocation = await waitForStackTopMatch(breakLocationRegExp); ++// assert.match(scriptLocation, breakLocationRegExp); ++// }); ++ ++// await step('Check local variable is eventually un-minified', async () => { ++// const unminifiedVariable = 'element: div'; ++// await openSoftContextMenuAndClickOnItem('.cm-line', 'Add source map…'); ++ ++// // Enter the source map URL into the appropriate input box. ++// await click('.add-source-map'); ++// await typeText('sourcemap-minified.map'); ++// await frontend.keyboard.press('Enter'); ++ ++// const scopeValues = await waitForFunction(async () => { ++// const values = await getValuesForScope('Local', 0, 0); ++// return (values && values.includes(unminifiedVariable)) ? values : undefined; ++// }); ++// assert.include(scopeValues, unminifiedVariable); ++// }); ++ ++// await step('Check that expression evaluation understands unminified name', async () => { ++// await frontend.evaluate(`(async () => { ++// const Root = await import('./core/root/root.js'); ++// Root.Runtime.experiments.setEnabled('evaluateExpressionsWithSourceMaps', true); ++// })()`); ++ ++// await click(CONSOLE_TAB_SELECTOR); ++// await focusConsolePrompt(); ++// await pasteText('`Hello${text}!`'); ++// await frontend.keyboard.press('Enter'); ++ ++// // Wait for the console to be usable again. ++// await frontend.waitForFunction(() => { ++// return document.querySelectorAll('.console-user-command-result').length === 1; ++// }); ++// const messages = await getCurrentConsoleMessages(); ++ ++// assert.deepEqual(messages, ['\'Hello world!\'']); ++ ++// await openSourcesPanel(); ++// }); ++ ++// await step('Resume', async () => { ++// await click(RESUME_BUTTON); ++// await scriptEvaluation; ++// }); ++// }); +\ No newline at end of file +diff --git a/test/unittests/BUILD.gn b/test/unittests/BUILD.gn +index 6e6c6fd400..c259624d42 100644 +--- a/test/unittests/BUILD.gn ++++ b/test/unittests/BUILD.gn +@@ -17,6 +17,7 @@ group("unittests") { + "../shared", + "fixtures/images", + "fixtures/traces", ++ "fixtures/sourcemaps", + "front_end", + "inspector_overlay", + ] +diff --git a/test/unittests/front_end/core/sdk/BUILD.gn b/test/unittests/front_end/core/sdk/BUILD.gn +index 1c4d051cd7..5b185550b9 100644 +--- a/test/unittests/front_end/core/sdk/BUILD.gn ++++ b/test/unittests/front_end/core/sdk/BUILD.gn +@@ -42,6 +42,7 @@ ts_library("sdk") { + "ServiceWorkerManager_test.ts", + "SourceMapManager_test.ts", + "SourceMap_test.ts", ++ "SourceMapSpec_test.ts", + "StorageKeyManager_test.ts", + "TargetManager_test.ts", + "Target_test.ts", From e5a238d17eb6d373514494d1d25cf01f31ae3580 Mon Sep 17 00:00:00 2001 From: Agata Belkius Date: Wed, 10 Apr 2024 00:12:35 +0100 Subject: [PATCH 49/68] remove logging --- chrome/SourceMapSpec_test.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/chrome/SourceMapSpec_test.ts b/chrome/SourceMapSpec_test.ts index 4c94a18..2c1ab35 100644 --- a/chrome/SourceMapSpec_test.ts +++ b/chrome/SourceMapSpec_test.ts @@ -32,7 +32,6 @@ interface TestAction { const testCases = await loadTestCasesFromFixture('source-map-spec-tests.json'); describeWithEnvironment.only('SourceMapSpec', async () => { - console.log(testCases); testCases.forEach(async ({ baseFile, sourceMapFile, @@ -79,7 +78,6 @@ describeWithEnvironment.only('SourceMapSpec', async () => { }); async function loadTestCasesFromFixture(filename: string): Promise { - console.log('!!!!loading test cases'); const testSpec = await getFixtureFileContents<{ tests: TestSpec[] }>(filename); return testSpec?.tests ?? []; }; From 41681889e5ab7f6347abf4f5dccf0490bcf7e97c Mon Sep 17 00:00:00 2001 From: Agata Belkius Date: Fri, 19 Apr 2024 15:38:20 +0100 Subject: [PATCH 50/68] update chrome harness --- .../0001-add-tests-for-sourcemaps-spec.patch | 2070 +++++++++++++++++ chrome/SourceMapSpec_test.ts | 107 - chrome/sourcemaps-tests-harness-chrome.patch | 1509 ------------ 3 files changed, 2070 insertions(+), 1616 deletions(-) create mode 100644 chrome/0001-add-tests-for-sourcemaps-spec.patch delete mode 100644 chrome/SourceMapSpec_test.ts delete mode 100644 chrome/sourcemaps-tests-harness-chrome.patch diff --git a/chrome/0001-add-tests-for-sourcemaps-spec.patch b/chrome/0001-add-tests-for-sourcemaps-spec.patch new file mode 100644 index 0000000..aa69c64 --- /dev/null +++ b/chrome/0001-add-tests-for-sourcemaps-spec.patch @@ -0,0 +1,2070 @@ +From 5a77ff79e4092740116e1c6871bd15fc5f560e66 Mon Sep 17 00:00:00 2001 +From: Agata Belkius +Date: Fri, 19 Apr 2024 15:30:48 +0100 +Subject: [PATCH] add tests for sourcemaps spec + +--- + front_end/BUILD.gn | 1 + + front_end/core/sdk/BUILD.gn | 1 + + front_end/core/sdk/SourceMapSpec.test.ts | 129 ++++ + .../core/sdk/fixtures/sourcemaps/BUILD.gn | 106 ++++ + .../sourcemaps/basic-mapping-as-index-map.js | 2 + + .../basic-mapping-as-index-map.js.map | 23 + + .../sourcemaps/basic-mapping-original.js | 8 + + .../sdk/fixtures/sourcemaps/basic-mapping.js | 2 + + .../fixtures/sourcemaps/basic-mapping.js.map | 6 + + .../index-map-invalid-base-mappings.js | 1 + + .../index-map-invalid-base-mappings.js.map | 15 + + .../sourcemaps/index-map-invalid-overlap.js | 1 + + .../index-map-invalid-overlap.js.map | 23 + + .../index-map-missing-offset-column.js | 1 + + .../index-map-missing-offset-column.js.map | 14 + + .../index-map-missing-offset-line.js | 1 + + .../index-map-missing-offset-line.js.map | 14 + + .../sourcemaps/index-map-missing-offset.js | 1 + + .../index-map-missing-offset.js.map | 13 + + .../index-map-offset-column-wrong-type.js | 1 + + .../index-map-offset-column-wrong-type.js.map | 14 + + .../index-map-offset-line-wrong-type.js | 1 + + .../index-map-offset-line-wrong-type.js.map | 14 + + .../invalid-mapping-bad-separator.js | 2 + + .../invalid-mapping-bad-separator.js.map | 6 + + .../invalid-mapping-not-a-string-1.js | 1 + + .../invalid-mapping-not-a-string-1.js.map | 7 + + .../invalid-mapping-not-a-string-2.js | 1 + + .../invalid-mapping-not-a-string-2.js.map | 7 + + ...nvalid-mapping-segment-column-too-large.js | 1 + + ...id-mapping-segment-column-too-large.js.map | 7 + + ...apping-segment-name-index-out-of-bounds.js | 1 + + ...ng-segment-name-index-out-of-bounds.js.map | 7 + + ...id-mapping-segment-name-index-too-large.js | 1 + + ...apping-segment-name-index-too-large.js.map | 7 + + ...invalid-mapping-segment-negative-column.js | 1 + + ...lid-mapping-segment-negative-column.js.map | 7 + + ...lid-mapping-segment-negative-name-index.js | 1 + + ...mapping-segment-negative-name-index.js.map | 7 + + ...apping-segment-negative-original-column.js | 1 + + ...ng-segment-negative-original-column.js.map | 7 + + ...-mapping-segment-negative-original-line.js | 1 + + ...ping-segment-negative-original-line.js.map | 7 + + ...d-mapping-segment-negative-source-index.js | 1 + + ...pping-segment-negative-source-index.js.map | 7 + + ...pping-segment-original-column-too-large.js | 1 + + ...g-segment-original-column-too-large.js.map | 7 + + ...mapping-segment-original-line-too-large.js | 1 + + ...ing-segment-original-line-too-large.js.map | 7 + + ...ping-segment-source-index-out-of-bounds.js | 1 + + ...-segment-source-index-out-of-bounds.js.map | 7 + + ...-mapping-segment-source-index-too-large.js | 1 + + ...ping-segment-source-index-too-large.js.map | 7 + + ...valid-mapping-segment-with-three-fields.js | 2 + + ...d-mapping-segment-with-three-fields.js.map | 6 + + ...invalid-mapping-segment-with-two-fields.js | 2 + + ...lid-mapping-segment-with-two-fields.js.map | 6 + + ...nvalid-mapping-segment-with-zero-fields.js | 1 + + ...id-mapping-segment-with-zero-fields.js.map | 7 + + .../sourcemaps/invalid-vlq-non-base64-char.js | 1 + + .../invalid-vlq-non-base64-char.js.map | 6 + + .../sdk/fixtures/sourcemaps/names-missing.js | 1 + + .../fixtures/sourcemaps/names-missing.js.map | 5 + + .../fixtures/sourcemaps/names-not-a-list-1.js | 1 + + .../sourcemaps/names-not-a-list-1.js.map | 6 + + .../fixtures/sourcemaps/names-not-a-list-2.js | 1 + + .../sourcemaps/names-not-a-list-2.js.map | 6 + + .../fixtures/sourcemaps/names-not-string.js | 1 + + .../sourcemaps/names-not-string.js.map | 6 + + .../sourcemaps/source-map-spec-tests.json | 573 ++++++++++++++++++ + .../fixtures/sourcemaps/sources-missing.js | 1 + + .../sourcemaps/sources-missing.js.map | 5 + + .../sourcemaps/sources-not-a-list-1.js | 1 + + .../sourcemaps/sources-not-a-list-1.js.map | 6 + + .../sourcemaps/sources-not-a-list-2.js | 1 + + .../sourcemaps/sources-not-a-list-2.js.map | 6 + + .../sourcemaps/sources-not-string-or-null.js | 1 + + .../sources-not-string-or-null.js.map | 6 + + .../sourcemaps/unrecognized-property.js | 1 + + .../sourcemaps/unrecognized-property.js.map | 8 + + .../valid-mapping-boundary-values.js | 1 + + .../valid-mapping-boundary-values.js.map | 7 + + .../sourcemaps/valid-mapping-empty-groups.js | 1 + + .../valid-mapping-empty-groups.js.map | 7 + + .../sourcemaps/valid-mapping-large-vlq.js | 1 + + .../sourcemaps/valid-mapping-large-vlq.js.map | 6 + + .../sourcemaps/valid-mapping-null-sources.js | 2 + + .../valid-mapping-null-sources.js.map | 6 + + .../fixtures/sourcemaps/version-missing.js | 1 + + .../sourcemaps/version-missing.js.map | 5 + + .../sourcemaps/version-not-a-number.js | 1 + + .../sourcemaps/version-not-a-number.js.map | 6 + + .../sourcemaps/version-numeric-string.js | 1 + + .../sourcemaps/version-numeric-string.js.map | 6 + + .../fixtures/sourcemaps/version-too-high.js | 1 + + .../sourcemaps/version-too-high.js.map | 6 + + .../fixtures/sourcemaps/version-too-low.js | 1 + + .../sourcemaps/version-too-low.js.map | 6 + + .../sdk/fixtures/sourcemaps/version-valid.js | 1 + + .../fixtures/sourcemaps/version-valid.js.map | 6 + + 100 files changed, 1251 insertions(+) + create mode 100644 front_end/core/sdk/SourceMapSpec.test.ts + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/BUILD.gn + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/basic-mapping-as-index-map.js + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/basic-mapping-as-index-map.js.map + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/basic-mapping-original.js + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/basic-mapping.js + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/basic-mapping.js.map + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/index-map-invalid-base-mappings.js + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/index-map-invalid-base-mappings.js.map + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/index-map-invalid-overlap.js + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/index-map-invalid-overlap.js.map + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/index-map-missing-offset-column.js + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/index-map-missing-offset-column.js.map + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/index-map-missing-offset-line.js + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/index-map-missing-offset-line.js.map + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/index-map-missing-offset.js + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/index-map-missing-offset.js.map + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/index-map-offset-column-wrong-type.js + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/index-map-offset-column-wrong-type.js.map + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/index-map-offset-line-wrong-type.js + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/index-map-offset-line-wrong-type.js.map + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-bad-separator.js + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-bad-separator.js.map + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-not-a-string-1.js + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-not-a-string-1.js.map + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-not-a-string-2.js + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-not-a-string-2.js.map + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-column-too-large.js + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-column-too-large.js.map + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-name-index-out-of-bounds.js + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-name-index-out-of-bounds.js.map + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-name-index-too-large.js + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-name-index-too-large.js.map + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-negative-column.js + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-negative-column.js.map + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-negative-name-index.js + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-negative-name-index.js.map + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-negative-original-column.js + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-negative-original-column.js.map + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-negative-original-line.js + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-negative-original-line.js.map + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-negative-source-index.js + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-negative-source-index.js.map + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-original-column-too-large.js + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-original-column-too-large.js.map + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-original-line-too-large.js + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-original-line-too-large.js.map + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-source-index-out-of-bounds.js + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-source-index-out-of-bounds.js.map + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-source-index-too-large.js + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-source-index-too-large.js.map + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-with-three-fields.js + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-with-three-fields.js.map + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-with-two-fields.js + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-with-two-fields.js.map + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-with-zero-fields.js + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-with-zero-fields.js.map + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/invalid-vlq-non-base64-char.js + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/invalid-vlq-non-base64-char.js.map + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/names-missing.js + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/names-missing.js.map + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/names-not-a-list-1.js + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/names-not-a-list-1.js.map + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/names-not-a-list-2.js + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/names-not-a-list-2.js.map + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/names-not-string.js + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/names-not-string.js.map + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/source-map-spec-tests.json + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/sources-missing.js + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/sources-missing.js.map + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/sources-not-a-list-1.js + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/sources-not-a-list-1.js.map + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/sources-not-a-list-2.js + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/sources-not-a-list-2.js.map + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/sources-not-string-or-null.js + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/sources-not-string-or-null.js.map + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/unrecognized-property.js + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/unrecognized-property.js.map + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/valid-mapping-boundary-values.js + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/valid-mapping-boundary-values.js.map + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/valid-mapping-empty-groups.js + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/valid-mapping-empty-groups.js.map + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/valid-mapping-large-vlq.js + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/valid-mapping-large-vlq.js.map + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/valid-mapping-null-sources.js + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/valid-mapping-null-sources.js.map + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/version-missing.js + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/version-missing.js.map + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/version-not-a-number.js + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/version-not-a-number.js.map + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/version-numeric-string.js + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/version-numeric-string.js.map + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/version-too-high.js + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/version-too-high.js.map + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/version-too-low.js + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/version-too-low.js.map + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/version-valid.js + create mode 100644 front_end/core/sdk/fixtures/sourcemaps/version-valid.js.map + +diff --git a/front_end/BUILD.gn b/front_end/BUILD.gn +index 85926fd08b..0dc146898c 100644 +--- a/front_end/BUILD.gn ++++ b/front_end/BUILD.gn +@@ -106,6 +106,7 @@ group("unittests") { + "core/protocol_client:unittests", + "core/root:unittests", + "core/sdk:unittests", ++ "core/sdk/fixtures/sourcemaps", + "entrypoints/formatter_worker:unittests", + "entrypoints/heap_snapshot_worker:unittests", + "entrypoints/inspector_main:unittests", +diff --git a/front_end/core/sdk/BUILD.gn b/front_end/core/sdk/BUILD.gn +index 43ea1be19c..bdc88a7e04 100644 +--- a/front_end/core/sdk/BUILD.gn ++++ b/front_end/core/sdk/BUILD.gn +@@ -163,6 +163,7 @@ ts_library("unittests") { + "SourceMap.test.ts", + "SourceMapManager.test.ts", + "SourceMapScopes.test.ts", ++ "SourceMapSpec.test.ts", + "StorageBucketsModel.test.ts", + "StorageKeyManager.test.ts", + "Target.test.ts", +diff --git a/front_end/core/sdk/SourceMapSpec.test.ts b/front_end/core/sdk/SourceMapSpec.test.ts +new file mode 100644 +index 0000000000..64f350d7f3 +--- /dev/null ++++ b/front_end/core/sdk/SourceMapSpec.test.ts +@@ -0,0 +1,129 @@ ++// Copyright 2024 The Chromium Authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++ ++/** ++ This file tests if devtools sourcemaps implementation is matching the sourcemaps spec. ++ Sourcemap Spec tests are using test data coming from: https://github.com/takikawa/source-map-tests ++ ++ At the moment only basic mapping tests are implemented. Expected results: ++ ++ ==== FAIL: SourceMapSpec/checks mappings for valid-mapping-null-sources.js.map ++ AssertionError: unexpected source URL: expected 'null' to equal null ++ at front_end/core/sdk/SourceMapSpec.test.ts:74:20 <- out/Default/gen/front_end/core/sdk/SourceMapSpec.test.js:25:32 ++ at Array.forEach () ++ at Context. (front_end/core/sdk/SourceMapSpec.test.ts:62:21 <- out/Default/gen/front_end/core/sdk/SourceMapSpec.test.js:21:29) ++ ++ - expected ++ + actual ++ ++ -[null] ++ +"null" ++ ============================================================================== ++ ++ FAILED: 1 failed, 46 passed (0 skipped) ++ ERRORS DETECTED ++ ++ **/ ++ ++const {assert} = chai; ++import type * as Platform from '../platform/platform.js'; ++import {assertNotNullOrUndefined} from '../platform/platform.js'; ++import { SourceMapV3 } from './SourceMap.js'; ++import * as SDK from './sdk.js'; ++import {describeWithEnvironment} from '../../testing/EnvironmentHelpers.js'; ++ ++interface TestSpec { ++ name: string; ++ description: string; ++ baseFile: string; ++ sourceMapFile: string; ++ sourceMapIsValid: boolean; ++ testActions?: TestAction[]; ++} ++ ++interface TestAction { ++ actionType: string; ++ generatedLine: number; ++ generatedColumn: number; ++ originalSource: string; ++ originalLine: number; ++ originalColumn: number; ++ mappedName: null | string; ++} ++ ++const testCases = await loadTestCasesFromFixture('source-map-spec-tests.json'); ++ ++describeWithEnvironment.only('SourceMapSpec', async () => { ++ testCases.forEach(async ({ ++ baseFile, ++ sourceMapFile, ++ testActions, ++ sourceMapIsValid ++ }) => { ++ it(`checks mappings for ${sourceMapFile}`, async () => { ++ if (!sourceMapIsValid) { ++ return; ++ } ++ ++ const baseFileUrl = baseFile as Platform.DevToolsPath.UrlString; ++ const sourceMapFileUrl = sourceMapFile as Platform.DevToolsPath.UrlString; ++ const sourceMapContent = await loadSourceMapFromFixture(sourceMapFile); ++ ++ const sourceMap = new SDK.SourceMap.SourceMap( ++ baseFileUrl, ++ sourceMapFileUrl, ++ sourceMapContent); ++ ++ ++ if (testActions !== undefined) { ++ testActions.forEach(({ ++ actionType, ++ originalSource, ++ originalLine, ++ originalColumn, ++ generatedLine, ++ generatedColumn ++ }) => { ++ if (actionType === "checkMapping" && sourceMapIsValid) { ++ const actual = sourceMap.findEntry(generatedLine, generatedColumn); ++ assertNotNullOrUndefined(actual); ++ ++ assert.strictEqual(actual.sourceURL, originalSource, 'unexpected source URL'); ++ assert.strictEqual(actual.sourceLineNumber, originalLine, 'unexpected source line number'); ++ assert.strictEqual(actual.sourceColumnNumber, originalColumn, 'unexpected source column number'); ++ } ++ }); ++ } ++ }); ++ }); ++}); ++ ++async function loadTestCasesFromFixture(filename: string): Promise { ++ const testSpec = await getFixtureFileContents<{ tests: TestSpec[] }>(filename); ++ return testSpec?.tests ?? []; ++}; ++ ++async function loadSourceMapFromFixture(filename: string): Promise { ++ return getFixtureFileContents(filename); ++}; ++ ++async function getFixtureFileContents(filename: string): ++ Promise { ++ const url = new URL(`/front_end/core/sdk/fixtures/sourcemaps/${filename}`, window.location.origin); ++ ++ const response = await fetch(url); ++ ++ if (response.status !== 200) { ++ throw new Error(`Unable to load ${url}`); ++ } ++ ++ const contentType = response.headers.get('content-type'); ++ const isGzipEncoded = contentType !== null && contentType.includes('gzip'); ++ let buffer = await response.arrayBuffer(); ++ ++ const decoder = new TextDecoder('utf-8'); ++ const contents = JSON.parse(decoder.decode(buffer)) as T; ++ return contents; ++} +diff --git a/front_end/core/sdk/fixtures/sourcemaps/BUILD.gn b/front_end/core/sdk/fixtures/sourcemaps/BUILD.gn +new file mode 100644 +index 0000000000..f39bf7afc6 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/BUILD.gn +@@ -0,0 +1,106 @@ ++# Copyright 2022 The Chromium Authors. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++import("../../../../../scripts/build/ninja/copy.gni") ++ ++copy_to_gen("sourcemaps") { ++ sources = [ ++ "basic-mapping-as-index-map.js", ++ "basic-mapping-as-index-map.js.map", ++ "basic-mapping-original.js", ++ "basic-mapping.js", ++ "basic-mapping.js.map", ++ "index-map-invalid-base-mappings.js", ++ "index-map-invalid-base-mappings.js.map", ++ "index-map-invalid-overlap.js", ++ "index-map-invalid-overlap.js.map", ++ "index-map-missing-offset-column.js", ++ "index-map-missing-offset-column.js.map", ++ "index-map-missing-offset-line.js", ++ "index-map-missing-offset-line.js.map", ++ "index-map-missing-offset.js", ++ "index-map-missing-offset.js.map", ++ "index-map-offset-column-wrong-type.js", ++ "index-map-offset-column-wrong-type.js.map", ++ "index-map-offset-line-wrong-type.js", ++ "index-map-offset-line-wrong-type.js.map", ++ "invalid-mapping-bad-separator.js", ++ "invalid-mapping-bad-separator.js.map", ++ "invalid-mapping-not-a-string-1.js", ++ "invalid-mapping-not-a-string-1.js.map", ++ "invalid-mapping-not-a-string-2.js", ++ "invalid-mapping-not-a-string-2.js.map", ++ "invalid-mapping-segment-column-too-large.js", ++ "invalid-mapping-segment-column-too-large.js.map", ++ "invalid-mapping-segment-name-index-out-of-bounds.js", ++ "invalid-mapping-segment-name-index-out-of-bounds.js.map", ++ "invalid-mapping-segment-name-index-too-large.js", ++ "invalid-mapping-segment-name-index-too-large.js.map", ++ "invalid-mapping-segment-negative-column.js", ++ "invalid-mapping-segment-negative-column.js.map", ++ "invalid-mapping-segment-negative-name-index.js", ++ "invalid-mapping-segment-negative-name-index.js.map", ++ "invalid-mapping-segment-negative-original-column.js", ++ "invalid-mapping-segment-negative-original-column.js.map", ++ "invalid-mapping-segment-negative-original-line.js", ++ "invalid-mapping-segment-negative-original-line.js.map", ++ "invalid-mapping-segment-negative-source-index.js", ++ "invalid-mapping-segment-negative-source-index.js.map", ++ "invalid-mapping-segment-original-column-too-large.js", ++ "invalid-mapping-segment-original-column-too-large.js.map", ++ "invalid-mapping-segment-original-line-too-large.js", ++ "invalid-mapping-segment-original-line-too-large.js.map", ++ "invalid-mapping-segment-source-index-out-of-bounds.js", ++ "invalid-mapping-segment-source-index-out-of-bounds.js.map", ++ "invalid-mapping-segment-source-index-too-large.js", ++ "invalid-mapping-segment-source-index-too-large.js.map", ++ "invalid-mapping-segment-with-three-fields.js", ++ "invalid-mapping-segment-with-three-fields.js.map", ++ "invalid-mapping-segment-with-two-fields.js", ++ "invalid-mapping-segment-with-two-fields.js.map", ++ "invalid-mapping-segment-with-zero-fields.js", ++ "invalid-mapping-segment-with-zero-fields.js.map", ++ "invalid-vlq-non-base64-char.js", ++ "invalid-vlq-non-base64-char.js.map", ++ "names-missing.js", ++ "names-missing.js.map", ++ "names-not-a-list-1.js", ++ "names-not-a-list-1.js.map", ++ "names-not-a-list-2.js", ++ "names-not-a-list-2.js.map", ++ "names-not-string.js", ++ "names-not-string.js.map", ++ "source-map-spec-tests.json", ++ "sources-missing.js", ++ "sources-missing.js.map", ++ "sources-not-a-list-1.js", ++ "sources-not-a-list-1.js.map", ++ "sources-not-a-list-2.js", ++ "sources-not-a-list-2.js.map", ++ "sources-not-string-or-null.js", ++ "sources-not-string-or-null.js.map", ++ "unrecognized-property.js", ++ "unrecognized-property.js.map", ++ "valid-mapping-boundary-values.js", ++ "valid-mapping-boundary-values.js.map", ++ "valid-mapping-empty-groups.js", ++ "valid-mapping-empty-groups.js.map", ++ "valid-mapping-large-vlq.js", ++ "valid-mapping-large-vlq.js.map", ++ "valid-mapping-null-sources.js", ++ "valid-mapping-null-sources.js.map", ++ "version-missing.js", ++ "version-missing.js.map", ++ "version-not-a-number.js", ++ "version-not-a-number.js.map", ++ "version-numeric-string.js", ++ "version-numeric-string.js.map", ++ "version-too-high.js", ++ "version-too-high.js.map", ++ "version-too-low.js", ++ "version-too-low.js.map", ++ "version-valid.js", ++ "version-valid.js.map", ++ ] ++} +diff --git a/front_end/core/sdk/fixtures/sourcemaps/basic-mapping-as-index-map.js b/front_end/core/sdk/fixtures/sourcemaps/basic-mapping-as-index-map.js +new file mode 100644 +index 0000000000..b9fae38043 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/basic-mapping-as-index-map.js +@@ -0,0 +1,2 @@ ++function foo(){return 42}function bar(){return 24}foo();bar(); ++//# sourceMappingURL=basic-mapping-as-index-map.js.map +diff --git a/front_end/core/sdk/fixtures/sourcemaps/basic-mapping-as-index-map.js.map b/front_end/core/sdk/fixtures/sourcemaps/basic-mapping-as-index-map.js.map +new file mode 100644 +index 0000000000..0863d44e62 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/basic-mapping-as-index-map.js.map +@@ -0,0 +1,23 @@ ++{ ++ "version": 3, ++ "sections": [ ++ { ++ "offset": { "line": 0, "column": 0 }, ++ "map": { ++ "version": 3, ++ "names": ["foo","bar"], ++ "sources": ["basic-mapping-original.js"], ++ "mappings": "AAAA,SAASA,MACP,OAAO,EACT,CACA" ++ } ++ }, ++ { ++ "offset": { "line": 0, "column": 34 }, ++ "map": { ++ "version": 3, ++ "names": ["foo","bar"], ++ "sources": ["basic-mapping-original.js"], ++ "mappings": "AAGSC,MACP,OAAO,EACT,CACAD,MACAC" ++ } ++ } ++ ] ++} +diff --git a/front_end/core/sdk/fixtures/sourcemaps/basic-mapping-original.js b/front_end/core/sdk/fixtures/sourcemaps/basic-mapping-original.js +new file mode 100644 +index 0000000000..301b186cb1 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/basic-mapping-original.js +@@ -0,0 +1,8 @@ ++function foo() { ++ return 42; ++} ++function bar() { ++ return 24; ++} ++foo(); ++bar(); +diff --git a/front_end/core/sdk/fixtures/sourcemaps/basic-mapping.js b/front_end/core/sdk/fixtures/sourcemaps/basic-mapping.js +new file mode 100644 +index 0000000000..2e479a4175 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/basic-mapping.js +@@ -0,0 +1,2 @@ ++function foo(){return 42}function bar(){return 24}foo();bar(); ++//# sourceMappingURL=basic-mapping.js.map +diff --git a/front_end/core/sdk/fixtures/sourcemaps/basic-mapping.js.map b/front_end/core/sdk/fixtures/sourcemaps/basic-mapping.js.map +new file mode 100644 +index 0000000000..12dc9679a4 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/basic-mapping.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version":3, ++ "names": ["foo","bar"], ++ "sources": ["basic-mapping-original.js"], ++ "mappings":"AAAA,SAASA,MACP,OAAO,EACT,CACA,SAASC,MACP,OAAO,EACT,CACAD,MACAC" ++} +diff --git a/front_end/core/sdk/fixtures/sourcemaps/index-map-invalid-base-mappings.js b/front_end/core/sdk/fixtures/sourcemaps/index-map-invalid-base-mappings.js +new file mode 100644 +index 0000000000..e90bef083c +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/index-map-invalid-base-mappings.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=index-map-invalid-base-mappings.js.map +diff --git a/front_end/core/sdk/fixtures/sourcemaps/index-map-invalid-base-mappings.js.map b/front_end/core/sdk/fixtures/sourcemaps/index-map-invalid-base-mappings.js.map +new file mode 100644 +index 0000000000..b489c1f080 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/index-map-invalid-base-mappings.js.map +@@ -0,0 +1,15 @@ ++{ ++ "version": 3, ++ "mappings": "AAAA", ++ "sections": [ ++ { ++ "offset": { "line": 0, "column": 0 }, ++ "map": { ++ "version": 3, ++ "names": [], ++ "sources": ["empty-original.js"], ++ "mappings": "AAAA" ++ } ++ } ++ ] ++} +diff --git a/front_end/core/sdk/fixtures/sourcemaps/index-map-invalid-overlap.js b/front_end/core/sdk/fixtures/sourcemaps/index-map-invalid-overlap.js +new file mode 100644 +index 0000000000..9aff8dc620 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/index-map-invalid-overlap.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=index-map-invalid-overlap.js.map +diff --git a/front_end/core/sdk/fixtures/sourcemaps/index-map-invalid-overlap.js.map b/front_end/core/sdk/fixtures/sourcemaps/index-map-invalid-overlap.js.map +new file mode 100644 +index 0000000000..8d42546fd8 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/index-map-invalid-overlap.js.map +@@ -0,0 +1,23 @@ ++{ ++ "version": 3, ++ "sections": [ ++ { ++ "offset": { "line": 0, "column": 0 }, ++ "map": { ++ "version": 3, ++ "names": [], ++ "sources": ["empty-original.js"], ++ "mappings": "AAAA" ++ } ++ }, ++ { ++ "offset": { "line": 0, "column": 0 }, ++ "map": { ++ "version": 3, ++ "names": [], ++ "sources": ["empty-original.js"], ++ "mappings": "AAAA" ++ } ++ } ++ ] ++} +diff --git a/front_end/core/sdk/fixtures/sourcemaps/index-map-missing-offset-column.js b/front_end/core/sdk/fixtures/sourcemaps/index-map-missing-offset-column.js +new file mode 100644 +index 0000000000..fe6917403f +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/index-map-missing-offset-column.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=index-map-missing-offset-column.js.map +diff --git a/front_end/core/sdk/fixtures/sourcemaps/index-map-missing-offset-column.js.map b/front_end/core/sdk/fixtures/sourcemaps/index-map-missing-offset-column.js.map +new file mode 100644 +index 0000000000..aa48bbb993 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/index-map-missing-offset-column.js.map +@@ -0,0 +1,14 @@ ++{ ++ "version": 3, ++ "sections": [ ++ { ++ "offset": { "line": 0 }, ++ "map": { ++ "version": 3, ++ "names": [], ++ "sources": ["empty-original.js"], ++ "mappings": "AAAA" ++ } ++ } ++ ] ++} +diff --git a/front_end/core/sdk/fixtures/sourcemaps/index-map-missing-offset-line.js b/front_end/core/sdk/fixtures/sourcemaps/index-map-missing-offset-line.js +new file mode 100644 +index 0000000000..ba8614e412 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/index-map-missing-offset-line.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=index-map-missing-offset-line.js.map +diff --git a/front_end/core/sdk/fixtures/sourcemaps/index-map-missing-offset-line.js.map b/front_end/core/sdk/fixtures/sourcemaps/index-map-missing-offset-line.js.map +new file mode 100644 +index 0000000000..3d60444ea7 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/index-map-missing-offset-line.js.map +@@ -0,0 +1,14 @@ ++{ ++ "version": 3, ++ "sections": [ ++ { ++ "offset": { "column": 0 }, ++ "map": { ++ "version": 3, ++ "names": [], ++ "sources": ["empty-original.js"], ++ "mappings": "AAAA" ++ } ++ } ++ ] ++} +diff --git a/front_end/core/sdk/fixtures/sourcemaps/index-map-missing-offset.js b/front_end/core/sdk/fixtures/sourcemaps/index-map-missing-offset.js +new file mode 100644 +index 0000000000..9ca2cf3fb5 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/index-map-missing-offset.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=index-map-missing-offset.js.map +diff --git a/front_end/core/sdk/fixtures/sourcemaps/index-map-missing-offset.js.map b/front_end/core/sdk/fixtures/sourcemaps/index-map-missing-offset.js.map +new file mode 100644 +index 0000000000..7285138bf5 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/index-map-missing-offset.js.map +@@ -0,0 +1,13 @@ ++{ ++ "version": 3, ++ "sections": [ ++ { ++ "map": { ++ "version": 3, ++ "names": [], ++ "sources": ["empty-original.js"], ++ "mappings": "AAAA" ++ } ++ } ++ ] ++} +diff --git a/front_end/core/sdk/fixtures/sourcemaps/index-map-offset-column-wrong-type.js b/front_end/core/sdk/fixtures/sourcemaps/index-map-offset-column-wrong-type.js +new file mode 100644 +index 0000000000..ed1e9ec5d5 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/index-map-offset-column-wrong-type.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=index-map-offset-column-wrong-type.js.map +diff --git a/front_end/core/sdk/fixtures/sourcemaps/index-map-offset-column-wrong-type.js.map b/front_end/core/sdk/fixtures/sourcemaps/index-map-offset-column-wrong-type.js.map +new file mode 100644 +index 0000000000..b43e79a9dd +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/index-map-offset-column-wrong-type.js.map +@@ -0,0 +1,14 @@ ++{ ++ "version": 3, ++ "sections": [ ++ { ++ "offset": { "line": 0, "column": true }, ++ "map": { ++ "version": 3, ++ "names": [], ++ "sources": ["empty-original.js"], ++ "mappings": "AAAA" ++ } ++ } ++ ] ++} +diff --git a/front_end/core/sdk/fixtures/sourcemaps/index-map-offset-line-wrong-type.js b/front_end/core/sdk/fixtures/sourcemaps/index-map-offset-line-wrong-type.js +new file mode 100644 +index 0000000000..d58f2aff99 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/index-map-offset-line-wrong-type.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=index-map-offset-line-wrong-type.js.map +diff --git a/front_end/core/sdk/fixtures/sourcemaps/index-map-offset-line-wrong-type.js.map b/front_end/core/sdk/fixtures/sourcemaps/index-map-offset-line-wrong-type.js.map +new file mode 100644 +index 0000000000..81dbcd6ec4 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/index-map-offset-line-wrong-type.js.map +@@ -0,0 +1,14 @@ ++{ ++ "version": 3, ++ "sections": [ ++ { ++ "offset": { "line": true, "column": 0 }, ++ "map": { ++ "version": 3, ++ "names": [], ++ "sources": ["empty-original.js"], ++ "mappings": "AAAA" ++ } ++ } ++ ] ++} +diff --git a/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-bad-separator.js b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-bad-separator.js +new file mode 100644 +index 0000000000..25338aca30 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-bad-separator.js +@@ -0,0 +1,2 @@ ++function foo(){return 42}function bar(){return 24}foo();bar(); ++//# sourceMappingURL=invalid-mapping-bad-separator.js.map +diff --git a/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-bad-separator.js.map b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-bad-separator.js.map +new file mode 100644 +index 0000000000..5f4f5b9233 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-bad-separator.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version": 3, ++ "names": ["foo","bar"], ++ "sources": ["basic-mapping-original.js"], ++ "mappings": "AAAA.SAASA:MACP" ++} +diff --git a/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-not-a-string-1.js b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-not-a-string-1.js +new file mode 100644 +index 0000000000..cb38e2fe9d +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-not-a-string-1.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=invalid-mapping-not-a-string-1.js.map +diff --git a/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-not-a-string-1.js.map b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-not-a-string-1.js.map +new file mode 100644 +index 0000000000..5bf3e2a9d8 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-not-a-string-1.js.map +@@ -0,0 +1,7 @@ ++{ ++ "version": 3, ++ "names": [], ++ "file": "invalid-mapping-not-a-string-1.js", ++ "sources": ["empty-original.js"], ++ "mappings": 5 ++} +diff --git a/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-not-a-string-2.js b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-not-a-string-2.js +new file mode 100644 +index 0000000000..3d84abd6c6 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-not-a-string-2.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=invalid-mapping-not-a-string-2.js.map +diff --git a/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-not-a-string-2.js.map b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-not-a-string-2.js.map +new file mode 100644 +index 0000000000..4527e7f764 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-not-a-string-2.js.map +@@ -0,0 +1,7 @@ ++{ ++ "version": 3, ++ "names": [], ++ "file": "invalid-mapping-not-a-string-2.js", ++ "sources": ["empty-original.js"], ++ "mappings": [1, 2, 3, 4] ++} +diff --git a/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-column-too-large.js b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-column-too-large.js +new file mode 100644 +index 0000000000..55591f874b +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-column-too-large.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=invalid-mapping-segment-column-too-large.js.map +diff --git a/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-column-too-large.js.map b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-column-too-large.js.map +new file mode 100644 +index 0000000000..b4c059e015 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-column-too-large.js.map +@@ -0,0 +1,7 @@ ++{ ++ "version": 3, ++ "names": [], ++ "file": "invalid-mapping-segment-column-too-large.js", ++ "sources": ["empty-original.js"], ++ "mappings": "ggggggE" ++} +diff --git a/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-name-index-out-of-bounds.js b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-name-index-out-of-bounds.js +new file mode 100644 +index 0000000000..2a6b434eff +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-name-index-out-of-bounds.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=invalid-mapping-segment-name-index-out-of-bounds.js.map +diff --git a/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-name-index-out-of-bounds.js.map b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-name-index-out-of-bounds.js.map +new file mode 100644 +index 0000000000..8dd2ea6c2d +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-name-index-out-of-bounds.js.map +@@ -0,0 +1,7 @@ ++{ ++ "version": 3, ++ "names": ["foo"], ++ "file": "invalid-mapping-segment-name-index-out-of-bounds.js", ++ "sources": ["empty-original.js"], ++ "mappings": "AAAAC" ++} +diff --git a/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-name-index-too-large.js b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-name-index-too-large.js +new file mode 100644 +index 0000000000..709e34dbd3 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-name-index-too-large.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=invalid-mapping-segment-name-index-too-large.js.map +diff --git a/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-name-index-too-large.js.map b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-name-index-too-large.js.map +new file mode 100644 +index 0000000000..c7bf5b98d1 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-name-index-too-large.js.map +@@ -0,0 +1,7 @@ ++{ ++ "version": 3, ++ "names": [], ++ "file": "invalid-mapping-segment-name-index-too-large.js", ++ "sources": ["empty-original.js"], ++ "mappings": "AAAAggggggE" ++} +diff --git a/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-negative-column.js b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-negative-column.js +new file mode 100644 +index 0000000000..a202152d6f +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-negative-column.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=invalid-mapping-segment-negative-column.js.map +diff --git a/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-negative-column.js.map b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-negative-column.js.map +new file mode 100644 +index 0000000000..403878bfa4 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-negative-column.js.map +@@ -0,0 +1,7 @@ ++{ ++ "version": 3, ++ "names": [], ++ "file": "invalid-mapping-segment-negative-column.js", ++ "sources": ["empty-original.js"], ++ "mappings": "F" ++} +diff --git a/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-negative-name-index.js b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-negative-name-index.js +new file mode 100644 +index 0000000000..3e3f634204 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-negative-name-index.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=invalid-mapping-segment-negative-name-index.js.map +diff --git a/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-negative-name-index.js.map b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-negative-name-index.js.map +new file mode 100644 +index 0000000000..b94f63646e +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-negative-name-index.js.map +@@ -0,0 +1,7 @@ ++{ ++ "version": 3, ++ "names": [], ++ "file": "invalid-mapping-segment-negative-name-index.js", ++ "sources": ["empty-original.js"], ++ "mappings": "AAAAF" ++} +diff --git a/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-negative-original-column.js b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-negative-original-column.js +new file mode 100644 +index 0000000000..f21d5342b3 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-negative-original-column.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=invalid-mapping-segment-negative-original-column.js.map +diff --git a/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-negative-original-column.js.map b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-negative-original-column.js.map +new file mode 100644 +index 0000000000..011c639d3f +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-negative-original-column.js.map +@@ -0,0 +1,7 @@ ++{ ++ "version": 3, ++ "names": [], ++ "file": "invalid-mapping-segment-negative-original-column.js", ++ "sources": ["empty-original.js"], ++ "mappings": "AAAF" ++} +diff --git a/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-negative-original-line.js b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-negative-original-line.js +new file mode 100644 +index 0000000000..b37309601c +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-negative-original-line.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=invalid-mapping-segment-negative-original-line.js.map +diff --git a/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-negative-original-line.js.map b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-negative-original-line.js.map +new file mode 100644 +index 0000000000..e7ec993eeb +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-negative-original-line.js.map +@@ -0,0 +1,7 @@ ++{ ++ "version": 3, ++ "names": [], ++ "file": "invalid-mapping-segment-negative-original-line.js", ++ "sources": ["empty-original.js"], ++ "mappings": "AAFA" ++} +diff --git a/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-negative-source-index.js b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-negative-source-index.js +new file mode 100644 +index 0000000000..6e05849b6a +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-negative-source-index.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=invalid-mapping-segment-negative-source-index.js.map +diff --git a/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-negative-source-index.js.map b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-negative-source-index.js.map +new file mode 100644 +index 0000000000..596c2f298b +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-negative-source-index.js.map +@@ -0,0 +1,7 @@ ++{ ++ "version": 3, ++ "names": [], ++ "file": "invalid-mapping-segment-negative-source-index.js", ++ "sources": ["empty-original.js"], ++ "mappings": "AFAA" ++} +diff --git a/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-original-column-too-large.js b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-original-column-too-large.js +new file mode 100644 +index 0000000000..0936ed7ea8 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-original-column-too-large.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=invalid-mapping-segment-original-column-too-large.js.map +diff --git a/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-original-column-too-large.js.map b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-original-column-too-large.js.map +new file mode 100644 +index 0000000000..ff2103fe24 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-original-column-too-large.js.map +@@ -0,0 +1,7 @@ ++{ ++ "version": 3, ++ "names": [], ++ "file": "invalid-mapping-segment-original-column-too-large.js", ++ "sources": ["empty-original.js"], ++ "mappings": "AAAggggggE" ++} +diff --git a/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-original-line-too-large.js b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-original-line-too-large.js +new file mode 100644 +index 0000000000..9b3aa5a361 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-original-line-too-large.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=invalid-mapping-segment-original-line-too-large.js.map +diff --git a/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-original-line-too-large.js.map b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-original-line-too-large.js.map +new file mode 100644 +index 0000000000..890f1c71fc +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-original-line-too-large.js.map +@@ -0,0 +1,7 @@ ++{ ++ "version": 3, ++ "names": [], ++ "file": "invalid-mapping-segment-original-line-too-large.js", ++ "sources": ["empty-original.js"], ++ "mappings": "AAggggggEA" ++} +diff --git a/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-source-index-out-of-bounds.js b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-source-index-out-of-bounds.js +new file mode 100644 +index 0000000000..2e5fbca268 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-source-index-out-of-bounds.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=invalid-mapping-segment-source-index-out-of-bounds.js.map +diff --git a/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-source-index-out-of-bounds.js.map b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-source-index-out-of-bounds.js.map +new file mode 100644 +index 0000000000..86dedb114f +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-source-index-out-of-bounds.js.map +@@ -0,0 +1,7 @@ ++{ ++ "version": 3, ++ "names": [], ++ "file": "invalid-mapping-segment-source-index-out-of-bounds.js", ++ "sources": ["empty-original.js"], ++ "mappings": "ACAA" ++} +diff --git a/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-source-index-too-large.js b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-source-index-too-large.js +new file mode 100644 +index 0000000000..3f4943e127 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-source-index-too-large.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=invalid-mapping-segment-source-index-too-large.js.map +diff --git a/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-source-index-too-large.js.map b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-source-index-too-large.js.map +new file mode 100644 +index 0000000000..e9f858c6e1 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-source-index-too-large.js.map +@@ -0,0 +1,7 @@ ++{ ++ "version": 3, ++ "names": [], ++ "file": "invalid-mapping-segment-source-index-too-large.js", ++ "sources": ["empty-original.js"], ++ "mappings": "AggggggEAA" ++} +diff --git a/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-with-three-fields.js b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-with-three-fields.js +new file mode 100644 +index 0000000000..4b868fac9c +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-with-three-fields.js +@@ -0,0 +1,2 @@ ++function foo(){return 42}function bar(){return 24}foo();bar(); ++//# sourceMappingURL=invalid-mapping-three-fields.js.map +diff --git a/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-with-three-fields.js.map b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-with-three-fields.js.map +new file mode 100644 +index 0000000000..c2af1165ad +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-with-three-fields.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version": 3, ++ "names": ["foo","bar"], ++ "sources": ["basic-mapping-original.js"], ++ "mappings": "AAA" ++} +diff --git a/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-with-two-fields.js b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-with-two-fields.js +new file mode 100644 +index 0000000000..96045a7a11 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-with-two-fields.js +@@ -0,0 +1,2 @@ ++function foo(){return 42}function bar(){return 24}foo();bar(); ++//# sourceMappingURL=invalid-mapping-two-fields.js.map +diff --git a/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-with-two-fields.js.map b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-with-two-fields.js.map +new file mode 100644 +index 0000000000..73cf00fa1c +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-with-two-fields.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version": 3, ++ "names": ["foo","bar"], ++ "sources": ["basic-mapping-original.js"], ++ "mappings": "AA" ++} +diff --git a/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-with-zero-fields.js b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-with-zero-fields.js +new file mode 100644 +index 0000000000..9d5332a56c +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-with-zero-fields.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=invalid-mapping-segment-column-with-zero-fields.js.map +diff --git a/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-with-zero-fields.js.map b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-with-zero-fields.js.map +new file mode 100644 +index 0000000000..5a34d25b64 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/invalid-mapping-segment-with-zero-fields.js.map +@@ -0,0 +1,7 @@ ++{ ++ "version": 3, ++ "names": [], ++ "file": "invalid-mapping-segment-with-zero-fields.js", ++ "sources": ["empty-original.js"], ++ "mappings": ",,,," ++} +diff --git a/front_end/core/sdk/fixtures/sourcemaps/invalid-vlq-non-base64-char.js b/front_end/core/sdk/fixtures/sourcemaps/invalid-vlq-non-base64-char.js +new file mode 100644 +index 0000000000..d1b20b41a2 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/invalid-vlq-non-base64-char.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=invalid-vlq-non-base64-char.js.map +diff --git a/front_end/core/sdk/fixtures/sourcemaps/invalid-vlq-non-base64-char.js.map b/front_end/core/sdk/fixtures/sourcemaps/invalid-vlq-non-base64-char.js.map +new file mode 100644 +index 0000000000..4fa1ac5768 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/invalid-vlq-non-base64-char.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version" : 3, ++ "sources": [], ++ "names": [], ++ "mappings": "A$%?!" ++} +diff --git a/front_end/core/sdk/fixtures/sourcemaps/names-missing.js b/front_end/core/sdk/fixtures/sourcemaps/names-missing.js +new file mode 100644 +index 0000000000..58781fd887 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/names-missing.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=names-missing.js.map +diff --git a/front_end/core/sdk/fixtures/sourcemaps/names-missing.js.map b/front_end/core/sdk/fixtures/sourcemaps/names-missing.js.map +new file mode 100644 +index 0000000000..82170bf784 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/names-missing.js.map +@@ -0,0 +1,5 @@ ++{ ++ "version" : 3, ++ "sources": ["empty-original.js"], ++ "mappings": "" ++} +diff --git a/front_end/core/sdk/fixtures/sourcemaps/names-not-a-list-1.js b/front_end/core/sdk/fixtures/sourcemaps/names-not-a-list-1.js +new file mode 100644 +index 0000000000..dc65f1972b +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/names-not-a-list-1.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=names-not-a-list-1.js.map +diff --git a/front_end/core/sdk/fixtures/sourcemaps/names-not-a-list-1.js.map b/front_end/core/sdk/fixtures/sourcemaps/names-not-a-list-1.js.map +new file mode 100644 +index 0000000000..fe1edaeb96 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/names-not-a-list-1.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version" : 3, ++ "sources": ["source.js"], ++ "names": "not a list", ++ "mappings": "AAAAA" ++} +diff --git a/front_end/core/sdk/fixtures/sourcemaps/names-not-a-list-2.js b/front_end/core/sdk/fixtures/sourcemaps/names-not-a-list-2.js +new file mode 100644 +index 0000000000..d7251f78da +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/names-not-a-list-2.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=names-not-a-list-2.js.map +diff --git a/front_end/core/sdk/fixtures/sourcemaps/names-not-a-list-2.js.map b/front_end/core/sdk/fixtures/sourcemaps/names-not-a-list-2.js.map +new file mode 100644 +index 0000000000..3388d2bb71 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/names-not-a-list-2.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version" : 3, ++ "sources": ["source.js"], ++ "names": { "foo": 3 }, ++ "mappings": "AAAAA" ++} +diff --git a/front_end/core/sdk/fixtures/sourcemaps/names-not-string.js b/front_end/core/sdk/fixtures/sourcemaps/names-not-string.js +new file mode 100644 +index 0000000000..8dc7b4811a +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/names-not-string.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=names-not-string.js.map +diff --git a/front_end/core/sdk/fixtures/sourcemaps/names-not-string.js.map b/front_end/core/sdk/fixtures/sourcemaps/names-not-string.js.map +new file mode 100644 +index 0000000000..c0feb0739a +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/names-not-string.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version" : 3, ++ "sources": ["source.js"], ++ "names": [null, 3, true, false, {}, []], ++ "mappings": "AAAAA" ++} +diff --git a/front_end/core/sdk/fixtures/sourcemaps/source-map-spec-tests.json b/front_end/core/sdk/fixtures/sourcemaps/source-map-spec-tests.json +new file mode 100644 +index 0000000000..7e7350b28e +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/source-map-spec-tests.json +@@ -0,0 +1,573 @@ ++{ ++ "tests": [ ++ { ++ "name": "versionValid", ++ "description": "Test a simple source map with a valid version number", ++ "baseFile": "version-valid.js", ++ "sourceMapFile": "version-valid.js.map", ++ "sourceMapIsValid": true ++ }, ++ { ++ "name": "versionMissing", ++ "description": "Test a source map that is missing a version field", ++ "baseFile": "version-missing.js", ++ "sourceMapFile": "version-missing.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "versionNotANumber", ++ "description": "Test a source map with a version field that is not a number", ++ "baseFile": "version-not-a-number.js", ++ "sourceMapFile": "version-not-a-number.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "versionNumericString", ++ "description": "Test a source map with a version field that is a number as a string", ++ "baseFile": "version-numeric-string.js", ++ "sourceMapFile": "version-numeric-string.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "versionTooHigh", ++ "description": "Test a source map with an integer version field that is too high", ++ "baseFile": "version-too-high.js", ++ "sourceMapFile": "version-too-high.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "versionTooLow", ++ "description": "Test a source map with an integer version field that is too low", ++ "baseFile": "version-too-low.js", ++ "sourceMapFile": "version-too-low.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "sourcesMissing", ++ "description": "Test a source map that is missing a necessary sources field", ++ "baseFile": "sources-missing.js", ++ "sourceMapFile": "sources-missing.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "sourcesNotAList1", ++ "description": "Test a source map with a sources field that is not a valid list (string)", ++ "baseFile": "sources-not-a-list-1.js", ++ "sourceMapFile": "sources-not-a-list-1.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "sourcesNotAList2", ++ "description": "Test a source map with a sources field that is not a valid list (object)", ++ "baseFile": "sources-not-a-list-2.js", ++ "sourceMapFile": "sources-not-a-list-2.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "sourcesNotStringOrNull", ++ "description": "Test a source map with a sources list that has non-string and non-null items", ++ "baseFile": "sources-not-string-or-null.js", ++ "sourceMapFile": "sources-not-string-or-null.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "namesMissing", ++ "description": "Test a source map that is missing a necessary names field", ++ "baseFile": "names-missing.js", ++ "sourceMapFile": "names-missing.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "namesNotAList1", ++ "description": "Test a source map with a names field that is not a valid list (string)", ++ "baseFile": "names-not-a-list-1.js", ++ "sourceMapFile": "names-not-a-list-1.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "namesNotAList2", ++ "description": "Test a source map with a names field that is not a valid list (object)", ++ "baseFile": "names-not-a-list-2.js", ++ "sourceMapFile": "names-not-a-list-2.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "namesNotString", ++ "description": "Test a source map with a names list that has non-string items", ++ "baseFile": "names-not-string.js", ++ "sourceMapFile": "names-not-string.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "unrecognizedProperty", ++ "description": "Test a source map that has an extra field not explicitly encoded in the spec", ++ "baseFile": "unrecognized-property.js", ++ "sourceMapFile": "unrecognized-property.js.map", ++ "sourceMapIsValid": true ++ }, ++ { ++ "name": "invalidVLQDueToNonBase64Character", ++ "description": "Test a source map that has a mapping with an invalid non-base64 character", ++ "baseFile": "invalid-vlq-non-base64-char.js", ++ "sourceMapFile": "invalid-vlq-non-base64-char.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "invalidMappingNotAString1", ++ "description": "Test a source map that has an invalid mapping that is not a string (number)", ++ "baseFile": "invalid-mapping-not-a-string-1.js", ++ "sourceMapFile": "invalid-mapping-not-a-string-1.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "invalidMappingNotAString2", ++ "description": "Test a source map that has an invalid mapping that is not a string (array)", ++ "baseFile": "invalid-mapping-not-a-string-2.js", ++ "sourceMapFile": "invalid-mapping-not-a-string-2.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "invalidMappingSegmentBadSeparator", ++ "description": "Test a source map that uses separator characters not recognized in the spec", ++ "baseFile": "invalid-mapping-bad-separator.js", ++ "sourceMapFile": "invalid-mapping-bad-separator.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "invalidMappingSegmentWithZeroFields", ++ "description": "Test a source map that has the wrong number (zero) of segments fields", ++ "baseFile": "invalid-mapping-segment-with-zero-fields.js", ++ "sourceMapFile": "invalid-mapping-segment-with-zero-fields.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "invalidMappingSegmentWithTwoFields", ++ "description": "Test a source map that has the wrong number (two) of segments fields", ++ "baseFile": "invalid-mapping-segment-with-two-fields.js", ++ "sourceMapFile": "invalid-mapping-segment-with-two-fields.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "invalidMappingSegmentWithThreeFields", ++ "description": "Test a source map that has the wrong number (three) of segments fields", ++ "baseFile": "invalid-mapping-segment-with-three-fields.js", ++ "sourceMapFile": "invalid-mapping-segment-with-three-fields.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "invalidMappingSegmentWithSourceIndexOutOfBounds", ++ "description": "Test a source map that has a source index field that is out of bounds of the sources field", ++ "baseFile": "invalid-mapping-segment-source-index-out-of-bounds.js", ++ "sourceMapFile": "invalid-mapping-segment-source-index-out-of-bounds.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "invalidMappingSegmentWithNameIndexOutOfBounds", ++ "description": "Test a source map that has a name index field that is out of bounds of the names field", ++ "baseFile": "invalid-mapping-segment-name-index-out-of-bounds.js", ++ "sourceMapFile": "invalid-mapping-segment-name-index-out-of-bounds.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "invalidMappingSegmentWithNegativeColumn", ++ "description": "Test a source map that has an invalid negative non-relative column field", ++ "baseFile": "invalid-mapping-segment-negative-column.js", ++ "sourceMapFile": "invalid-mapping-segment-negative-column.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "invalidMappingSegmentWithNegativeSourceIndex", ++ "description": "Test a source map that has an invalid negative non-relative source index field", ++ "baseFile": "invalid-mapping-segment-negative-source-index.js", ++ "sourceMapFile": "invalid-mapping-segment-negative-source-index.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "invalidMappingSegmentWithNegativeOriginalLine", ++ "description": "Test a source map that has an invalid negative non-relative original line field", ++ "baseFile": "invalid-mapping-segment-negative-original-line.js", ++ "sourceMapFile": "invalid-mapping-segment-negative-original-line.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "invalidMappingSegmentWithNegativeOriginalColumn", ++ "description": "Test a source map that has an invalid negative non-relative original column field", ++ "baseFile": "invalid-mapping-segment-negative-original-column.js", ++ "sourceMapFile": "invalid-mapping-segment-negative-original-column.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "invalidMappingSegmentWithNegativeNameIndex", ++ "description": "Test a source map that has an invalid negative non-relative name index field", ++ "baseFile": "invalid-mapping-segment-negative-name-index.js", ++ "sourceMapFile": "invalid-mapping-segment-negative-name-index.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "invalidMappingSegmentWithColumnExceeding32Bits", ++ "description": "Test a source map that has a column field that exceeds 32 bits", ++ "baseFile": "invalid-mapping-segment-column-too-large.js", ++ "sourceMapFile": "invalid-mapping-segment-column-too-large.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "invalidMappingSegmentWithSourceIndexExceeding32Bits", ++ "description": "Test a source map that has a source index field that exceeds 32 bits", ++ "baseFile": "invalid-mapping-segment-source-index-too-large.js", ++ "sourceMapFile": "invalid-mapping-segment-source-index-too-large.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "invalidMappingSegmentWithOriginalLineExceeding32Bits", ++ "description": "Test a source map that has a original line field that exceeds 32 bits", ++ "baseFile": "invalid-mapping-segment-original-line-too-large.js", ++ "sourceMapFile": "invalid-mapping-segment-original-line-too-large.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "invalidMappingSegmentWithOriginalColumnExceeding32Bits", ++ "description": "Test a source map that has an original column field that exceeds 32 bits", ++ "baseFile": "invalid-mapping-segment-original-column-too-large.js", ++ "sourceMapFile": "invalid-mapping-segment-original-column-too-large.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "invalidMappingSegmentWithNameIndexExceeding32Bits", ++ "description": "Test a source map that has a name index field that exceeds 32 bits", ++ "baseFile": "invalid-mapping-segment-name-index-too-large.js", ++ "sourceMapFile": "invalid-mapping-segment-name-index-too-large.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "validMappingFieldsWith32BitMaxValues", ++ "description": "Test a source map that has segment fields with max values representable in 32 bits", ++ "baseFile": "valid-mapping-boundary-values.js", ++ "sourceMapFile": "valid-mapping-boundary-values.js.map", ++ "sourceMapIsValid": true ++ }, ++ { ++ "name": "validMappingLargeVLQ", ++ "description": "Test a source map that has a segment field VLQ that is very long but within 32-bits", ++ "baseFile": "valid-mapping-large-vlq.js", ++ "sourceMapFile": "valid-mapping-large-vlq.js.map", ++ "sourceMapIsValid": true ++ }, ++ { ++ "name": "validMappingEmptyGroups", ++ "description": "Test a source map with a mapping that has many empty groups", ++ "baseFile": "valid-mapping-empty-groups.js", ++ "sourceMapFile": "valid-mapping-empty-groups.js.map", ++ "sourceMapIsValid": true ++ }, ++ { ++ "name": "indexMapInvalidBaseMapings", ++ "description": "Test that an index map cannot also have a regular mappings field", ++ "baseFile": "index-map-invalid-base-mappings.js", ++ "sourceMapFile": "index-map-invalid-base-mappings.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "indexMapInvalidOverlap", ++ "description": "Test that an invalid index map with multiple sections that overlap", ++ "baseFile": "index-map-invalid-overlap.js", ++ "sourceMapFile": "index-map-invalid-overlap.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "indexMapMissingOffset", ++ "description": "Test that an index map that is missing a section offset", ++ "baseFile": "index-map-missing-offset.js", ++ "sourceMapFile": "index-map-missing-offset.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "indexMapMissingOffsetLine", ++ "description": "Test that an index map that is missing a section offset's line field", ++ "baseFile": "index-map-missing-offset-line.js", ++ "sourceMapFile": "index-map-missing-offset-line.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "indexMapMissingOffsetColumn", ++ "description": "Test that an index map that is missing a section offset's column field", ++ "baseFile": "index-map-missing-offset-column.js", ++ "sourceMapFile": "index-map-missing-offset-column.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "indexMapOffsetLineWrongType", ++ "description": "Test that an index map that has an offset line field with the wrong type of value", ++ "baseFile": "index-map-offset-line-wrong-type.js", ++ "sourceMapFile": "index-map-offset-line-wrong-type.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "indexMapOffsetColumnWrongType", ++ "description": "Test that an index map that has an offset column field with the wrong type of value", ++ "baseFile": "index-map-offset-column-wrong-type.js", ++ "sourceMapFile": "index-map-offset-column-wrong-type.js.map", ++ "sourceMapIsValid": false ++ }, ++ { ++ "name": "basicMapping", ++ "description": "Test a simple source map that has several valid mappings", ++ "baseFile": "basic-mapping.js", ++ "sourceMapFile": "basic-mapping.js.map", ++ "sourceMapIsValid": true, ++ "testActions": [ ++ { ++ "actionType": "checkMapping", ++ "generatedLine": 0, ++ "generatedColumn": 0, ++ "originalSource": "basic-mapping-original.js", ++ "originalLine": 0, ++ "originalColumn": 0, ++ "mappedName": null ++ }, ++ { ++ "actionType": "checkMapping", ++ "generatedLine": 0, ++ "generatedColumn": 9, ++ "originalSource": "basic-mapping-original.js", ++ "originalLine": 0, ++ "originalColumn": 9, ++ "mappedName": "foo" ++ }, ++ { ++ "actionType": "checkMapping", ++ "originalSource": "basic-mapping-original.js", ++ "generatedLine": 0, ++ "generatedColumn": 15, ++ "originalLine": 1, ++ "originalColumn": 2, ++ "mappedName": null ++ }, ++ { ++ "actionType": "checkMapping", ++ "originalSource": "basic-mapping-original.js", ++ "generatedLine": 0, ++ "generatedColumn": 22, ++ "originalLine": 1, ++ "originalColumn": 9, ++ "mappedName": null ++ }, ++ { ++ "actionType": "checkMapping", ++ "originalSource": "basic-mapping-original.js", ++ "generatedLine": 0, ++ "generatedColumn": 24, ++ "originalLine": 2, ++ "originalColumn": 0, ++ "mappedName": null ++ }, ++ { ++ "actionType": "checkMapping", ++ "originalSource": "basic-mapping-original.js", ++ "generatedLine": 0, ++ "generatedColumn": 25, ++ "originalLine": 3, ++ "originalColumn": 0, ++ "mappedName": null ++ }, ++ { ++ "actionType": "checkMapping", ++ "generatedLine": 0, ++ "generatedColumn": 34, ++ "originalSource": "basic-mapping-original.js", ++ "originalLine": 3, ++ "originalColumn": 9, ++ "mappedName": "bar" ++ }, ++ { ++ "actionType": "checkMapping", ++ "originalSource": "basic-mapping-original.js", ++ "generatedLine": 0, ++ "generatedColumn": 40, ++ "originalLine": 4, ++ "originalColumn": 2, ++ "mappedName": null ++ }, ++ { ++ "actionType": "checkMapping", ++ "originalSource": "basic-mapping-original.js", ++ "generatedLine": 0, ++ "generatedColumn": 47, ++ "originalLine": 4, ++ "originalColumn": 9, ++ "mappedName": null ++ }, ++ { ++ "actionType": "checkMapping", ++ "originalSource": "basic-mapping-original.js", ++ "generatedLine": 0, ++ "generatedColumn": 49, ++ "originalLine": 5, ++ "originalColumn": 0, ++ "mappedName": null ++ }, ++ { ++ "actionType": "checkMapping", ++ "originalSource": "basic-mapping-original.js", ++ "generatedLine": 0, ++ "generatedColumn": 50, ++ "originalLine": 6, ++ "originalColumn": 0, ++ "mappedName": "foo" ++ }, ++ { ++ "actionType": "checkMapping", ++ "originalSource": "basic-mapping-original.js", ++ "generatedLine": 0, ++ "generatedColumn": 56, ++ "originalLine": 7, ++ "originalColumn": 0, ++ "mappedName": "bar" ++ } ++ ] ++ }, ++ { ++ "name": "basicMappingWithIndexMap", ++ "description": "Test a version of basic-mapping.js.map that is split into sections with an index map", ++ "baseFile": "basic-mapping-as-index-map.js", ++ "sourceMapFile": "basic-mapping-as-index-map.js.map", ++ "sourceMapIsValid": true, ++ "testActions": [ ++ { ++ "actionType": "checkMapping", ++ "generatedLine": 0, ++ "generatedColumn": 0, ++ "originalSource": "basic-mapping-original.js", ++ "originalLine": 0, ++ "originalColumn": 0, ++ "mappedName": null ++ }, ++ { ++ "actionType": "checkMapping", ++ "generatedLine": 0, ++ "generatedColumn": 9, ++ "originalSource": "basic-mapping-original.js", ++ "originalLine": 0, ++ "originalColumn": 9, ++ "mappedName": "foo" ++ }, ++ { ++ "actionType": "checkMapping", ++ "originalSource": "basic-mapping-original.js", ++ "generatedLine": 0, ++ "generatedColumn": 15, ++ "originalLine": 1, ++ "originalColumn": 2, ++ "mappedName": null ++ }, ++ { ++ "actionType": "checkMapping", ++ "originalSource": "basic-mapping-original.js", ++ "generatedLine": 0, ++ "generatedColumn": 22, ++ "originalLine": 1, ++ "originalColumn": 9, ++ "mappedName": null ++ }, ++ { ++ "actionType": "checkMapping", ++ "originalSource": "basic-mapping-original.js", ++ "generatedLine": 0, ++ "generatedColumn": 24, ++ "originalLine": 2, ++ "originalColumn": 0, ++ "mappedName": null ++ }, ++ { ++ "actionType": "checkMapping", ++ "originalSource": "basic-mapping-original.js", ++ "generatedLine": 0, ++ "generatedColumn": 25, ++ "originalLine": 3, ++ "originalColumn": 0, ++ "mappedName": null ++ }, ++ { ++ "actionType": "checkMapping", ++ "generatedLine": 0, ++ "generatedColumn": 34, ++ "originalSource": "basic-mapping-original.js", ++ "originalLine": 3, ++ "originalColumn": 9, ++ "mappedName": "bar" ++ }, ++ { ++ "actionType": "checkMapping", ++ "originalSource": "basic-mapping-original.js", ++ "generatedLine": 0, ++ "generatedColumn": 40, ++ "originalLine": 4, ++ "originalColumn": 2, ++ "mappedName": null ++ }, ++ { ++ "actionType": "checkMapping", ++ "originalSource": "basic-mapping-original.js", ++ "generatedLine": 0, ++ "generatedColumn": 47, ++ "originalLine": 4, ++ "originalColumn": 9, ++ "mappedName": null ++ }, ++ { ++ "actionType": "checkMapping", ++ "originalSource": "basic-mapping-original.js", ++ "generatedLine": 0, ++ "generatedColumn": 49, ++ "originalLine": 5, ++ "originalColumn": 0, ++ "mappedName": null ++ }, ++ { ++ "actionType": "checkMapping", ++ "originalSource": "basic-mapping-original.js", ++ "generatedLine": 0, ++ "generatedColumn": 50, ++ "originalLine": 6, ++ "originalColumn": 0, ++ "mappedName": "foo" ++ }, ++ { ++ "actionType": "checkMapping", ++ "originalSource": "basic-mapping-original.js", ++ "generatedLine": 0, ++ "generatedColumn": 56, ++ "originalLine": 7, ++ "originalColumn": 0, ++ "mappedName": "bar" ++ } ++ ] ++ }, ++ { ++ "name": "validMappingNullSources", ++ "description": "Test a source map that has null sources", ++ "baseFile": "valid-mapping-null-sources.js", ++ "sourceMapFile": "valid-mapping-null-sources.js.map", ++ "sourceMapIsValid": true, ++ "testActions": [ ++ { ++ "actionType": "checkMapping", ++ "generatedLine": 0, ++ "generatedColumn": 0, ++ "originalSource": null, ++ "originalLine": 0, ++ "originalColumn": 0, ++ "mappedName": null ++ }, ++ { ++ "actionType": "checkMapping", ++ "generatedLine": 0, ++ "generatedColumn": 9, ++ "originalSource": null, ++ "originalLine": 0, ++ "originalColumn": 9, ++ "mappedName": "foo" ++ } ++ ] ++ } ++ ] ++} +diff --git a/front_end/core/sdk/fixtures/sourcemaps/sources-missing.js b/front_end/core/sdk/fixtures/sourcemaps/sources-missing.js +new file mode 100644 +index 0000000000..779b865e27 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/sources-missing.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=sources-missing.js.map +diff --git a/front_end/core/sdk/fixtures/sourcemaps/sources-missing.js.map b/front_end/core/sdk/fixtures/sourcemaps/sources-missing.js.map +new file mode 100644 +index 0000000000..92aff4fb0e +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/sources-missing.js.map +@@ -0,0 +1,5 @@ ++{ ++ "version" : 3, ++ "names": ["foo"], ++ "mappings": "" ++} +diff --git a/front_end/core/sdk/fixtures/sourcemaps/sources-not-a-list-1.js b/front_end/core/sdk/fixtures/sourcemaps/sources-not-a-list-1.js +new file mode 100644 +index 0000000000..7e33b7e867 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/sources-not-a-list-1.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=sources-not-a-list-1.js.map +diff --git a/front_end/core/sdk/fixtures/sourcemaps/sources-not-a-list-1.js.map b/front_end/core/sdk/fixtures/sourcemaps/sources-not-a-list-1.js.map +new file mode 100644 +index 0000000000..26330517b9 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/sources-not-a-list-1.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version" : 3, ++ "sources": "not a list", ++ "names": ["foo"], ++ "mappings": "AAAAA" ++} +diff --git a/front_end/core/sdk/fixtures/sourcemaps/sources-not-a-list-2.js b/front_end/core/sdk/fixtures/sourcemaps/sources-not-a-list-2.js +new file mode 100644 +index 0000000000..4021f763fc +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/sources-not-a-list-2.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=sources-not-a-list-2.js.map +diff --git a/front_end/core/sdk/fixtures/sourcemaps/sources-not-a-list-2.js.map b/front_end/core/sdk/fixtures/sourcemaps/sources-not-a-list-2.js.map +new file mode 100644 +index 0000000000..2ed85962fd +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/sources-not-a-list-2.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version" : 3, ++ "sources": { "source.js": 3 }, ++ "names": ["foo"], ++ "mappings": "AAAAA" ++} +diff --git a/front_end/core/sdk/fixtures/sourcemaps/sources-not-string-or-null.js b/front_end/core/sdk/fixtures/sourcemaps/sources-not-string-or-null.js +new file mode 100644 +index 0000000000..7dca97a1da +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/sources-not-string-or-null.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=sources-not-string-or-null.js.map +diff --git a/front_end/core/sdk/fixtures/sourcemaps/sources-not-string-or-null.js.map b/front_end/core/sdk/fixtures/sourcemaps/sources-not-string-or-null.js.map +new file mode 100644 +index 0000000000..db25561966 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/sources-not-string-or-null.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version" : 3, ++ "sources": [3, {}, true, false, []], ++ "names": ["foo"], ++ "mappings": "AAAAA" ++} +diff --git a/front_end/core/sdk/fixtures/sourcemaps/unrecognized-property.js b/front_end/core/sdk/fixtures/sourcemaps/unrecognized-property.js +new file mode 100644 +index 0000000000..19dfb0e2e6 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/unrecognized-property.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=unrecognized-property.js.map +diff --git a/front_end/core/sdk/fixtures/sourcemaps/unrecognized-property.js.map b/front_end/core/sdk/fixtures/sourcemaps/unrecognized-property.js.map +new file mode 100644 +index 0000000000..40bee558a4 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/unrecognized-property.js.map +@@ -0,0 +1,8 @@ ++{ ++ "version" : 3, ++ "sources": [], ++ "names": [], ++ "mappings": "", ++ "foobar": 42, ++ "unusedProperty": [1, 2, 3, 4] ++} +diff --git a/front_end/core/sdk/fixtures/sourcemaps/valid-mapping-boundary-values.js b/front_end/core/sdk/fixtures/sourcemaps/valid-mapping-boundary-values.js +new file mode 100644 +index 0000000000..3c49709e05 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/valid-mapping-boundary-values.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=valid-mapping-boundary-values.js.map +diff --git a/front_end/core/sdk/fixtures/sourcemaps/valid-mapping-boundary-values.js.map b/front_end/core/sdk/fixtures/sourcemaps/valid-mapping-boundary-values.js.map +new file mode 100644 +index 0000000000..4dd836e63d +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/valid-mapping-boundary-values.js.map +@@ -0,0 +1,7 @@ ++{ ++ "version": 3, ++ "names": ["foo"], ++ "file": "valid-mapping-boundary-values.js", ++ "sources": ["empty-original.js"], ++ "mappings": "+/////DA+/////D+/////DA" ++} +diff --git a/front_end/core/sdk/fixtures/sourcemaps/valid-mapping-empty-groups.js b/front_end/core/sdk/fixtures/sourcemaps/valid-mapping-empty-groups.js +new file mode 100644 +index 0000000000..a2b767b619 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/valid-mapping-empty-groups.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=valid-mapping-empty-groups.js.map +diff --git a/front_end/core/sdk/fixtures/sourcemaps/valid-mapping-empty-groups.js.map b/front_end/core/sdk/fixtures/sourcemaps/valid-mapping-empty-groups.js.map +new file mode 100644 +index 0000000000..53be4ae4ae +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/valid-mapping-empty-groups.js.map +@@ -0,0 +1,7 @@ ++{ ++ "version": 3, ++ "names": [], ++ "file": "valid-mapping-empty-groups.js", ++ "sources": ["empty-original.js"], ++ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;" ++} +diff --git a/front_end/core/sdk/fixtures/sourcemaps/valid-mapping-large-vlq.js b/front_end/core/sdk/fixtures/sourcemaps/valid-mapping-large-vlq.js +new file mode 100644 +index 0000000000..b0cd897813 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/valid-mapping-large-vlq.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=valid-mapping-large-vlq.js.map +diff --git a/front_end/core/sdk/fixtures/sourcemaps/valid-mapping-large-vlq.js.map b/front_end/core/sdk/fixtures/sourcemaps/valid-mapping-large-vlq.js.map +new file mode 100644 +index 0000000000..76e18704c4 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/valid-mapping-large-vlq.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version": 3, ++ "names": [], ++ "sources": ["valid-mapping-large-vlq.js"], ++ "mappings": "igggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggA" ++} +diff --git a/front_end/core/sdk/fixtures/sourcemaps/valid-mapping-null-sources.js b/front_end/core/sdk/fixtures/sourcemaps/valid-mapping-null-sources.js +new file mode 100644 +index 0000000000..ee2acf0f5b +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/valid-mapping-null-sources.js +@@ -0,0 +1,2 @@ ++function foo(){return 42}function bar(){return 24}foo();bar(); ++//# sourceMappingURL=valid-mapping-null-sources.js.map +diff --git a/front_end/core/sdk/fixtures/sourcemaps/valid-mapping-null-sources.js.map b/front_end/core/sdk/fixtures/sourcemaps/valid-mapping-null-sources.js.map +new file mode 100644 +index 0000000000..199cda9369 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/valid-mapping-null-sources.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version":3, ++ "names": ["foo"], ++ "sources": [null], ++ "mappings":"AAAA,SAASA" ++} +diff --git a/front_end/core/sdk/fixtures/sourcemaps/version-missing.js b/front_end/core/sdk/fixtures/sourcemaps/version-missing.js +new file mode 100644 +index 0000000000..c32d1f1a1c +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/version-missing.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=version-missing.js.map +diff --git a/front_end/core/sdk/fixtures/sourcemaps/version-missing.js.map b/front_end/core/sdk/fixtures/sourcemaps/version-missing.js.map +new file mode 100644 +index 0000000000..49d8ce766e +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/version-missing.js.map +@@ -0,0 +1,5 @@ ++{ ++ "sources": [], ++ "names": [], ++ "mappings": "" ++} +diff --git a/front_end/core/sdk/fixtures/sourcemaps/version-not-a-number.js b/front_end/core/sdk/fixtures/sourcemaps/version-not-a-number.js +new file mode 100644 +index 0000000000..ae2342e2ff +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/version-not-a-number.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=version-not-a-number.js.map +diff --git a/front_end/core/sdk/fixtures/sourcemaps/version-not-a-number.js.map b/front_end/core/sdk/fixtures/sourcemaps/version-not-a-number.js.map +new file mode 100644 +index 0000000000..a584d6e695 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/version-not-a-number.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version" : "3foo", ++ "sources": [], ++ "names": [], ++ "mappings": "" ++} +diff --git a/front_end/core/sdk/fixtures/sourcemaps/version-numeric-string.js b/front_end/core/sdk/fixtures/sourcemaps/version-numeric-string.js +new file mode 100644 +index 0000000000..a55170885d +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/version-numeric-string.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=version-numeric-string.js.map +diff --git a/front_end/core/sdk/fixtures/sourcemaps/version-numeric-string.js.map b/front_end/core/sdk/fixtures/sourcemaps/version-numeric-string.js.map +new file mode 100644 +index 0000000000..dbe52a7d0d +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/version-numeric-string.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version" : "3", ++ "sources": [], ++ "names": [], ++ "mappings": "" ++} +diff --git a/front_end/core/sdk/fixtures/sourcemaps/version-too-high.js b/front_end/core/sdk/fixtures/sourcemaps/version-too-high.js +new file mode 100644 +index 0000000000..55f4e1a298 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/version-too-high.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=version-too-high.js.map +diff --git a/front_end/core/sdk/fixtures/sourcemaps/version-too-high.js.map b/front_end/core/sdk/fixtures/sourcemaps/version-too-high.js.map +new file mode 100644 +index 0000000000..ee23be32ff +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/version-too-high.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version" : 4, ++ "sources": [], ++ "names": [], ++ "mappings": "" ++} +diff --git a/front_end/core/sdk/fixtures/sourcemaps/version-too-low.js b/front_end/core/sdk/fixtures/sourcemaps/version-too-low.js +new file mode 100644 +index 0000000000..d9642920b3 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/version-too-low.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=version-too-low.js.map +diff --git a/front_end/core/sdk/fixtures/sourcemaps/version-too-low.js.map b/front_end/core/sdk/fixtures/sourcemaps/version-too-low.js.map +new file mode 100644 +index 0000000000..64ca7a6e2e +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/version-too-low.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version" : 2, ++ "sources": [], ++ "names": [], ++ "mappings": "" ++} +diff --git a/front_end/core/sdk/fixtures/sourcemaps/version-valid.js b/front_end/core/sdk/fixtures/sourcemaps/version-valid.js +new file mode 100644 +index 0000000000..82d0bfa1eb +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/version-valid.js +@@ -0,0 +1 @@ ++//# sourceMappingURL=version-valid.js.map +diff --git a/front_end/core/sdk/fixtures/sourcemaps/version-valid.js.map b/front_end/core/sdk/fixtures/sourcemaps/version-valid.js.map +new file mode 100644 +index 0000000000..1a163052d8 +--- /dev/null ++++ b/front_end/core/sdk/fixtures/sourcemaps/version-valid.js.map +@@ -0,0 +1,6 @@ ++{ ++ "version" : 3, ++ "sources": [], ++ "names": [], ++ "mappings": "" ++} +-- +2.39.3 (Apple Git-145) + diff --git a/chrome/SourceMapSpec_test.ts b/chrome/SourceMapSpec_test.ts deleted file mode 100644 index 2c1ab35..0000000 --- a/chrome/SourceMapSpec_test.ts +++ /dev/null @@ -1,107 +0,0 @@ -// Copyright 2019 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -const {assert} = chai; - -import type * as Platform from '../../../../../front_end/core/platform/platform.js'; -import {assertNotNullOrUndefined} from '../../../../../front_end/core/platform/platform.js'; -import { SourceMapV3 } from '../../../../../front_end/core/sdk/SourceMap.js'; -import * as SDK from '../../../../../front_end/core/sdk/sdk.js'; -import {describeWithEnvironment} from '../../helpers/EnvironmentHelpers.js'; - -interface TestSpec { - name: string; - description: string; - baseFile: string; - sourceMapFile: string; - sourceMapIsValid: boolean; - testActions?: TestAction[]; -} - -interface TestAction { - actionType: string; - generatedLine: number; - generatedColumn: number; - originalSource: string; - originalLine: number; - originalColumn: number; - mappedName: null | string; -} - -const testCases = await loadTestCasesFromFixture('source-map-spec-tests.json'); - -describeWithEnvironment.only('SourceMapSpec', async () => { - testCases.forEach(async ({ - baseFile, - sourceMapFile, - testActions, - sourceMapIsValid - }) => { - it('checks mappings', async () => { - if (!sourceMapIsValid) { - return; - } - - const baseFileUrl = baseFile as Platform.DevToolsPath.UrlString; - const sourceMapFileUrl = sourceMapFile as Platform.DevToolsPath.UrlString; - console.log(`loading sourcemap: ${sourceMapFile}`); - const sourceMapContent = await loadSourceMapFromFixture(sourceMapFile); - - const sourceMap = new SDK.SourceMap.SourceMap( - baseFileUrl, - sourceMapFileUrl, - sourceMapContent); - - - if (testActions !== undefined) { - testActions.forEach(({ - actionType, - originalSource, - originalLine, - originalColumn, - generatedLine, - generatedColumn - }) => { - if (actionType === "checkMapping" && sourceMapIsValid) { - const actual = sourceMap.findEntry(generatedLine, generatedColumn); - assertNotNullOrUndefined(actual); - - assert.strictEqual(actual.sourceURL, originalSource, 'unexpected source URL'); - assert.strictEqual(actual.sourceLineNumber, originalLine, 'unexpected source line number'); - assert.strictEqual(actual.sourceColumnNumber, originalColumn, 'unexpected source column number'); - } - }); - } - }); - }); -}); - -async function loadTestCasesFromFixture(filename: string): Promise { - const testSpec = await getFixtureFileContents<{ tests: TestSpec[] }>(filename); - return testSpec?.tests ?? []; -}; - -async function loadSourceMapFromFixture(filename: string): Promise { - return getFixtureFileContents(filename); -}; - -async function getFixtureFileContents(filename: string): - Promise { - - const url = new URL(`/fixtures/sourcemaps/${filename}`, window.location.origin); - - const response = await fetch(url); - - if (response.status !== 200) { - throw new Error(`Unable to load ${url}`); - } - - const contentType = response.headers.get('content-type'); - const isGzipEncoded = contentType !== null && contentType.includes('gzip'); - let buffer = await response.arrayBuffer(); - - const decoder = new TextDecoder('utf-8'); - const contents = JSON.parse(decoder.decode(buffer)) as T; - return contents; -} diff --git a/chrome/sourcemaps-tests-harness-chrome.patch b/chrome/sourcemaps-tests-harness-chrome.patch deleted file mode 100644 index c0994a1..0000000 --- a/chrome/sourcemaps-tests-harness-chrome.patch +++ /dev/null @@ -1,1509 +0,0 @@ -diff --git a/test/e2e/sources/sourcemap_test.ts b/test/e2e/sources/sourcemap_test.ts -index 2db3bc0bab..a672132c18 100644 ---- a/test/e2e/sources/sourcemap_test.ts -+++ b/test/e2e/sources/sourcemap_test.ts -@@ -63,728 +63,788 @@ async function waitForTextContent(selector: string) { - const DEVTOOLS_LINK = '.toolbar-item .devtools-link'; - const INFOBAR_TEXT = '.infobar-info-text'; - --describe('The Sources Tab', async function() { -- // Some of these tests that use instrumentation breakpoints -- // can be slower on mac and windows. Increase the timeout for them. -- if (this.timeout() !== 0) { -- this.timeout(10000); -- } -- -- it('steps over a source line mapping to a range with several statements', async () => { -- const {target, frontend} = getBrowserAndPages(); -- -- await openSourceCodeEditorForFile('sourcemap-stepping-source.js', 'sourcemap-stepping.html'); -- let scriptEvaluation: Promise; -- -- // DevTools is contracting long filenames with ellipses. -- // Let us match the location with regexp to match even contracted locations. -- const breakLocationRegExp = /.*source\.js:12$/; -- const stepLocationRegExp = /.*source\.js:13$/; -- -- await step('Run to breakpoint', async () => { -- await addBreakpointForLine(frontend, 12); -- -- scriptEvaluation = target.evaluate('singleline();'); -- -- const scriptLocation = await waitForStackTopMatch(breakLocationRegExp); -- assert.match(scriptLocation, breakLocationRegExp); -- }); -- -- await step('Step over the mapped line', async () => { -- await click(STEP_OVER_BUTTON); -- -- const stepLocation = await waitForStackTopMatch(stepLocationRegExp); -- assert.match(stepLocation, stepLocationRegExp); -- }); -- -- await step('Resume', async () => { -- await click(RESUME_BUTTON); -- await scriptEvaluation; -- }); -- }); -- -- it('steps over a source line with mappings to several adjacent target lines', async () => { -- const {target, frontend} = getBrowserAndPages(); -- await openSourceCodeEditorForFile('sourcemap-stepping-source.js', 'sourcemap-stepping.html'); -- -- let scriptEvaluation: Promise; -- -- // DevTools is contracting long filenames with ellipses. -- // Let us match the location with regexp to match even contracted locations. -- const breakLocationRegExp = /.*source\.js:4$/; -- const stepLocationRegExp = /.*source\.js:5$/; -- -- await step('Run to breakpoint', async () => { -- await addBreakpointForLine(frontend, 4); -- -- scriptEvaluation = target.evaluate('multiline();'); -- -- const scriptLocation = await waitForStackTopMatch(breakLocationRegExp); -- assert.match(scriptLocation, breakLocationRegExp); -- }); -- -- await step('Step over the mapped line', async () => { -- await click(STEP_OVER_BUTTON); -- -- const stepLocation = await waitForStackTopMatch(stepLocationRegExp); -- assert.match(stepLocation, stepLocationRegExp); -- }); -- -- await step('Resume', async () => { -- await click(RESUME_BUTTON); -- await scriptEvaluation; -- }); -- }); -- -- it('steps out from a function, with source maps available (crbug/1283188)', async () => { -- const {target, frontend} = getBrowserAndPages(); -- await openSourceCodeEditorForFile('sourcemap-stepping-source.js', 'sourcemap-stepping.html'); -- -- let scriptEvaluation: Promise; -- -- // DevTools is contracting long filenames with ellipses. -- // Let us match the location with regexp to match even contracted locations. -- const breakLocationRegExp = /.*source\.js:4$/; -- const stepLocationRegExp = /sourcemap-stepping.html:6$/; -- -- await step('Run to breakpoint', async () => { -- await addBreakpointForLine(frontend, 4); -- -- scriptEvaluation = target.evaluate('outer();'); -- -- const scriptLocation = await waitForStackTopMatch(breakLocationRegExp); -- assert.match(scriptLocation, breakLocationRegExp); -- }); -- -- await step('Step out from breakpoint', async () => { -- await click(STEP_OUT_BUTTON); -- -- const stepLocation = await waitForStackTopMatch(stepLocationRegExp); -- assert.match(stepLocation, stepLocationRegExp); -- }); -- -- await step('Resume', async () => { -- await click(RESUME_BUTTON); -- await scriptEvaluation; -- }); -- }); -- -- it('stepping works at the end of a sourcemapped script (crbug/1305956)', async () => { -- const {target} = getBrowserAndPages(); -- await openSourceCodeEditorForFile('sourcemap-stepping-at-end.js', 'sourcemap-stepping-at-end.html'); -- -- // DevTools is contracting long filenames with ellipses. -- // Let us match the location with regexp to match even contracted locations. -- const breakLocationRegExp = /.*at-end\.js:2$/; -- const stepLocationRegExp = /.*at-end.html:6$/; -- -- for (const [description, button] of [ -- ['into', STEP_INTO_BUTTON], -- ['out', STEP_OUT_BUTTON], -- ['over', STEP_OVER_BUTTON], -- ]) { -- let scriptEvaluation: Promise; -- await step('Run to debugger statement', async () => { -- scriptEvaluation = target.evaluate('outer();'); -- -- const scriptLocation = await waitForStackTopMatch(breakLocationRegExp); -- assert.match(scriptLocation, breakLocationRegExp); -- }); -- -- await step(`Step ${description} from debugger statement`, async () => { -- await click(button); -- -- const stepLocation = await waitForStackTopMatch(stepLocationRegExp); -- assert.match(stepLocation, stepLocationRegExp); -- }); -- -- await step('Resume', async () => { -- await click(RESUME_BUTTON); -- await scriptEvaluation; -- }); -- } -- }); -- -- it('shows unminified identifiers in scopes and console', async () => { -- const {target, frontend} = getBrowserAndPages(); -- await openSourceCodeEditorForFile('sourcemap-minified.js', 'sourcemap-minified.html'); -- -- let scriptEvaluation: Promise; -- const breakLocationRegExp = /sourcemap-minified\.js:1$/; -- -- await step('Run to debugger statement', async () => { -- scriptEvaluation = target.evaluate('sayHello(" world");'); -- -- const scriptLocation = await waitForStackTopMatch(breakLocationRegExp); -- assert.match(scriptLocation, breakLocationRegExp); -- }); -- -- await step('Check local variable is eventually un-minified', async () => { -- const unminifiedVariable = 'element: div'; -- await openSoftContextMenuAndClickOnItem('.cm-line', 'Add source map…'); -- -- // Enter the source map URL into the appropriate input box. -- await click('.add-source-map'); -- await typeText('sourcemap-minified.map'); -- await frontend.keyboard.press('Enter'); -- -- const scopeValues = await waitForFunction(async () => { -- const values = await getValuesForScope('Local', 0, 0); -- return (values && values.includes(unminifiedVariable)) ? values : undefined; -- }); -- assert.include(scopeValues, unminifiedVariable); -- }); -- -- await step('Check that expression evaluation understands unminified name', async () => { -- await frontend.evaluate(`(async () => { -- const Root = await import('./core/root/root.js'); -- Root.Runtime.experiments.setEnabled('evaluateExpressionsWithSourceMaps', true); -- })()`); -- -- await click(CONSOLE_TAB_SELECTOR); -- await focusConsolePrompt(); -- await pasteText('`Hello${text}!`'); -- await frontend.keyboard.press('Enter'); -- -- // Wait for the console to be usable again. -- await frontend.waitForFunction(() => { -- return document.querySelectorAll('.console-user-command-result').length === 1; -- }); -- const messages = await getCurrentConsoleMessages(); -- -- assert.deepEqual(messages, ['\'Hello world!\'']); -- -- await openSourcesPanel(); -- }); -- -- await step('Resume', async () => { -- await click(RESUME_BUTTON); -- await scriptEvaluation; -- }); -- }); -- -- it('shows unminified identifiers in scopes with minified names clash and nested scopes', async () => { -- const {target, frontend} = getBrowserAndPages(); -- await openSourceCodeEditorForFile('sourcemap-scopes-minified.js', 'sourcemap-scopes-minified.html'); -- -- let scriptEvaluation: Promise; -- const breakLocationOuterRegExp = /sourcemap-scopes-minified\.js:2$/; -- const breakLocationInnerRegExp = /sourcemap-scopes-minified\.js:5$/; -- -- const outerUnminifiedVariable = 'arg0: 10'; -- const innerUnminifiedVariable = 'loop_var: 0'; -- -- await step('Run to outer scope breakpoint', async () => { -- await addBreakpointForLine(frontend, 2); -+// describe('The Sources Tab', async function() { -+// // Some of these tests that use instrumentation breakpoints -+// // can be slower on mac and windows. Increase the timeout for them. -+// if (this.timeout() !== 0) { -+// this.timeout(10000); -+// } - -- scriptEvaluation = target.evaluate('foo(10);'); -+// it('steps over a source line mapping to a range with several statements', async () => { -+// const {target, frontend} = getBrowserAndPages(); - -- const scriptLocation = await waitForStackTopMatch(breakLocationOuterRegExp); -- assert.match(scriptLocation, breakLocationOuterRegExp); -- }); -- -- await step('Check local scope variable is eventually un-minified', async () => { -- const scopeValues = await waitForFunction(async () => { -- const values = await getValuesForScope('Local', 0, 0); -- return (values && values.includes(outerUnminifiedVariable)) ? values : undefined; -- }); -- assert.include(scopeValues, outerUnminifiedVariable); -- }); -- -- await step('Resume from outer breakpoint', async () => { -- await addBreakpointForLine(frontend, 5); -- await click(RESUME_BUTTON); -- const scriptLocation = await waitForStackTopMatch(breakLocationInnerRegExp); -- assert.match(scriptLocation, breakLocationInnerRegExp); -- }); -- -- await step('Check local and block scope variables are eventually un-minified', async () => { -- const blockScopeValues = await waitForFunction(async () => { -- const values = await getValuesForScope('Block', 0, 0); -- return (values && values.includes(innerUnminifiedVariable)) ? values : undefined; -- }); -- assert.include(blockScopeValues, innerUnminifiedVariable); -- -- const scopeValues = await waitForFunction(async () => { -- const values = await getValuesForScope('Local', 0, 0); -- return (values && values.includes(outerUnminifiedVariable)) ? values : undefined; -- }); -- assert.include(scopeValues, outerUnminifiedVariable); -- }); -- -- await step('Resume from inner breakpoint', async () => { -- await removeBreakpointForLine(frontend, 2); -- await removeBreakpointForLine(frontend, 5); -- await click(RESUME_BUTTON); -- await scriptEvaluation; -- }); -- }); -- -- it('shows unminified function name in stack trace', async () => { -- const {target, frontend} = getBrowserAndPages(); -- await openSourceCodeEditorForFile( -- 'sourcemap-minified-function-name-compiled.js', 'sourcemap-minified-function-name.html'); -+// await openSourceCodeEditorForFile('sourcemap-stepping-source.js', 'sourcemap-stepping.html'); -+// let scriptEvaluation: Promise; - -- let scriptEvaluation: Promise; -- const breakLocationOuterRegExp = /sourcemap-.*-compiled\.js:1$/; -+// // DevTools is contracting long filenames with ellipses. -+// // Let us match the location with regexp to match even contracted locations. -+// const breakLocationRegExp = /.*source\.js:12$/; -+// const stepLocationRegExp = /.*source\.js:13$/; - -- await step('Run to breakpoint', async () => { -- scriptEvaluation = target.evaluate('o(1, 2)'); -+// await step('Run to breakpoint', async () => { -+// await addBreakpointForLine(frontend, 12); - -- const scriptLocation = await waitForStackTopMatch(breakLocationOuterRegExp); -- assert.match(scriptLocation, breakLocationOuterRegExp); -- }); -- -- await step('Add source map', async () => { -- await openSoftContextMenuAndClickOnItem('.cm-line', 'Add source map…'); -+// scriptEvaluation = target.evaluate('singleline();'); - -- // Enter the source map URL into the appropriate input box. -- await click('.add-source-map'); -- await typeText('sourcemap-minified-function-name-compiled.map'); -- await frontend.keyboard.press('Enter'); -- }); -+// const scriptLocation = await waitForStackTopMatch(breakLocationRegExp); -+// assert.match(scriptLocation, breakLocationRegExp); -+// }); - -- await step('Check function name is eventually un-minified', async () => { -- const functionName = await waitForFunction(async () => { -- const functionName = await waitForTextContent('.call-frame-title-text'); -- return functionName && functionName === 'unminified' ? functionName : undefined; -- }); -- assert.strictEqual(functionName, 'unminified'); -- }); -+// await step('Step over the mapped line', async () => { -+// await click(STEP_OVER_BUTTON); - -- await step('Resume execution', async () => { -- await click(RESUME_BUTTON); -- await scriptEvaluation; -- }); -- }); -+// const stepLocation = await waitForStackTopMatch(stepLocationRegExp); -+// assert.match(stepLocation, stepLocationRegExp); -+// }); - -- // TODO(crbug.com/1346228) Flaky - timeouts. -- it.skip('[crbug.com/1346228] automatically ignore-lists third party code from source maps', async function() { -- const {target} = getBrowserAndPages(); -- await openSourceCodeEditorForFile('webpack-main.js', 'webpack-index.html'); -+// await step('Resume', async () => { -+// await click(RESUME_BUTTON); -+// await scriptEvaluation; -+// }); -+// }); -+ -+// it('steps over a source line with mappings to several adjacent target lines', async () => { -+// const {target, frontend} = getBrowserAndPages(); -+// await openSourceCodeEditorForFile('sourcemap-stepping-source.js', 'sourcemap-stepping.html'); -+ -+// let scriptEvaluation: Promise; - -- let scriptEvaluation: Promise; -- const breakLocationOuterRegExp = /index\.js:12$/; -+// // DevTools is contracting long filenames with ellipses. -+// // Let us match the location with regexp to match even contracted locations. -+// const breakLocationRegExp = /.*source\.js:4$/; -+// const stepLocationRegExp = /.*source\.js:5$/; - -- await step('Run to breakpoint', async () => { -- scriptEvaluation = target.evaluate('window.foo()'); -+// await step('Run to breakpoint', async () => { -+// await addBreakpointForLine(frontend, 4); - -- const scriptLocation = await waitForStackTopMatch(breakLocationOuterRegExp); -- assert.match(scriptLocation, breakLocationOuterRegExp); -- assert.deepEqual(await getCallFrameNames(), ['baz', 'bar', 'foo', '(anonymous)']); -- }); -+// scriptEvaluation = target.evaluate('multiline();'); - -- await step('Toggle to show ignore-listed frames', async () => { -- await click('.ignore-listed-message-label'); -- await waitFor('.ignore-listed-call-frame:not(.hidden)'); -- assert.deepEqual(await getCallFrameNames(), ['baz', 'vendor', 'bar', 'foo', '(anonymous)']); -- }); -+// const scriptLocation = await waitForStackTopMatch(breakLocationRegExp); -+// assert.match(scriptLocation, breakLocationRegExp); -+// }); - -- await step('Toggle back off', async () => { -- await click('.ignore-listed-message-label'); -- await waitFor('.ignore-listed-call-frame.hidden'); -- assert.deepEqual(await getCallFrameNames(), ['baz', 'bar', 'foo', '(anonymous)']); -- }); -+// await step('Step over the mapped line', async () => { -+// await click(STEP_OVER_BUTTON); - -- await step('Resume execution', async () => { -- await click(RESUME_BUTTON); -- await scriptEvaluation; -- }); -- }); -+// const stepLocation = await waitForStackTopMatch(stepLocationRegExp); -+// assert.match(stepLocation, stepLocationRegExp); -+// }); - -- it('updates decorators for removed breakpoints in case of code-splitting (crbug.com/1251675)', async () => { -- const {frontend} = getBrowserAndPages(); -- await openSourceCodeEditorForFile('sourcemap-disjoint.js', 'sourcemap-disjoint.html'); -- assert.deepEqual(await getBreakpointDecorators(), []); -- await addBreakpointForLine(frontend, 2); -- assert.deepEqual(await getBreakpointDecorators(), [2]); -- await removeBreakpointForLine(frontend, 2); -- assert.deepEqual(await getBreakpointDecorators(), []); -- }); -- -- it('reliably hits breakpoints on worker with source map', async () => { -- await enableExperiment('instrumentationBreakpoints'); -- const {target, frontend} = getBrowserAndPages(); -- await openSourceCodeEditorForFile('sourcemap-stepping-source.js', 'sourcemap-breakpoint.html'); -- -- await step('Add a breakpoint at first line of function multiline', async () => { -- await addBreakpointForLine(frontend, 4); -- }); -- -- await step('Navigate to a different site to refresh devtools and remove back-end state', async () => { -- await refreshDevToolsAndRemoveBackendState(target); -- }); -- -- await step('Navigate back to test page', () => { -- void goToResource('sources/sourcemap-breakpoint.html'); -- }); -- -- await step('wait for pause and check if we stopped at line 4', async () => { -- await waitFor(PAUSE_INDICATOR_SELECTOR); -- await waitForFunction(async () => { -- const topCallFrame = await retrieveTopCallFrameWithoutResuming(); -- return topCallFrame === 'sourcemap-stepping-source.js:4'; -- }); -- }); -- -- await step('Resume', async () => { -- await click(RESUME_BUTTON); -- }); -- }); -- -- it('links to the correct origins for source-mapped resources', async () => { -- await goToResource('sources/sourcemap-origin.html'); -- await openSourcesPanel(); -- -- await step('Check origin of source-mapped JavaScript', async () => { -- await openFileInEditor('sourcemap-origin.js'); -- const linkText = await waitForTextContent(DEVTOOLS_LINK); -- assert.strictEqual(linkText, 'sourcemap-origin.min.js'); -- }); -- -- await step('Check origin of source-mapped SASS', async () => { -- await openFileInEditor('sourcemap-origin.scss'); -- const linkText = await waitForTextContent(DEVTOOLS_LINK); -- assert.strictEqual(linkText, 'sourcemap-origin.css'); -- }); -- -- await step('Check origin of source-mapped JavaScript with URL clash', async () => { -- await openFileInEditor('sourcemap-origin.clash.js'); -- const linkText = await waitForTextContent(DEVTOOLS_LINK); -- assert.strictEqual(linkText, 'sourcemap-origin.clash.js'); -- }); -- }); -- -- it('shows Source map loaded infobar', async () => { -- await goToResource('sources/sourcemap-origin.html'); -- await openSourcesPanel(); -- -- await step('Get infobar text', async () => { -- await openFileInEditor('sourcemap-origin.min.js'); -- const infobarText = await waitForTextContent(INFOBAR_TEXT); -- assert.strictEqual(infobarText, 'Source map loaded.'); -- }); -- }); -- -- it('shows Source map loaded infobar after attaching', async () => { -- const {frontend} = getBrowserAndPages(); -- await openSourceCodeEditorForFile('sourcemap-minified.js', 'sourcemap-minified.html'); -- -- await step('Attach source map', async () => { -- await openSoftContextMenuAndClickOnItem('.cm-line', 'Add source map…'); -- -- // Enter the source map URL into the appropriate input box. -- await click('.add-source-map'); -- await typeText('sourcemap-minified.map'); -- await frontend.keyboard.press('Enter'); -- }); -- -- await step('Get infobar text', async () => { -- const infobarText = await waitForTextContent(INFOBAR_TEXT); -- assert.strictEqual(infobarText, 'Source map loaded.'); -- }); -- }); -- -- it('shows Source map skipped infobar', async () => { -- await setIgnoreListPattern('.min.js'); -- await openSourceCodeEditorForFile('sourcemap-origin.min.js', 'sourcemap-origin.html'); -- -- await step('Get infobar texts', async () => { -- await openFileInEditor('sourcemap-origin.min.js'); -- await waitFor('.infobar-warning'); -- await waitFor('.infobar-info'); -- const infobarTexts = await getVisibleTextContents(INFOBAR_TEXT); -- assert.deepEqual( -- infobarTexts, ['This script is on the debugger\'s ignore list', 'Source map skipped for this file.']); -- }); -- }); -- -- it('shows Source map error infobar after failing to attach', async () => { -- const {frontend} = getBrowserAndPages(); -- await openSourceCodeEditorForFile('sourcemap-minified.js', 'sourcemap-minified.html'); -- -- await step('Attach source map', async () => { -- await openSoftContextMenuAndClickOnItem('.cm-line', 'Add source map…'); -- -- // Enter the source map URL into the appropriate input box. -- await click('.add-source-map'); -- await typeText('sourcemap-invalid.map'); -- await frontend.keyboard.press('Enter'); -- }); -- -- await step('Get infobar text', async () => { -- const infobarText = await waitForTextContent(INFOBAR_TEXT); -- assert.strictEqual(infobarText, 'Source map failed to load.'); -- }); -- }); -- -- describe('can deal with code-splitting', () => { -- it('sets multiple breakpoints in case of code-splitting', async () => { -- const {target, frontend} = getBrowserAndPages(); -- await openSourceCodeEditorForFile('sourcemap-codesplit.ts', 'sourcemap-codesplit.html'); -- await addBreakpointForLine(frontend, 3); -- -- for (let i = 0; i < 2; ++i) { -- const scriptLocation = await retrieveTopCallFrameScriptLocation(`functions[${i}]();`, target); -- assert.deepEqual(scriptLocation, 'sourcemap-codesplit.ts:3'); -- } -- }); -- -- it('restores breakpoints correctly in case of code-splitting (crbug.com/1412033)', async () => { -- const {target, frontend} = getBrowserAndPages(); -- -- // Load the initial setup with only one script pointing to `codesplitting-bar.ts`... -- await openSourceCodeEditorForFile('codesplitting-bar.ts', 'codesplitting.html'); -- -- // ...and set a breakpoint inside `bar()`. -- await addBreakpointForLine(frontend, 2); -- -- // Now load the second script pointing to `codesplitting-bar.ts`... -- await target.evaluate('addSecond();'); -- -- // ...wait for the new origin to be listed... -- const linkTexts = await waitForFunction(async () => { -- const links = await $$(DEVTOOLS_LINK); -- const linkTexts = await Promise.all(links.map(node => node.evaluate(({textContent}) => textContent))); -- if (linkTexts.length === 1 && linkTexts[0] === 'codesplitting-first.js') { -- return undefined; -- } -- return linkTexts; -- }); -- assert.sameMembers(linkTexts, ['codesplitting-first.js', 'codesplitting-second.js']); -- -- // ...and eventually wait for the breakpoint to be restored in line 2. -- await waitForFunction(async () => await isBreakpointSet(2)); -- -- // Eventually we should stop on the breakpoint in the `codesplitting-second.js`. -- await waitForFunction(() => { -- return Promise.race([ -- target.evaluate('second()').then(() => false), -- waitFor(PAUSE_INDICATOR_SELECTOR).then(() => true), -- ]); -- }); -- await click(RESUME_BUTTON); -- }); -- -- it('hits breakpoints reliably after reload in case of code-splitting (crbug.com/1490369)', async () => { -- const {target, frontend} = getBrowserAndPages(); -- -- // Set the breakpoint inside `shared()` in `shared.js`. -- await openSourceCodeEditorForFile('shared.js', 'codesplitting-race.html'); -- await addBreakpointForLine(frontend, 2); -- await waitForFunction(async () => await isBreakpointSet(2)); -- -- // Reload the page. -- const reloadPromise = target.reload(); -- -- // Now the debugger should pause twice reliably. -- await waitFor(PAUSE_INDICATOR_SELECTOR); -- await click(RESUME_BUTTON); -- await waitFor(PAUSE_INDICATOR_SELECTOR); -- await click(RESUME_BUTTON); -- -- await reloadPromise; -- }); -- }); -- -- describe('can deal with hot module replacement', () => { -- // The tests in here simulate Hot Module Replacement (HMR) workflows related -- // to how DevTools deals with source maps in these situations. -- -- it('correctly handles URL clashes between compiled and source-mapped scripts', async () => { -- const {target} = getBrowserAndPages(); -- -- // Load the "initial bundle"... -- await openSourceCodeEditorForFile('index.js', 'sourcemap-hmr.html'); -- -- // ...and check that index.js content is as expected. -- // In particular, this asserts that the front-end does not get creative in -- // appending suffixes like '? [sm]' to the index.js here. -- const initialContent = await retrieveCodeMirrorEditorContent(); -- assert.deepEqual(initialContent, [ -- 'globalThis.hello = () => {', -- ' console.log("Hello world!");', -- '}', -- '', -- ]); -- -- // Simulate the hot module replacement for index.js... -- await target.evaluate('update();'); -- -- // ...and wait for its content to load (should just replace -- // the existing tab contents for index.js). We perform this -- // check by waiting until the editor contents differ from -- // the initial contents, and then asserting that it looks -- // as expected afterwards. -- const updatedContent = await waitForFunction(async () => { -- const content = await retrieveCodeMirrorEditorContent(); -- if (content.length !== initialContent.length) { -- return content; -- } -- for (let i = 0; i < content.length; ++i) { -- if (content[i] !== initialContent[i]) { -- return content; -- } -- } -- return undefined; -- }); -- assert.deepEqual(updatedContent, [ -- 'globalThis.hello = () => {', -- ' console.log("Hello UPDATED world!");', -- '}', -- '', -- ]); -- }); -- -- it('correctly maintains breakpoints from initial bundle to replacement', async () => { -- const {target, frontend} = getBrowserAndPages(); -- -- // Load the "initial bundle" and set a breakpoint on the second line. -- await openSourceCodeEditorForFile('index.js', 'sourcemap-hmr.html'); -- await addBreakpointForLine(frontend, 2); -- -- // Simulate the hot module replacement for index.js -- await target.evaluate('update();'); -- -- // Wait for the "hot module replacement" to take effect for index.js. -- await waitForFunction(async () => { -- const content = await retrieveCodeMirrorEditorContent(); -- return content[1].includes('UPDATED'); -- }); -- -- // Wait for the breakpoint to appear on line 2 of the updated index.js. -- await waitForFunction(async () => await isBreakpointSet(2)); -- }); -- -- it('correctly maintains breakpoints from replacement to initial bundle (across reloads)', async () => { -- const {target, frontend} = getBrowserAndPages(); -- -- // Load the "initial bundle". -- await openSourceCodeEditorForFile('index.js', 'sourcemap-hmr.html'); -- -- // Simulate the hot module replacement for index.js -- await target.evaluate('update();'); -- -- // Wait for the "hot module replacement" to take effect for index.js. -- await waitForFunction(async () => { -- const content = await retrieveCodeMirrorEditorContent(); -- return content[1].includes('UPDATED'); -- }); -- -- // Set a breakpoint on the second line. -- await addBreakpointForLine(frontend, 2); -- -- // Reload the page and re-open (the initial) index.js. -- await reloadPageAndWaitForSourceFile(target, 'index.js'); -- -- // Check that the breakpoint still exists on line 2. -- assert.isTrue(await isBreakpointSet(2)); -- }); -- }); -- -- it('can attach sourcemaps to CSS files from a context menu', async () => { -- await openSourceCodeEditorForFile('sourcemap-css.css', 'sourcemap-css-noinline.html'); -- -- await click('aria/Code editor', {clickOptions: {button: 'right'}}); -- await click('aria/Add source map…'); -- await waitFor('.add-source-map'); -- await typeText('sourcemap-css-absolute.map'); -- await pressKey('Enter'); -- -- await waitFor('[aria-label="app.scss, file"]'); -- }); --}); -- --describe('The Elements Tab', async () => { -- async function clickStyleValueWithModifiers(selector: string, name: string, value: string, location: string) { -- const element = await waitForCSSPropertyValue(selector, name, value, location); -- // Click with offset to skip swatches. -- await withControlOrMetaKey(() => clickElement(element, {clickOptions: {offset: {x: 20, y: 5}}})); -- } -- -- it('links to the right SASS source for inline CSS with relative sourcemap (crbug.com/787792)', async () => { -- await goToResource('sources/sourcemap-css-inline-relative.html'); -- await step('Prepare elements tab', async () => { -- await waitForElementsStyleSection(); -- await waitForContentOfSelectedElementsNode('\u200B'); -- await focusElementsTree(); -- await clickNthChildOfSelectedElementNode(1); -- }); -- await clickStyleValueWithModifiers('body .text', 'color', 'green', 'app.scss:6'); -- await waitForElementWithTextContent('Line 12, Column 9'); -- }); -- -- it('links to the right SASS source for inline CSS with absolute sourcemap (crbug.com/787792)', async () => { -- await goToResource('sources/sourcemap-css-dynamic-link.html'); -- await step('Prepare elements tab', async () => { -- await waitForElementsStyleSection(); -- await waitForContentOfSelectedElementsNode('\u200B'); -- await focusElementsTree(); -- await clickNthChildOfSelectedElementNode(1); -- }); -- await clickStyleValueWithModifiers('body .text', 'color', 'green', 'app.scss:6'); -- await waitForElementWithTextContent('Line 12, Column 9'); -- }); -- -- it('links to the right SASS source for dynamically added CSS style tags (crbug.com/787792)', async () => { -- await goToResource('sources/sourcemap-css-dynamic.html'); -- await step('Prepare elements tab', async () => { -- await waitForElementsStyleSection(); -- await waitForContentOfSelectedElementsNode('\u200B'); -- await focusElementsTree(); -- await clickNthChildOfSelectedElementNode(1); -- }); -- await clickStyleValueWithModifiers('body .text', 'color', 'green', 'app.scss:6'); -- await waitForElementWithTextContent('Line 12, Column 9'); -- }); -- -- it('links to the right SASS source for dynamically added CSS link tags (crbug.com/787792)', async () => { -- await goToResource('sources/sourcemap-css-dynamic-link.html'); -- await step('Prepare elements tab', async () => { -- await waitForElementsStyleSection(); -- await waitForContentOfSelectedElementsNode('\u200B'); -- await focusElementsTree(); -- await clickNthChildOfSelectedElementNode(1); -- }); -- await clickStyleValueWithModifiers('body .text', 'color', 'green', 'app.scss:6'); -- await waitForElementWithTextContent('Line 12, Column 9'); -- }); --}); -+// await step('Resume', async () => { -+// await click(RESUME_BUTTON); -+// await scriptEvaluation; -+// }); -+// }); -+ -+// it('steps out from a function, with source maps available (crbug/1283188)', async () => { -+// const {target, frontend} = getBrowserAndPages(); -+// await openSourceCodeEditorForFile('sourcemap-stepping-source.js', 'sourcemap-stepping.html'); -+ -+// let scriptEvaluation: Promise; -+ -+// // DevTools is contracting long filenames with ellipses. -+// // Let us match the location with regexp to match even contracted locations. -+// const breakLocationRegExp = /.*source\.js:4$/; -+// const stepLocationRegExp = /sourcemap-stepping.html:6$/; -+ -+// await step('Run to breakpoint', async () => { -+// await addBreakpointForLine(frontend, 4); -+ -+// scriptEvaluation = target.evaluate('outer();'); -+ -+// const scriptLocation = await waitForStackTopMatch(breakLocationRegExp); -+// assert.match(scriptLocation, breakLocationRegExp); -+// }); -+ -+// await step('Step out from breakpoint', async () => { -+// await click(STEP_OUT_BUTTON); -+ -+// const stepLocation = await waitForStackTopMatch(stepLocationRegExp); -+// assert.match(stepLocation, stepLocationRegExp); -+// }); -+ -+// await step('Resume', async () => { -+// await click(RESUME_BUTTON); -+// await scriptEvaluation; -+// }); -+// }); -+ -+// it('stepping works at the end of a sourcemapped script (crbug/1305956)', async () => { -+// const {target} = getBrowserAndPages(); -+// await openSourceCodeEditorForFile('sourcemap-stepping-at-end.js', 'sourcemap-stepping-at-end.html'); -+ -+// // DevTools is contracting long filenames with ellipses. -+// // Let us match the location with regexp to match even contracted locations. -+// const breakLocationRegExp = /.*at-end\.js:2$/; -+// const stepLocationRegExp = /.*at-end.html:6$/; -+ -+// for (const [description, button] of [ -+// ['into', STEP_INTO_BUTTON], -+// ['out', STEP_OUT_BUTTON], -+// ['over', STEP_OVER_BUTTON], -+// ]) { -+// let scriptEvaluation: Promise; -+// await step('Run to debugger statement', async () => { -+// scriptEvaluation = target.evaluate('outer();'); -+ -+// const scriptLocation = await waitForStackTopMatch(breakLocationRegExp); -+// assert.match(scriptLocation, breakLocationRegExp); -+// }); -+ -+// await step(`Step ${description} from debugger statement`, async () => { -+// await click(button); -+ -+// const stepLocation = await waitForStackTopMatch(stepLocationRegExp); -+// assert.match(stepLocation, stepLocationRegExp); -+// }); -+ -+// await step('Resume', async () => { -+// await click(RESUME_BUTTON); -+// await scriptEvaluation; -+// }); -+// } -+// }); -+ -+// it('shows unminified identifiers in scopes and console', async () => { -+// const {target, frontend} = getBrowserAndPages(); -+// await openSourceCodeEditorForFile('sourcemap-minified.js', 'sourcemap-minified.html'); -+ -+// let scriptEvaluation: Promise; -+// const breakLocationRegExp = /sourcemap-minified\.js:1$/; -+ -+// await step('Run to debugger statement', async () => { -+// scriptEvaluation = target.evaluate('sayHello(" world");'); -+ -+// const scriptLocation = await waitForStackTopMatch(breakLocationRegExp); -+// assert.match(scriptLocation, breakLocationRegExp); -+// }); -+ -+// await step('Check local variable is eventually un-minified', async () => { -+// const unminifiedVariable = 'element: div'; -+// await openSoftContextMenuAndClickOnItem('.cm-line', 'Add source map…'); -+ -+// // Enter the source map URL into the appropriate input box. -+// await click('.add-source-map'); -+// await typeText('sourcemap-minified.map'); -+// await frontend.keyboard.press('Enter'); -+ -+// const scopeValues = await waitForFunction(async () => { -+// const values = await getValuesForScope('Local', 0, 0); -+// return (values && values.includes(unminifiedVariable)) ? values : undefined; -+// }); -+// assert.include(scopeValues, unminifiedVariable); -+// }); -+ -+// await step('Check that expression evaluation understands unminified name', async () => { -+// await frontend.evaluate(`(async () => { -+// const Root = await import('./core/root/root.js'); -+// Root.Runtime.experiments.setEnabled('evaluateExpressionsWithSourceMaps', true); -+// })()`); -+ -+// await click(CONSOLE_TAB_SELECTOR); -+// await focusConsolePrompt(); -+// await pasteText('`Hello${text}!`'); -+// await frontend.keyboard.press('Enter'); -+ -+// // Wait for the console to be usable again. -+// await frontend.waitForFunction(() => { -+// return document.querySelectorAll('.console-user-command-result').length === 1; -+// }); -+// const messages = await getCurrentConsoleMessages(); -+ -+// assert.deepEqual(messages, ['\'Hello world!\'']); -+ -+// await openSourcesPanel(); -+// }); -+ -+// await step('Resume', async () => { -+// await click(RESUME_BUTTON); -+// await scriptEvaluation; -+// }); -+// }); -+ -+// it('shows unminified identifiers in scopes with minified names clash and nested scopes', async () => { -+// const {target, frontend} = getBrowserAndPages(); -+// await openSourceCodeEditorForFile('sourcemap-scopes-minified.js', 'sourcemap-scopes-minified.html'); -+ -+// let scriptEvaluation: Promise; -+// const breakLocationOuterRegExp = /sourcemap-scopes-minified\.js:2$/; -+// const breakLocationInnerRegExp = /sourcemap-scopes-minified\.js:5$/; -+ -+// const outerUnminifiedVariable = 'arg0: 10'; -+// const innerUnminifiedVariable = 'loop_var: 0'; -+ -+// await step('Run to outer scope breakpoint', async () => { -+// await addBreakpointForLine(frontend, 2); -+ -+// scriptEvaluation = target.evaluate('foo(10);'); -+ -+// const scriptLocation = await waitForStackTopMatch(breakLocationOuterRegExp); -+// assert.match(scriptLocation, breakLocationOuterRegExp); -+// }); -+ -+// await step('Check local scope variable is eventually un-minified', async () => { -+// const scopeValues = await waitForFunction(async () => { -+// const values = await getValuesForScope('Local', 0, 0); -+// return (values && values.includes(outerUnminifiedVariable)) ? values : undefined; -+// }); -+// assert.include(scopeValues, outerUnminifiedVariable); -+// }); -+ -+// await step('Resume from outer breakpoint', async () => { -+// await addBreakpointForLine(frontend, 5); -+// await click(RESUME_BUTTON); -+// const scriptLocation = await waitForStackTopMatch(breakLocationInnerRegExp); -+// assert.match(scriptLocation, breakLocationInnerRegExp); -+// }); -+ -+// await step('Check local and block scope variables are eventually un-minified', async () => { -+// const blockScopeValues = await waitForFunction(async () => { -+// const values = await getValuesForScope('Block', 0, 0); -+// return (values && values.includes(innerUnminifiedVariable)) ? values : undefined; -+// }); -+// assert.include(blockScopeValues, innerUnminifiedVariable); -+ -+// const scopeValues = await waitForFunction(async () => { -+// const values = await getValuesForScope('Local', 0, 0); -+// return (values && values.includes(outerUnminifiedVariable)) ? values : undefined; -+// }); -+// assert.include(scopeValues, outerUnminifiedVariable); -+// }); -+ -+// await step('Resume from inner breakpoint', async () => { -+// await removeBreakpointForLine(frontend, 2); -+// await removeBreakpointForLine(frontend, 5); -+// await click(RESUME_BUTTON); -+// await scriptEvaluation; -+// }); -+// }); -+ -+// it('shows unminified function name in stack trace', async () => { -+// const {target, frontend} = getBrowserAndPages(); -+// await openSourceCodeEditorForFile( -+// 'sourcemap-minified-function-name-compiled.js', 'sourcemap-minified-function-name.html'); -+ -+// let scriptEvaluation: Promise; -+// const breakLocationOuterRegExp = /sourcemap-.*-compiled\.js:1$/; -+ -+// await step('Run to breakpoint', async () => { -+// scriptEvaluation = target.evaluate('o(1, 2)'); -+ -+// const scriptLocation = await waitForStackTopMatch(breakLocationOuterRegExp); -+// assert.match(scriptLocation, breakLocationOuterRegExp); -+// }); -+ -+// await step('Add source map', async () => { -+// await openSoftContextMenuAndClickOnItem('.cm-line', 'Add source map…'); -+ -+// // Enter the source map URL into the appropriate input box. -+// await click('.add-source-map'); -+// await typeText('sourcemap-minified-function-name-compiled.map'); -+// await frontend.keyboard.press('Enter'); -+// }); -+ -+// await step('Check function name is eventually un-minified', async () => { -+// const functionName = await waitForFunction(async () => { -+// const functionName = await waitForTextContent('.call-frame-title-text'); -+// return functionName && functionName === 'unminified' ? functionName : undefined; -+// }); -+// assert.strictEqual(functionName, 'unminified'); -+// }); -+ -+// await step('Resume execution', async () => { -+// await click(RESUME_BUTTON); -+// await scriptEvaluation; -+// }); -+// }); -+ -+// // TODO(crbug.com/1346228) Flaky - timeouts. -+// it.skip('[crbug.com/1346228] automatically ignore-lists third party code from source maps', async function() { -+// const {target} = getBrowserAndPages(); -+// await openSourceCodeEditorForFile('webpack-main.js', 'webpack-index.html'); -+ -+// let scriptEvaluation: Promise; -+// const breakLocationOuterRegExp = /index\.js:12$/; -+ -+// await step('Run to breakpoint', async () => { -+// scriptEvaluation = target.evaluate('window.foo()'); -+ -+// const scriptLocation = await waitForStackTopMatch(breakLocationOuterRegExp); -+// assert.match(scriptLocation, breakLocationOuterRegExp); -+// assert.deepEqual(await getCallFrameNames(), ['baz', 'bar', 'foo', '(anonymous)']); -+// }); -+ -+// await step('Toggle to show ignore-listed frames', async () => { -+// await click('.ignore-listed-message-label'); -+// await waitFor('.ignore-listed-call-frame:not(.hidden)'); -+// assert.deepEqual(await getCallFrameNames(), ['baz', 'vendor', 'bar', 'foo', '(anonymous)']); -+// }); -+ -+// await step('Toggle back off', async () => { -+// await click('.ignore-listed-message-label'); -+// await waitFor('.ignore-listed-call-frame.hidden'); -+// assert.deepEqual(await getCallFrameNames(), ['baz', 'bar', 'foo', '(anonymous)']); -+// }); -+ -+// await step('Resume execution', async () => { -+// await click(RESUME_BUTTON); -+// await scriptEvaluation; -+// }); -+// }); -+ -+// it('updates decorators for removed breakpoints in case of code-splitting (crbug.com/1251675)', async () => { -+// const {frontend} = getBrowserAndPages(); -+// await openSourceCodeEditorForFile('sourcemap-disjoint.js', 'sourcemap-disjoint.html'); -+// assert.deepEqual(await getBreakpointDecorators(), []); -+// await addBreakpointForLine(frontend, 2); -+// assert.deepEqual(await getBreakpointDecorators(), [2]); -+// await removeBreakpointForLine(frontend, 2); -+// assert.deepEqual(await getBreakpointDecorators(), []); -+// }); -+ -+// it('reliably hits breakpoints on worker with source map', async () => { -+// await enableExperiment('instrumentationBreakpoints'); -+// const {target, frontend} = getBrowserAndPages(); -+// await openSourceCodeEditorForFile('sourcemap-stepping-source.js', 'sourcemap-breakpoint.html'); -+ -+// await step('Add a breakpoint at first line of function multiline', async () => { -+// await addBreakpointForLine(frontend, 4); -+// }); -+ -+// await step('Navigate to a different site to refresh devtools and remove back-end state', async () => { -+// await refreshDevToolsAndRemoveBackendState(target); -+// }); -+ -+// await step('Navigate back to test page', () => { -+// void goToResource('sources/sourcemap-breakpoint.html'); -+// }); -+ -+// await step('wait for pause and check if we stopped at line 4', async () => { -+// await waitFor(PAUSE_INDICATOR_SELECTOR); -+// await waitForFunction(async () => { -+// const topCallFrame = await retrieveTopCallFrameWithoutResuming(); -+// return topCallFrame === 'sourcemap-stepping-source.js:4'; -+// }); -+// }); -+ -+// await step('Resume', async () => { -+// await click(RESUME_BUTTON); -+// }); -+// }); -+ -+// it('links to the correct origins for source-mapped resources', async () => { -+// await goToResource('sources/sourcemap-origin.html'); -+// await openSourcesPanel(); -+ -+// await step('Check origin of source-mapped JavaScript', async () => { -+// await openFileInEditor('sourcemap-origin.js'); -+// const linkText = await waitForTextContent(DEVTOOLS_LINK); -+// assert.strictEqual(linkText, 'sourcemap-origin.min.js'); -+// }); -+ -+// await step('Check origin of source-mapped SASS', async () => { -+// await openFileInEditor('sourcemap-origin.scss'); -+// const linkText = await waitForTextContent(DEVTOOLS_LINK); -+// assert.strictEqual(linkText, 'sourcemap-origin.css'); -+// }); -+ -+// await step('Check origin of source-mapped JavaScript with URL clash', async () => { -+// await openFileInEditor('sourcemap-origin.clash.js'); -+// const linkText = await waitForTextContent(DEVTOOLS_LINK); -+// assert.strictEqual(linkText, 'sourcemap-origin.clash.js'); -+// }); -+// }); -+ -+// it('shows Source map loaded infobar', async () => { -+// await goToResource('sources/sourcemap-origin.html'); -+// await openSourcesPanel(); -+ -+// await step('Get infobar text', async () => { -+// await openFileInEditor('sourcemap-origin.min.js'); -+// const infobarText = await waitForTextContent(INFOBAR_TEXT); -+// assert.strictEqual(infobarText, 'Source map loaded.'); -+// }); -+// }); -+ -+// it('shows Source map loaded infobar after attaching', async () => { -+// const {frontend} = getBrowserAndPages(); -+// await openSourceCodeEditorForFile('sourcemap-minified.js', 'sourcemap-minified.html'); -+ -+// await step('Attach source map', async () => { -+// await openSoftContextMenuAndClickOnItem('.cm-line', 'Add source map…'); -+ -+// // Enter the source map URL into the appropriate input box. -+// await click('.add-source-map'); -+// await typeText('sourcemap-minified.map'); -+// await frontend.keyboard.press('Enter'); -+// }); -+ -+// await step('Get infobar text', async () => { -+// const infobarText = await waitForTextContent(INFOBAR_TEXT); -+// assert.strictEqual(infobarText, 'Source map loaded.'); -+// }); -+// }); -+ -+// it('shows Source map skipped infobar', async () => { -+// await setIgnoreListPattern('.min.js'); -+// await openSourceCodeEditorForFile('sourcemap-origin.min.js', 'sourcemap-origin.html'); -+ -+// await step('Get infobar texts', async () => { -+// await openFileInEditor('sourcemap-origin.min.js'); -+// await waitFor('.infobar-warning'); -+// await waitFor('.infobar-info'); -+// const infobarTexts = await getVisibleTextContents(INFOBAR_TEXT); -+// assert.deepEqual( -+// infobarTexts, ['This script is on the debugger\'s ignore list', 'Source map skipped for this file.']); -+// }); -+// }); -+ -+// it('shows Source map error infobar after failing to attach', async () => { -+// const {frontend} = getBrowserAndPages(); -+// await openSourceCodeEditorForFile('sourcemap-minified.js', 'sourcemap-minified.html'); -+ -+// await step('Attach source map', async () => { -+// await openSoftContextMenuAndClickOnItem('.cm-line', 'Add source map…'); -+ -+// // Enter the source map URL into the appropriate input box. -+// await click('.add-source-map'); -+// await typeText('sourcemap-invalid.map'); -+// await frontend.keyboard.press('Enter'); -+// }); -+ -+// await step('Get infobar text', async () => { -+// const infobarText = await waitForTextContent(INFOBAR_TEXT); -+// assert.strictEqual(infobarText, 'Source map failed to load.'); -+// }); -+// }); -+ -+// describe('can deal with code-splitting', () => { -+// it('sets multiple breakpoints in case of code-splitting', async () => { -+// const {target, frontend} = getBrowserAndPages(); -+// await openSourceCodeEditorForFile('sourcemap-codesplit.ts', 'sourcemap-codesplit.html'); -+// await addBreakpointForLine(frontend, 3); -+ -+// for (let i = 0; i < 2; ++i) { -+// const scriptLocation = await retrieveTopCallFrameScriptLocation(`functions[${i}]();`, target); -+// assert.deepEqual(scriptLocation, 'sourcemap-codesplit.ts:3'); -+// } -+// }); -+ -+// it('restores breakpoints correctly in case of code-splitting (crbug.com/1412033)', async () => { -+// const {target, frontend} = getBrowserAndPages(); -+ -+// // Load the initial setup with only one script pointing to `codesplitting-bar.ts`... -+// await openSourceCodeEditorForFile('codesplitting-bar.ts', 'codesplitting.html'); -+ -+// // ...and set a breakpoint inside `bar()`. -+// await addBreakpointForLine(frontend, 2); -+ -+// // Now load the second script pointing to `codesplitting-bar.ts`... -+// await target.evaluate('addSecond();'); -+ -+// // ...wait for the new origin to be listed... -+// const linkTexts = await waitForFunction(async () => { -+// const links = await $$(DEVTOOLS_LINK); -+// const linkTexts = await Promise.all(links.map(node => node.evaluate(({textContent}) => textContent))); -+// if (linkTexts.length === 1 && linkTexts[0] === 'codesplitting-first.js') { -+// return undefined; -+// } -+// return linkTexts; -+// }); -+// assert.sameMembers(linkTexts, ['codesplitting-first.js', 'codesplitting-second.js']); -+ -+// // ...and eventually wait for the breakpoint to be restored in line 2. -+// await waitForFunction(async () => await isBreakpointSet(2)); -+ -+// // Eventually we should stop on the breakpoint in the `codesplitting-second.js`. -+// await waitForFunction(() => { -+// return Promise.race([ -+// target.evaluate('second()').then(() => false), -+// waitFor(PAUSE_INDICATOR_SELECTOR).then(() => true), -+// ]); -+// }); -+// await click(RESUME_BUTTON); -+// }); -+ -+// it('hits breakpoints reliably after reload in case of code-splitting (crbug.com/1490369)', async () => { -+// const {target, frontend} = getBrowserAndPages(); -+ -+// // Set the breakpoint inside `shared()` in `shared.js`. -+// await openSourceCodeEditorForFile('shared.js', 'codesplitting-race.html'); -+// await addBreakpointForLine(frontend, 2); -+// await waitForFunction(async () => await isBreakpointSet(2)); -+ -+// // Reload the page. -+// const reloadPromise = target.reload(); -+ -+// // Now the debugger should pause twice reliably. -+// await waitFor(PAUSE_INDICATOR_SELECTOR); -+// await click(RESUME_BUTTON); -+// await waitFor(PAUSE_INDICATOR_SELECTOR); -+// await click(RESUME_BUTTON); -+ -+// await reloadPromise; -+// }); -+// }); -+ -+// describe('can deal with hot module replacement', () => { -+// // The tests in here simulate Hot Module Replacement (HMR) workflows related -+// // to how DevTools deals with source maps in these situations. -+ -+// it('correctly handles URL clashes between compiled and source-mapped scripts', async () => { -+// const {target} = getBrowserAndPages(); -+ -+// // Load the "initial bundle"... -+// await openSourceCodeEditorForFile('index.js', 'sourcemap-hmr.html'); -+ -+// // ...and check that index.js content is as expected. -+// // In particular, this asserts that the front-end does not get creative in -+// // appending suffixes like '? [sm]' to the index.js here. -+// const initialContent = await retrieveCodeMirrorEditorContent(); -+// assert.deepEqual(initialContent, [ -+// 'globalThis.hello = () => {', -+// ' console.log("Hello world!");', -+// '}', -+// '', -+// ]); -+ -+// // Simulate the hot module replacement for index.js... -+// await target.evaluate('update();'); -+ -+// // ...and wait for its content to load (should just replace -+// // the existing tab contents for index.js). We perform this -+// // check by waiting until the editor contents differ from -+// // the initial contents, and then asserting that it looks -+// // as expected afterwards. -+// const updatedContent = await waitForFunction(async () => { -+// const content = await retrieveCodeMirrorEditorContent(); -+// if (content.length !== initialContent.length) { -+// return content; -+// } -+// for (let i = 0; i < content.length; ++i) { -+// if (content[i] !== initialContent[i]) { -+// return content; -+// } -+// } -+// return undefined; -+// }); -+// assert.deepEqual(updatedContent, [ -+// 'globalThis.hello = () => {', -+// ' console.log("Hello UPDATED world!");', -+// '}', -+// '', -+// ]); -+// }); -+ -+// it('correctly maintains breakpoints from initial bundle to replacement', async () => { -+// const {target, frontend} = getBrowserAndPages(); -+ -+// // Load the "initial bundle" and set a breakpoint on the second line. -+// await openSourceCodeEditorForFile('index.js', 'sourcemap-hmr.html'); -+// await addBreakpointForLine(frontend, 2); -+ -+// // Simulate the hot module replacement for index.js -+// await target.evaluate('update();'); -+ -+// // Wait for the "hot module replacement" to take effect for index.js. -+// await waitForFunction(async () => { -+// const content = await retrieveCodeMirrorEditorContent(); -+// return content[1].includes('UPDATED'); -+// }); -+ -+// // Wait for the breakpoint to appear on line 2 of the updated index.js. -+// await waitForFunction(async () => await isBreakpointSet(2)); -+// }); -+ -+// it('correctly maintains breakpoints from replacement to initial bundle (across reloads)', async () => { -+// const {target, frontend} = getBrowserAndPages(); -+ -+// // Load the "initial bundle". -+// await openSourceCodeEditorForFile('index.js', 'sourcemap-hmr.html'); -+ -+// // Simulate the hot module replacement for index.js -+// await target.evaluate('update();'); -+ -+// // Wait for the "hot module replacement" to take effect for index.js. -+// await waitForFunction(async () => { -+// const content = await retrieveCodeMirrorEditorContent(); -+// return content[1].includes('UPDATED'); -+// }); -+ -+// // Set a breakpoint on the second line. -+// await addBreakpointForLine(frontend, 2); -+ -+// // Reload the page and re-open (the initial) index.js. -+// await reloadPageAndWaitForSourceFile(target, 'index.js'); -+ -+// // Check that the breakpoint still exists on line 2. -+// assert.isTrue(await isBreakpointSet(2)); -+// }); -+// }); -+ -+// it('can attach sourcemaps to CSS files from a context menu', async () => { -+// await openSourceCodeEditorForFile('sourcemap-css.css', 'sourcemap-css-noinline.html'); -+ -+// await click('aria/Code editor', {clickOptions: {button: 'right'}}); -+// await click('aria/Add source map…'); -+// await waitFor('.add-source-map'); -+// await typeText('sourcemap-css-absolute.map'); -+// await pressKey('Enter'); -+ -+// await waitFor('[aria-label="app.scss, file"]'); -+// }); -+// }); -+ -+// describe('The Elements Tab', async () => { -+// async function clickStyleValueWithModifiers(selector: string, name: string, value: string, location: string) { -+// const element = await waitForCSSPropertyValue(selector, name, value, location); -+// // Click with offset to skip swatches. -+// await withControlOrMetaKey(() => clickElement(element, {clickOptions: {offset: {x: 20, y: 5}}})); -+// } -+ -+// it('links to the right SASS source for inline CSS with relative sourcemap (crbug.com/787792)', async () => { -+// await goToResource('sources/sourcemap-css-inline-relative.html'); -+// await step('Prepare elements tab', async () => { -+// await waitForElementsStyleSection(); -+// await waitForContentOfSelectedElementsNode('\u200B'); -+// await focusElementsTree(); -+// await clickNthChildOfSelectedElementNode(1); -+// }); -+// await clickStyleValueWithModifiers('body .text', 'color', 'green', 'app.scss:6'); -+// await waitForElementWithTextContent('Line 12, Column 9'); -+// }); -+ -+// it('links to the right SASS source for inline CSS with absolute sourcemap (crbug.com/787792)', async () => { -+// await goToResource('sources/sourcemap-css-dynamic-link.html'); -+// await step('Prepare elements tab', async () => { -+// await waitForElementsStyleSection(); -+// await waitForContentOfSelectedElementsNode('\u200B'); -+// await focusElementsTree(); -+// await clickNthChildOfSelectedElementNode(1); -+// }); -+// await clickStyleValueWithModifiers('body .text', 'color', 'green', 'app.scss:6'); -+// await waitForElementWithTextContent('Line 12, Column 9'); -+// }); -+ -+// it('links to the right SASS source for dynamically added CSS style tags (crbug.com/787792)', async () => { -+// await goToResource('sources/sourcemap-css-dynamic.html'); -+// await step('Prepare elements tab', async () => { -+// await waitForElementsStyleSection(); -+// await waitForContentOfSelectedElementsNode('\u200B'); -+// await focusElementsTree(); -+// await clickNthChildOfSelectedElementNode(1); -+// }); -+// await clickStyleValueWithModifiers('body .text', 'color', 'green', 'app.scss:6'); -+// await waitForElementWithTextContent('Line 12, Column 9'); -+// }); -+ -+// it('links to the right SASS source for dynamically added CSS link tags (crbug.com/787792)', async () => { -+// await goToResource('sources/sourcemap-css-dynamic-link.html'); -+// await step('Prepare elements tab', async () => { -+// await waitForElementsStyleSection(); -+// await waitForContentOfSelectedElementsNode('\u200B'); -+// await focusElementsTree(); -+// await clickNthChildOfSelectedElementNode(1); -+// }); -+// await clickStyleValueWithModifiers('body .text', 'color', 'green', 'app.scss:6'); -+// await waitForElementWithTextContent('Line 12, Column 9'); -+// }); -+// }); - - describe('Sourcemaps Standarization Tests', async () => { -- it('checks that the name in stacktrace in the console is unminified', async () => { -+ it('checks that the name in stacktrace in the console is unminified', async (done) => { - // this could be extracted to the test harness (maybe also the match function and the initial setup) - // like so: -- // const result = prepare(generatedFile, htmlFile) -- // assert(result, matchExpresssion) -+ // prepare(generatedFile, htmlFile) -+ // assert(matchExpresssion) - const generatedFile = 'simple-throw.js'; - const htmlFile = 'simple-throw.html'; - const matchExpression = /.*at\ wat/; - -- // this would be 'prepare' -+ // this would be 'prepare - const {target, frontend} = getBrowserAndPages(); -- -- await openSourceCodeEditorForFile(generatedFile, htmlFile); -- await step('open console', async () => { -+ -+ step('check console messages', async () => { -+ await openSourceCodeEditorForFile(generatedFile, htmlFile); - await frontend.evaluate(`(async () => { - const Root = await import('./core/root/root.js'); - Root.Runtime.experiments.setEnabled('evaluateExpressionsWithSourceMaps', true); - })()`); -+ // await frontend.evaluate(`SimpleThrow.outerWrap();`); - - await click(CONSOLE_TAB_SELECTOR); -- await focusConsolePrompt(); -- await pasteText('outerWat();'); -- await frontend.keyboard.press('Enter'); -- -- // Wait for the console to be usable again. -- await frontend.waitForFunction(() => { -- return document.querySelectorAll('.console-user-command-result').length === 1; -- }); -+ // await focusConsolePrompt(); -+ // await pasteText('SimpleThrow.outerWat();'); -+ // await frontend.keyboard.press('Enter'); -+ -+ // // Wait for the console to be usable again. -+ // await frontend.waitForFunction(() => { -+ // return document.querySelectorAll('.console-user-command-result').length === 1; -+ // }); -+ // // which would return the messages or would expose another function to get the -+ const messages = await getCurrentConsoleMessages(); -+ console.log(messages); -+ // and then this would be assert' -+ assert.match(messages[0], matchExpression); - }); -- -- // which would return the messages or would expose another function to get the messages -- const messages = await getCurrentConsoleMessages(); -- // and then this would be 'assert' -- assert.match(messages[0], matchExpression); - }); - }); -+ -+ -+// it('shows unminified identifiers in scopes and console', async () => { -+// const {target, frontend} = getBrowserAndPages(); -+// await openSourceCodeEditorForFile('sourcemap-minified.js', 'sourcemap-minified.html'); -+ -+// let scriptEvaluation: Promise; -+// const breakLocationRegExp = /sourcemap-minified\.js:1$/; -+ -+// await step('Run to debugger statement', async () => { -+// scriptEvaluation = target.evaluate('sayHello(" world");'); -+ -+// const scriptLocation = await waitForStackTopMatch(breakLocationRegExp); -+// assert.match(scriptLocation, breakLocationRegExp); -+// }); -+ -+// await step('Check local variable is eventually un-minified', async () => { -+// const unminifiedVariable = 'element: div'; -+// await openSoftContextMenuAndClickOnItem('.cm-line', 'Add source map…'); -+ -+// // Enter the source map URL into the appropriate input box. -+// await click('.add-source-map'); -+// await typeText('sourcemap-minified.map'); -+// await frontend.keyboard.press('Enter'); -+ -+// const scopeValues = await waitForFunction(async () => { -+// const values = await getValuesForScope('Local', 0, 0); -+// return (values && values.includes(unminifiedVariable)) ? values : undefined; -+// }); -+// assert.include(scopeValues, unminifiedVariable); -+// }); -+ -+// await step('Check that expression evaluation understands unminified name', async () => { -+// await frontend.evaluate(`(async () => { -+// const Root = await import('./core/root/root.js'); -+// Root.Runtime.experiments.setEnabled('evaluateExpressionsWithSourceMaps', true); -+// })()`); -+ -+// await click(CONSOLE_TAB_SELECTOR); -+// await focusConsolePrompt(); -+// await pasteText('`Hello${text}!`'); -+// await frontend.keyboard.press('Enter'); -+ -+// // Wait for the console to be usable again. -+// await frontend.waitForFunction(() => { -+// return document.querySelectorAll('.console-user-command-result').length === 1; -+// }); -+// const messages = await getCurrentConsoleMessages(); -+ -+// assert.deepEqual(messages, ['\'Hello world!\'']); -+ -+// await openSourcesPanel(); -+// }); -+ -+// await step('Resume', async () => { -+// await click(RESUME_BUTTON); -+// await scriptEvaluation; -+// }); -+// }); -\ No newline at end of file -diff --git a/test/unittests/BUILD.gn b/test/unittests/BUILD.gn -index 6e6c6fd400..c259624d42 100644 ---- a/test/unittests/BUILD.gn -+++ b/test/unittests/BUILD.gn -@@ -17,6 +17,7 @@ group("unittests") { - "../shared", - "fixtures/images", - "fixtures/traces", -+ "fixtures/sourcemaps", - "front_end", - "inspector_overlay", - ] -diff --git a/test/unittests/front_end/core/sdk/BUILD.gn b/test/unittests/front_end/core/sdk/BUILD.gn -index 1c4d051cd7..5b185550b9 100644 ---- a/test/unittests/front_end/core/sdk/BUILD.gn -+++ b/test/unittests/front_end/core/sdk/BUILD.gn -@@ -42,6 +42,7 @@ ts_library("sdk") { - "ServiceWorkerManager_test.ts", - "SourceMapManager_test.ts", - "SourceMap_test.ts", -+ "SourceMapSpec_test.ts", - "StorageKeyManager_test.ts", - "TargetManager_test.ts", - "Target_test.ts", From dc8056f1db6d059adaa78c9d7b9946f0be978bed Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Fri, 19 Apr 2024 11:45:13 -0700 Subject: [PATCH 51/68] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 8a47eb6..aff8668 100644 --- a/README.md +++ b/README.md @@ -27,3 +27,6 @@ How to run in WebKit: * Run `git am /webkit/0001-Add-harness-for-source-maps-spec-tests.patch` * Run `Tools/Scripts/build-webkit` (depending on the platform you may need to pass `--gtk` or other flags) * Run `Tools/Scripts/run-webkit-tests LayoutTests/inspector/model/source-map-spec.html` (again, you may need `--gtk` on Linux) + +Mozilla [source-map](https://github.com/mozilla/source-map) library: + * There is a [branch](https://github.com/takikawa/source-map/tree/add-spec-tests) for adding the spec tests to the package. From 857e6f56da43ed679f829f6dc73aa38ad1e8074d Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Thu, 25 Apr 2024 14:02:42 -0700 Subject: [PATCH 52/68] Add a checklist of test cases to the README --- README.md | 126 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) diff --git a/README.md b/README.md index aff8668..cf836cf 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,8 @@ Source Map spec: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze These test cases are still a work-in-progress 🚧. +# Running the tests + How to run in Firefox: * Check out mozilla-unified (see [Firefox dev setup](https://firefox-source-docs.mozilla.org/setup/index.html) under "Setting up your machine" for details, note that you can use git via [git-cinnabar](https://github.com/glandium/git-cinnabar/)) * `cd` to the checked out directory. @@ -30,3 +32,127 @@ How to run in WebKit: Mozilla [source-map](https://github.com/mozilla/source-map) library: * There is a [branch](https://github.com/takikawa/source-map/tree/add-spec-tests) for adding the spec tests to the package. + +# Goals of tests + +* Thoroughly test all aspects of the source maps spec that can be tested. +* Strictly follow the spec when determining test behavior. + +# Test coverage + +## Core spec + +* Encoding + - [ ] Source map must be a valid JSON document. + - Base64 VLQ + * VLQs should decode correctly + - [X] A VLQ with a non-base64 character will fail to decode. + - [ ] A VLQ with one digit and no continuation digits should decode. + - [ ] A negative VLQ with the sign bit set to 1 should decode. + - [ ] A VLQ with non-zero continuation bits (and more than one digit) should decode. + - [ ] A VLQ with a non-zero continuataion bit with no further digits should fail to decode. + - [ ] A VLQ should decode with the correct order of digits (least to most significant). + - [x] A long VLQ with many trailing zero digits will decode. + * [x] A VLQ exceeding the 32-bit size limit is invalid (note: the spec is unclear on the details of this limit) + * [x] A VLQ at exactly the 32-bit size limit should be decoded (positive and negative). +* Basic format + - `version` field + * [X] Must be present + * [X] Must be a number + * [X] Must be 3 + - `file` field + * [ ] Optional, allow missing + * [ ] Must be a string? (spec is not clear) + - `sourceRoot` field + * [ ] Optional, allow missing + * [ ] Must be a string? (spec is not clear) + - `sources` field + * [X] Must be present + * [X] Must be an array + * [X] Array elements must be `null` or a string + - `sourcesContent` field + * [X] Must be present + * [X] Must be an array + * [X] Array elements must be `null` or a string + - `names` field + * [X] Must be present (note: the spec implies this but implementations may not agree) + * [X] Must be an array + * [X] Array elements must be strings + - `mappings` field + * [X] Must be present + * [X] Must be a string + * [ ] Empty string is valid + - `ignoreList` field + * [ ] Optional, allow missing + * [ ] Must be an array + * [ ] Array elements must be numbers + * [ ] Elements must not be out of bounds for the `sources` list + - [X] Extra unrecognized fields are allowed +* Index maps + - ? Must be mutually exclusive with non-index map? + - `file` field + * [ ] Optional, allow missing + * [ ] Must be a string? (spec is not clear) + - `sections` field + * [X] Must be present + * [X] Must be an array + * [ ] An empty sections array is valid + * [X] Array elements are valid section objects + - `offset` field + * [X] Must be present + * `line` field + - [X] Must be present + - [X] Must be a number + * `column` field + - [X] Must be present + - [X] Must be a number + - `map` field + * [X] Must be present + * [X] Must be an object + * [ ] Must be a valid source map + - [X] Sections are in order (the spec is not 100% clear, but assumption is increasing numeric order, may need subtests) + - [X] Sections are non-overlapping (the definition of overlap is not clear, may need subtests) +* Mappings format + - [X] Each line is separated by ";" + - [X] A line may consist of zero segments (e.g., ";;") + - [X] Each line consists only of segments separated by "," + - [X] Must have greater than zero fields (note: many implementations don't check) + - [X] Must have 1, 4, or 5 fields + - [X] The source index must not be out of bounds of the sources array + - [X] The name index must not be out of bounds of the names array + - Absolute VLQ values must be non-negative + * [X] The column must be non-negative + * [X] The source index must be non-negative + * [X] The original line must be non-negative + * [X] The original column must be non-negative + * [X] The name index must be non-negative + - Relative VLQ values must be non-negative after adding to previous value + * [ ] The column must be non-negative + * [ ] The source index must be non-negative + * [ ] The original line must be non-negative + * [ ] The original column must be non-negative + * [ ] The name index must be non-negative +* Mappings semantics + - [ ] A source map with no mappings does not map any position. + - [ ] A single field segment gets mapped to the correct line and column. + - [X] A four field segment gets mapped to the correct line and column. + - [X] A five field segment gets mapped to the correct line and column. + - [X] When a name is present in a segment, it is correctly mapped. + - [X] When a source is present in a segment, it is correctly mapped. + - [ ] The second occurence of a field segment in a line is mapped relative to the previous one. + - [ ] When a new line starts, the generated column field resets to zero rather than being relative to the previous line. + - [ ] For fields other than the generated column, a segment field that has occured once in a previous line is mapped relatively when it occurs in the next line. + - [ ] Ensure that a transitive source map mapping works as expected + - Index maps are correctly used in mappings + * [ ] An index map with one sub-map will map correctly. + * [X] An index map with multiple sub-maps will map correctly, with appropriate offsets for the second and later sub-maps. +* Resolution of sources + - [ ] When `sourceRoot` is provided, it is prepended to any `sources` entries and will be mapped with the full URL. + - [ ] If the source URL is an absolute URL, it is resolved as an absolute URL. + - [ ] If the source URL is a relative URL, it is resolved relative to the source map path. +* Wasm support + - [ ] Create versions of the tests that use a Wasm source. + +## Scopes Proposal + +TODO From f41f1306eb1419531af8f989e9a85e1343efcf73 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Thu, 25 Apr 2024 18:21:41 -0700 Subject: [PATCH 53/68] Change behavior of basic-mapping-as-index-map test It looks like this approach of having the same source appear in multiple sections doesn't really match with how tools process source maps. It would be better to have a multi-section test with concatenated sources. The spec should probably also be clear on whether, e.g., the sources lists should be mutually exclusive. --- resources/basic-mapping-as-index-map.js.map | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/resources/basic-mapping-as-index-map.js.map b/resources/basic-mapping-as-index-map.js.map index 0863d44..8a6d4b5 100644 --- a/resources/basic-mapping-as-index-map.js.map +++ b/resources/basic-mapping-as-index-map.js.map @@ -7,16 +7,7 @@ "version": 3, "names": ["foo","bar"], "sources": ["basic-mapping-original.js"], - "mappings": "AAAA,SAASA,MACP,OAAO,EACT,CACA" - } - }, - { - "offset": { "line": 0, "column": 34 }, - "map": { - "version": 3, - "names": ["foo","bar"], - "sources": ["basic-mapping-original.js"], - "mappings": "AAGSC,MACP,OAAO,EACT,CACAD,MACAC" + "mappings": "AAAA,SAASA,MACP,OAAO,EACT,CACA,SAASC,MACP,OAAO,EACT,CACAD,MACAC" } } ] From d24b0203cf213cce945cfacacc83bf63dbad5bb0 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Mon, 29 Apr 2024 16:26:01 -0700 Subject: [PATCH 54/68] Add a new test with an index map with multiple sections Unlike the previous test that had two sections, there is one section for each of the two original sources. --- .../index-map-two-concatenated-sources.js | 2 + .../index-map-two-concatenated-sources.js.map | 23 +++ resources/second-source-original.js | 4 + source-map-spec-tests.json | 171 ++++++++++++++++++ 4 files changed, 200 insertions(+) create mode 100644 resources/index-map-two-concatenated-sources.js create mode 100644 resources/index-map-two-concatenated-sources.js.map create mode 100644 resources/second-source-original.js diff --git a/resources/index-map-two-concatenated-sources.js b/resources/index-map-two-concatenated-sources.js new file mode 100644 index 0000000..b8702d7 --- /dev/null +++ b/resources/index-map-two-concatenated-sources.js @@ -0,0 +1,2 @@ +function foo(){return 42}function bar(){return 24}foo();bar();function baz(){return"baz"}baz(); +//# sourceMappingURL=index-map-two-concatenated-sources.js.map diff --git a/resources/index-map-two-concatenated-sources.js.map b/resources/index-map-two-concatenated-sources.js.map new file mode 100644 index 0000000..f5e5214 --- /dev/null +++ b/resources/index-map-two-concatenated-sources.js.map @@ -0,0 +1,23 @@ +{ + "version": 3, + "sections": [ + { + "offset": { "line": 0, "column": 0 }, + "map": { + "version": 3, + "names": ["foo","bar"], + "sources": ["basic-mapping-original.js"], + "mappings": "AAAA,SAASA,MACP,OAAO,EACT,CACA,SAASC,MACP,OAAO,EACT,CACAD,MACAC" + } + }, + { + "offset": { "line": 0, "column": 62 }, + "map": { + "version": 3, + "names": ["baz"], + "sources": ["second-source-original.js"], + "mappings":"AAAA,SAASA,MACP,MAAO,KACT,CACAA" + } + } + ] +} diff --git a/resources/second-source-original.js b/resources/second-source-original.js new file mode 100644 index 0000000..c339bc9 --- /dev/null +++ b/resources/second-source-original.js @@ -0,0 +1,4 @@ +function baz() { + return "baz"; +} +baz(); diff --git a/source-map-spec-tests.json b/source-map-spec-tests.json index 678efd0..2563dff 100644 --- a/source-map-spec-tests.json +++ b/source-map-spec-tests.json @@ -584,6 +584,177 @@ } ] }, + { + "name": "indexMapWithTwoConcatenatedSources", + "description": "Test an index map that has two sub-maps for concatenated sources", + "baseFile": "index-map-two-concatenated-sources.js", + "sourceMapFile": "index-map-two-concatenated-sources.js.map", + "sourceMapIsValid": true, + "testActions": [ + { + "actionType": "checkMapping", + "generatedLine": 0, + "generatedColumn": 0, + "originalSource": "basic-mapping-original.js", + "originalLine": 0, + "originalColumn": 0, + "mappedName": null + }, + { + "actionType": "checkMapping", + "generatedLine": 0, + "generatedColumn": 9, + "originalSource": "basic-mapping-original.js", + "originalLine": 0, + "originalColumn": 9, + "mappedName": "foo" + }, + { + "actionType": "checkMapping", + "originalSource": "basic-mapping-original.js", + "generatedLine": 0, + "generatedColumn": 15, + "originalLine": 1, + "originalColumn": 2, + "mappedName": null + }, + { + "actionType": "checkMapping", + "originalSource": "basic-mapping-original.js", + "generatedLine": 0, + "generatedColumn": 22, + "originalLine": 1, + "originalColumn": 9, + "mappedName": null + }, + { + "actionType": "checkMapping", + "originalSource": "basic-mapping-original.js", + "generatedLine": 0, + "generatedColumn": 24, + "originalLine": 2, + "originalColumn": 0, + "mappedName": null + }, + { + "actionType": "checkMapping", + "originalSource": "basic-mapping-original.js", + "generatedLine": 0, + "generatedColumn": 25, + "originalLine": 3, + "originalColumn": 0, + "mappedName": null + }, + { + "actionType": "checkMapping", + "generatedLine": 0, + "generatedColumn": 34, + "originalSource": "basic-mapping-original.js", + "originalLine": 3, + "originalColumn": 9, + "mappedName": "bar" + }, + { + "actionType": "checkMapping", + "originalSource": "basic-mapping-original.js", + "generatedLine": 0, + "generatedColumn": 40, + "originalLine": 4, + "originalColumn": 2, + "mappedName": null + }, + { + "actionType": "checkMapping", + "originalSource": "basic-mapping-original.js", + "generatedLine": 0, + "generatedColumn": 47, + "originalLine": 4, + "originalColumn": 9, + "mappedName": null + }, + { + "actionType": "checkMapping", + "originalSource": "basic-mapping-original.js", + "generatedLine": 0, + "generatedColumn": 49, + "originalLine": 5, + "originalColumn": 0, + "mappedName": null + }, + { + "actionType": "checkMapping", + "originalSource": "basic-mapping-original.js", + "generatedLine": 0, + "generatedColumn": 50, + "originalLine": 6, + "originalColumn": 0, + "mappedName": "foo" + }, + { + "actionType": "checkMapping", + "originalSource": "basic-mapping-original.js", + "generatedLine": 0, + "generatedColumn": 56, + "originalLine": 7, + "originalColumn": 0, + "mappedName": "bar" + }, + { + "actionType": "checkMapping", + "originalSource": "second-source-original.js", + "generatedLine": 0, + "generatedColumn": 62, + "originalLine": 0, + "originalColumn": 0, + "mappedName": null + }, + { + "actionType": "checkMapping", + "originalSource": "second-source-original.js", + "generatedLine": 0, + "generatedColumn": 71, + "originalLine": 0, + "originalColumn": 9, + "mappedName": "baz" + }, + { + "actionType": "checkMapping", + "originalSource": "second-source-original.js", + "generatedLine": 0, + "generatedColumn": 77, + "originalLine": 1, + "originalColumn": 2, + "mappedName": null + }, + { + "actionType": "checkMapping", + "originalSource": "second-source-original.js", + "generatedLine": 0, + "generatedColumn": 83, + "originalLine": 1, + "originalColumn": 9, + "mappedName": null + }, + { + "actionType": "checkMapping", + "originalSource": "second-source-original.js", + "generatedLine": 0, + "generatedColumn": 88, + "originalLine": 2, + "originalColumn": 0, + "mappedName": null + }, + { + "actionType": "checkMapping", + "originalSource": "second-source-original.js", + "generatedLine": 0, + "generatedColumn": 89, + "originalLine": 3, + "originalColumn": 0, + "mappedName": "baz" + } + ] + }, { "name": "validMappingNullSources", "description": "Test a source map that has null sources", From 43d4c57192848a5afd86d927948fa66c61b00fc4 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Fri, 3 May 2024 17:45:19 -0700 Subject: [PATCH 55/68] Add a transitive mapping test. Adds a new test action "checkMappingTransitive" that takes mapping data and also a list of intermediate maps that should be queried. The intention is that a tool harness would, if it supports this action, look up a position starting at the generated source's map and resolve it iteratively through the intermediate maps until the original source is found. The particular test that is added is a minified JS generated source that has a source map for the minification, and then a source map for the TS to JS compilation step. --- resources/transitive-mapping-original.js | 5 ++ resources/transitive-mapping-original.js.map | 8 ++ resources/transitive-mapping.js | 2 + resources/transitive-mapping.js.map | 6 ++ resources/typescript-original.ts | 5 ++ source-map-spec-tests.json | 89 ++++++++++++++++++++ 6 files changed, 115 insertions(+) create mode 100644 resources/transitive-mapping-original.js create mode 100644 resources/transitive-mapping-original.js.map create mode 100644 resources/transitive-mapping.js create mode 100644 resources/transitive-mapping.js.map create mode 100644 resources/typescript-original.ts diff --git a/resources/transitive-mapping-original.js b/resources/transitive-mapping-original.js new file mode 100644 index 0000000..0a96699 --- /dev/null +++ b/resources/transitive-mapping-original.js @@ -0,0 +1,5 @@ +function foo(x) { + return x; +} +foo("foo"); +//# sourceMappingURL=transitive-mapping-original.js.map diff --git a/resources/transitive-mapping-original.js.map b/resources/transitive-mapping-original.js.map new file mode 100644 index 0000000..65af25c --- /dev/null +++ b/resources/transitive-mapping-original.js.map @@ -0,0 +1,8 @@ +{ + "version": 3, + "file" : "transitive-mapping-original.js", + "sourceRoot": "", + "sources": ["typescript-original.ts"], + "names": [], + "mappings": "AACA,SAAS,GAAG,CAAC,CAAU;IACrB,OAAO,CAAC,CAAC;AACX,CAAC;AACD,GAAG,CAAC,KAAK,CAAC,CAAC" +} diff --git a/resources/transitive-mapping.js b/resources/transitive-mapping.js new file mode 100644 index 0000000..183c027 --- /dev/null +++ b/resources/transitive-mapping.js @@ -0,0 +1,2 @@ +function foo(x){return x}foo("foo"); +//# sourceMappingURL=transitive-mapping.js.map diff --git a/resources/transitive-mapping.js.map b/resources/transitive-mapping.js.map new file mode 100644 index 0000000..d6a6fa6 --- /dev/null +++ b/resources/transitive-mapping.js.map @@ -0,0 +1,6 @@ +{ + "version": 3, + "names": ["foo","x"], + "sources": ["transitive-mapping-original.js"], + "mappings":"AAAA,SAASA,IAAIC,GACT,OAAOA,CACX,CACAD,IAAI" +} diff --git a/resources/typescript-original.ts b/resources/typescript-original.ts new file mode 100644 index 0000000..cd51c01 --- /dev/null +++ b/resources/typescript-original.ts @@ -0,0 +1,5 @@ +type FooArg = string | number; +function foo(x : FooArg) { + return x; +} +foo("foo"); diff --git a/source-map-spec-tests.json b/source-map-spec-tests.json index 2563dff..6c260fc 100644 --- a/source-map-spec-tests.json +++ b/source-map-spec-tests.json @@ -781,6 +781,95 @@ "mappedName": "foo" } ] + }, + { + "name": "transitiveMapping", + "description": "Test a simple two-stage transitive mapping from a minified JS to a TypeScript source", + "baseFile": "transitive-mapping.js", + "sourceMapFile": "transitive-mapping.js.map", + "sourceMapIsValid": true, + "testActions": [ + { + "actionType": "checkMappingTransitive", + "generatedLine": 0, + "generatedColumn": 0, + "originalSource": "typescript-original.ts", + "intermediateMaps": ["transitive-mapping-original.js.map"], + "originalLine": 1, + "originalColumn": 0, + "mappedName": null + }, + { + "actionType": "checkMappingTransitive", + "generatedLine": 0, + "generatedColumn": 9, + "originalSource": "typescript-original.ts", + "intermediateMaps": ["transitive-mapping-original.js.map"], + "originalLine": 1, + "originalColumn": 9, + "mappedName": null + }, + { + "actionType": "checkMappingTransitive", + "generatedLine": 0, + "generatedColumn": 13, + "originalSource": "typescript-original.ts", + "intermediateMaps": ["transitive-mapping-original.js.map"], + "originalLine": 1, + "originalColumn": 13, + "mappedName": null + }, + { + "actionType": "checkMappingTransitive", + "generatedLine": 0, + "generatedColumn": 16, + "originalSource": "typescript-original.ts", + "intermediateMaps": ["transitive-mapping-original.js.map"], + "originalLine": 2, + "originalColumn": 2, + "mappedName": null + }, + { + "actionType": "checkMappingTransitive", + "generatedLine": 0, + "generatedColumn": 23, + "originalSource": "typescript-original.ts", + "intermediateMaps": ["transitive-mapping-original.js.map"], + "originalLine": 2, + "originalColumn": 9, + "mappedName": null + }, + { + "actionType": "checkMappingTransitive", + "generatedLine": 0, + "generatedColumn": 24, + "originalSource": "typescript-original.ts", + "intermediateMaps": ["transitive-mapping-original.js.map"], + "originalLine": 3, + "originalColumn": 0, + "mappedName": null + }, + { + "actionType": "checkMappingTransitive", + "generatedLine": 0, + "generatedColumn": 25, + "originalSource": "typescript-original.ts", + "intermediateMaps": ["transitive-mapping-original.js.map"], + "originalLine": 4, + "originalColumn": 0, + "mappedName": null + }, + { + "actionType": "checkMappingTransitive", + "generatedLine": 0, + "generatedColumn": 29, + "originalSource": "typescript-original.ts", + "intermediateMaps": ["transitive-mapping-original.js.map"], + "originalLine": 4, + "originalColumn": 4, + "mappedName": null + } + ] } ] } From 75157f83c18bf40183007299da36c7affb566821 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Fri, 10 May 2024 20:50:16 -0700 Subject: [PATCH 56/68] Add a three-step transitive mapping test This test is similar to the previously added transitive mapping test but has an additional intermediate source map. --- resources/transitive-mapping-three-steps.js | 6 ++ .../transitive-mapping-three-steps.js.map | 7 ++ source-map-spec-tests.json | 89 +++++++++++++++++++ 3 files changed, 102 insertions(+) create mode 100644 resources/transitive-mapping-three-steps.js create mode 100644 resources/transitive-mapping-three-steps.js.map diff --git a/resources/transitive-mapping-three-steps.js b/resources/transitive-mapping-three-steps.js new file mode 100644 index 0000000..fd95616 --- /dev/null +++ b/resources/transitive-mapping-three-steps.js @@ -0,0 +1,6 @@ +function foo(x) { + return x; +} + +foo("foo"); +//# sourceMappingURL=transitive-mapping-three-steps.js.map diff --git a/resources/transitive-mapping-three-steps.js.map b/resources/transitive-mapping-three-steps.js.map new file mode 100644 index 0000000..90459d9 --- /dev/null +++ b/resources/transitive-mapping-three-steps.js.map @@ -0,0 +1,7 @@ +{ + "version": 3, + "file": "transitive-mapping-three-steps.js", + "sources": ["transitive-mapping.js"], + "names": ["foo", "x"], + "mappings": "AAAA,SAASA,IAAIC;IAAG,OAAOA;AAAC;;AAACD,IAAI,KAAK" +} diff --git a/source-map-spec-tests.json b/source-map-spec-tests.json index 6c260fc..fffe8d8 100644 --- a/source-map-spec-tests.json +++ b/source-map-spec-tests.json @@ -870,6 +870,95 @@ "mappedName": null } ] + }, + { + "name": "transitiveMappingWithThreeSteps", + "description": "Test a three-stage transitive mapping from an un-minified JS to minified JS to a TypeScript source", + "baseFile": "transitive-mapping-three-steps.js", + "sourceMapFile": "transitive-mapping-three-steps.js.map", + "sourceMapIsValid": true, + "testActions": [ + { + "actionType": "checkMappingTransitive", + "generatedLine": 0, + "generatedColumn": 0, + "originalSource": "typescript-original.ts", + "intermediateMaps": ["transitive-mapping.js.map", "transitive-mapping-original.js.map"], + "originalLine": 1, + "originalColumn": 0, + "mappedName": null + }, + { + "actionType": "checkMappingTransitive", + "generatedLine": 0, + "generatedColumn": 9, + "originalSource": "typescript-original.ts", + "intermediateMaps": ["transitive-mapping.js.map", "transitive-mapping-original.js.map"], + "originalLine": 1, + "originalColumn": 9, + "mappedName": null + }, + { + "actionType": "checkMappingTransitive", + "generatedLine": 0, + "generatedColumn": 13, + "originalSource": "typescript-original.ts", + "intermediateMaps": ["transitive-mapping.js.map", "transitive-mapping-original.js.map"], + "originalLine": 1, + "originalColumn": 13, + "mappedName": null + }, + { + "actionType": "checkMappingTransitive", + "generatedLine": 1, + "generatedColumn": 4, + "originalSource": "typescript-original.ts", + "intermediateMaps": ["transitive-mapping.js.map", "transitive-mapping-original.js.map"], + "originalLine": 2, + "originalColumn": 2, + "mappedName": null + }, + { + "actionType": "checkMappingTransitive", + "generatedLine": 1, + "generatedColumn": 11, + "originalSource": "typescript-original.ts", + "intermediateMaps": ["transitive-mapping.js.map", "transitive-mapping-original.js.map"], + "originalLine": 2, + "originalColumn": 9, + "mappedName": null + }, + { + "actionType": "checkMappingTransitive", + "generatedLine": 2, + "generatedColumn": 0, + "originalSource": "typescript-original.ts", + "intermediateMaps": ["transitive-mapping.js.map", "transitive-mapping-original.js.map"], + "originalLine": 3, + "originalColumn": 0, + "mappedName": null + }, + { + "actionType": "checkMappingTransitive", + "generatedLine": 4, + "generatedColumn": 0, + "originalSource": "typescript-original.ts", + "intermediateMaps": ["transitive-mapping.js.map", "transitive-mapping-original.js.map"], + "originalLine": 4, + "originalColumn": 0, + "mappedName": null + }, + { + "actionType": "checkMappingTransitive", + "generatedLine": 4, + "generatedColumn": 4, + "originalSource": "typescript-original.ts", + "intermediateMaps": ["transitive-mapping.js.map", "transitive-mapping-original.js.map"], + "originalLine": 4, + "originalColumn": 4, + "mappedName": null + } + ] } ] } From 37f96179f4824fab8d1b110692386d0fa9c59714 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Sat, 11 May 2024 15:49:51 -0700 Subject: [PATCH 57/68] Add a test for missing continuation digits --- README.md | 2 +- resources/invalid-vlq-missing-continuation.js | 1 + resources/invalid-vlq-missing-continuation.js.map | 6 ++++++ source-map-spec-tests.json | 7 +++++++ 4 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 resources/invalid-vlq-missing-continuation.js create mode 100644 resources/invalid-vlq-missing-continuation.js.map diff --git a/README.md b/README.md index cf836cf..bf2ac76 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ Mozilla [source-map](https://github.com/mozilla/source-map) library: - [ ] A VLQ with one digit and no continuation digits should decode. - [ ] A negative VLQ with the sign bit set to 1 should decode. - [ ] A VLQ with non-zero continuation bits (and more than one digit) should decode. - - [ ] A VLQ with a non-zero continuataion bit with no further digits should fail to decode. + - [X] A VLQ with a non-zero continuation bit with no further digits should fail to decode. - [ ] A VLQ should decode with the correct order of digits (least to most significant). - [x] A long VLQ with many trailing zero digits will decode. * [x] A VLQ exceeding the 32-bit size limit is invalid (note: the spec is unclear on the details of this limit) diff --git a/resources/invalid-vlq-missing-continuation.js b/resources/invalid-vlq-missing-continuation.js new file mode 100644 index 0000000..2c2a009 --- /dev/null +++ b/resources/invalid-vlq-missing-continuation.js @@ -0,0 +1 @@ +//# sourceMappingURL=invalid-vlq-missing-continuation.js.map diff --git a/resources/invalid-vlq-missing-continuation.js.map b/resources/invalid-vlq-missing-continuation.js.map new file mode 100644 index 0000000..dd0e363 --- /dev/null +++ b/resources/invalid-vlq-missing-continuation.js.map @@ -0,0 +1,6 @@ +{ + "version" : 3, + "sources": [], + "names": [], + "mappings": "g" +} diff --git a/source-map-spec-tests.json b/source-map-spec-tests.json index fffe8d8..7f24a01 100644 --- a/source-map-spec-tests.json +++ b/source-map-spec-tests.json @@ -119,6 +119,13 @@ "sourceMapFile": "invalid-vlq-non-base64-char.js.map", "sourceMapIsValid": false }, + { + "name": "invalidVLQDueToMissingContinuationDigits", + "description": "Test a source map that has a mapping with an invalid VLQ that has a continuation bit but no continuing digits", + "baseFile": "invalid-vlq-missing-continuation.js", + "sourceMapFile": "invalid-vlq-missing-continuation.js.map", + "sourceMapIsValid": false + }, { "name": "invalidMappingNotAString1", "description": "Test a source map that has an invalid mapping that is not a string (number)", From 04e70be6bfdb728d81a4f5fdc8c927e81cddbd24 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Tue, 14 May 2024 16:40:18 -0700 Subject: [PATCH 58/68] Add test cases for relative fields that are negative --- README.md | 10 +++--- ...apping-segment-negative-relative-column.js | 1 + ...ng-segment-negative-relative-column.js.map | 8 +++++ ...ng-segment-negative-relative-name-index.js | 1 + ...egment-negative-relative-name-index.js.map | 8 +++++ ...gment-negative-relative-original-column.js | 1 + ...t-negative-relative-original-column.js.map | 8 +++++ ...segment-negative-relative-original-line.js | 1 + ...ent-negative-relative-original-line.js.map | 8 +++++ ...-segment-negative-relative-source-index.js | 1 + ...ment-negative-relative-source-index.js.map | 8 +++++ source-map-spec-tests.json | 35 +++++++++++++++++++ 12 files changed, 85 insertions(+), 5 deletions(-) create mode 100644 resources/invalid-mapping-segment-negative-relative-column.js create mode 100644 resources/invalid-mapping-segment-negative-relative-column.js.map create mode 100644 resources/invalid-mapping-segment-negative-relative-name-index.js create mode 100644 resources/invalid-mapping-segment-negative-relative-name-index.js.map create mode 100644 resources/invalid-mapping-segment-negative-relative-original-column.js create mode 100644 resources/invalid-mapping-segment-negative-relative-original-column.js.map create mode 100644 resources/invalid-mapping-segment-negative-relative-original-line.js create mode 100644 resources/invalid-mapping-segment-negative-relative-original-line.js.map create mode 100644 resources/invalid-mapping-segment-negative-relative-source-index.js create mode 100644 resources/invalid-mapping-segment-negative-relative-source-index.js.map diff --git a/README.md b/README.md index bf2ac76..0a0433e 100644 --- a/README.md +++ b/README.md @@ -127,11 +127,11 @@ Mozilla [source-map](https://github.com/mozilla/source-map) library: * [X] The original column must be non-negative * [X] The name index must be non-negative - Relative VLQ values must be non-negative after adding to previous value - * [ ] The column must be non-negative - * [ ] The source index must be non-negative - * [ ] The original line must be non-negative - * [ ] The original column must be non-negative - * [ ] The name index must be non-negative + * [X] The column must be non-negative + * [X] The source index must be non-negative + * [X] The original line must be non-negative + * [X] The original column must be non-negative + * [X] The name index must be non-negative * Mappings semantics - [ ] A source map with no mappings does not map any position. - [ ] A single field segment gets mapped to the correct line and column. diff --git a/resources/invalid-mapping-segment-negative-relative-column.js b/resources/invalid-mapping-segment-negative-relative-column.js new file mode 100644 index 0000000..94b835d --- /dev/null +++ b/resources/invalid-mapping-segment-negative-relative-column.js @@ -0,0 +1 @@ +//# sourceMappingURL=invalid-mapping-segment-negative-relative-column.js.map diff --git a/resources/invalid-mapping-segment-negative-relative-column.js.map b/resources/invalid-mapping-segment-negative-relative-column.js.map new file mode 100644 index 0000000..4148840 --- /dev/null +++ b/resources/invalid-mapping-segment-negative-relative-column.js.map @@ -0,0 +1,8 @@ +{ + "version": 3, + "names": [], + "file": "invalid-mapping-segment-negative-relative-column.js", + "sources": ["empty-original.js"], + "sourcesContent": [""], + "mappings": "C,F" +} diff --git a/resources/invalid-mapping-segment-negative-relative-name-index.js b/resources/invalid-mapping-segment-negative-relative-name-index.js new file mode 100644 index 0000000..c965c5f --- /dev/null +++ b/resources/invalid-mapping-segment-negative-relative-name-index.js @@ -0,0 +1 @@ +//# sourceMappingURL=invalid-mapping-segment-negative-relative-name-index.js.map diff --git a/resources/invalid-mapping-segment-negative-relative-name-index.js.map b/resources/invalid-mapping-segment-negative-relative-name-index.js.map new file mode 100644 index 0000000..1fbbcfc --- /dev/null +++ b/resources/invalid-mapping-segment-negative-relative-name-index.js.map @@ -0,0 +1,8 @@ +{ + "version": 3, + "names": [], + "file": "invalid-mapping-segment-negative-relative-name-index.js", + "sources": ["empty-original.js"], + "sourcesContent": [""], + "mappings": "AAAAC,AAAAF" +} diff --git a/resources/invalid-mapping-segment-negative-relative-original-column.js b/resources/invalid-mapping-segment-negative-relative-original-column.js new file mode 100644 index 0000000..493a6ec --- /dev/null +++ b/resources/invalid-mapping-segment-negative-relative-original-column.js @@ -0,0 +1 @@ +//# sourceMappingURL=invalid-mapping-segment-negative-relative-original-column.js.map diff --git a/resources/invalid-mapping-segment-negative-relative-original-column.js.map b/resources/invalid-mapping-segment-negative-relative-original-column.js.map new file mode 100644 index 0000000..7e62895 --- /dev/null +++ b/resources/invalid-mapping-segment-negative-relative-original-column.js.map @@ -0,0 +1,8 @@ +{ + "version": 3, + "names": [], + "file": "invalid-mapping-segment-negative-relative-original-column.js", + "sources": ["empty-original.js"], + "sourcesContent": [""], + "mappings": "AAAC,AAAF" +} diff --git a/resources/invalid-mapping-segment-negative-relative-original-line.js b/resources/invalid-mapping-segment-negative-relative-original-line.js new file mode 100644 index 0000000..ca8329f --- /dev/null +++ b/resources/invalid-mapping-segment-negative-relative-original-line.js @@ -0,0 +1 @@ +//# sourceMappingURL=invalid-mapping-segment-negative-relative-original-line.js.map diff --git a/resources/invalid-mapping-segment-negative-relative-original-line.js.map b/resources/invalid-mapping-segment-negative-relative-original-line.js.map new file mode 100644 index 0000000..86b0fb3 --- /dev/null +++ b/resources/invalid-mapping-segment-negative-relative-original-line.js.map @@ -0,0 +1,8 @@ +{ + "version": 3, + "names": [], + "file": "invalid-mapping-segment-negative-relative-original-line.js", + "sources": ["empty-original.js"], + "sourcesContent": [""], + "mappings": "AACA,AAFA" +} diff --git a/resources/invalid-mapping-segment-negative-relative-source-index.js b/resources/invalid-mapping-segment-negative-relative-source-index.js new file mode 100644 index 0000000..fa92225 --- /dev/null +++ b/resources/invalid-mapping-segment-negative-relative-source-index.js @@ -0,0 +1 @@ +//# sourceMappingURL=invalid-mapping-segment-negative-relative-source-index.js.map diff --git a/resources/invalid-mapping-segment-negative-relative-source-index.js.map b/resources/invalid-mapping-segment-negative-relative-source-index.js.map new file mode 100644 index 0000000..2efeb04 --- /dev/null +++ b/resources/invalid-mapping-segment-negative-relative-source-index.js.map @@ -0,0 +1,8 @@ +{ + "version": 3, + "names": [], + "file": "invalid-mapping-segment-negative-relative-source-index.js", + "sources": ["empty-original.js"], + "sourcesContent": [""], + "mappings": "ACAA,AFAA" +} diff --git a/source-map-spec-tests.json b/source-map-spec-tests.json index 7f24a01..47bcd22 100644 --- a/source-map-spec-tests.json +++ b/source-map-spec-tests.json @@ -217,6 +217,41 @@ "sourceMapFile": "invalid-mapping-segment-negative-name-index.js.map", "sourceMapIsValid": false }, + { + "name": "invalidMappingSegmentWithNegativeRelativeColumn", + "description": "Test a source map that has an invalid negative relative column field", + "baseFile": "invalid-mapping-segment-negative-relative-column.js", + "sourceMapFile": "invalid-mapping-segment-negative-relative-column.js.map", + "sourceMapIsValid": false + }, + { + "name": "invalidMappingSegmentWithNegativeRelativeSourceIndex", + "description": "Test a source map that has an invalid negative relative source index field", + "baseFile": "invalid-mapping-segment-negative-relative-source-index.js", + "sourceMapFile": "invalid-mapping-segment-negative-relative-source-index.js.map", + "sourceMapIsValid": false + }, + { + "name": "invalidMappingSegmentWithNegativeRelativeOriginalLine", + "description": "Test a source map that has an invalid negative relative original line field", + "baseFile": "invalid-mapping-segment-negative-relative-original-line.js", + "sourceMapFile": "invalid-mapping-segment-negative-relative-original-line.js.map", + "sourceMapIsValid": false + }, + { + "name": "invalidMappingSegmentWithNegativeRelativeOriginalColumn", + "description": "Test a source map that has an invalid negative relative original column field", + "baseFile": "invalid-mapping-segment-negative-relative-original-column.js", + "sourceMapFile": "invalid-mapping-segment-negative-relative-original-column.js.map", + "sourceMapIsValid": false + }, + { + "name": "invalidMappingSegmentWithNegativeRelativeNameIndex", + "description": "Test a source map that has an invalid negative relative name index field", + "baseFile": "invalid-mapping-segment-negative-relative-name-index.js", + "sourceMapFile": "invalid-mapping-segment-negative-relative-name-index.js.map", + "sourceMapIsValid": false + }, { "name": "invalidMappingSegmentWithColumnExceeding32Bits", "description": "Test a source map that has a column field that exceeds 32 bits", From 4666447b6c662540e9f750b21fdc8711278fcf3a Mon Sep 17 00:00:00 2001 From: Agata Belkius Date: Tue, 30 Apr 2024 13:55:52 +0100 Subject: [PATCH 59/68] add checks for valid sourcemaps --- .../0001-add-tests-for-sourcemaps-spec.patch | 2 +- .../0002-add-test-for-valid-sourcemaps.patch | 59 +++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 chrome/0002-add-test-for-valid-sourcemaps.patch diff --git a/chrome/0001-add-tests-for-sourcemaps-spec.patch b/chrome/0001-add-tests-for-sourcemaps-spec.patch index aa69c64..0274104 100644 --- a/chrome/0001-add-tests-for-sourcemaps-spec.patch +++ b/chrome/0001-add-tests-for-sourcemaps-spec.patch @@ -1,7 +1,7 @@ From 5a77ff79e4092740116e1c6871bd15fc5f560e66 Mon Sep 17 00:00:00 2001 From: Agata Belkius Date: Fri, 19 Apr 2024 15:30:48 +0100 -Subject: [PATCH] add tests for sourcemaps spec +Subject: [PATCH 1/2] add tests for sourcemaps spec --- front_end/BUILD.gn | 1 + diff --git a/chrome/0002-add-test-for-valid-sourcemaps.patch b/chrome/0002-add-test-for-valid-sourcemaps.patch new file mode 100644 index 0000000..169fd3c --- /dev/null +++ b/chrome/0002-add-test-for-valid-sourcemaps.patch @@ -0,0 +1,59 @@ +From ddcad1d602ba5201ebd8560b44731232114a0c9d Mon Sep 17 00:00:00 2001 +From: Agata Belkius +Date: Tue, 30 Apr 2024 13:53:36 +0100 +Subject: [PATCH 2/2] add test for valid sourcemaps + +--- + front_end/core/sdk/SourceMapSpec.test.ts | 17 +++++++++++++---- + 1 file changed, 13 insertions(+), 4 deletions(-) + +diff --git a/front_end/core/sdk/SourceMapSpec.test.ts b/front_end/core/sdk/SourceMapSpec.test.ts +index 64f350d7f3..d8953d42fa 100644 +--- a/front_end/core/sdk/SourceMapSpec.test.ts ++++ b/front_end/core/sdk/SourceMapSpec.test.ts +@@ -30,7 +30,7 @@ + const {assert} = chai; + import type * as Platform from '../platform/platform.js'; + import {assertNotNullOrUndefined} from '../platform/platform.js'; +-import { SourceMapV3 } from './SourceMap.js'; ++import { SourceMapV3, parseSourceMap } from './SourceMap.js'; + import * as SDK from './sdk.js'; + import {describeWithEnvironment} from '../../testing/EnvironmentHelpers.js'; + +@@ -62,21 +62,30 @@ describeWithEnvironment.only('SourceMapSpec', async () => { + testActions, + sourceMapIsValid + }) => { +- it(`checks mappings for ${sourceMapFile}`, async () => { ++ it(`tests ${sourceMapFile}`, async () => { + if (!sourceMapIsValid) { ++ // TODO - right now most of the failure scenarios are actually passing + return; + } + ++ // check if a valid sourcemap can be loaded and a SourceMap object created + const baseFileUrl = baseFile as Platform.DevToolsPath.UrlString; + const sourceMapFileUrl = sourceMapFile as Platform.DevToolsPath.UrlString; + const sourceMapContent = await loadSourceMapFromFixture(sourceMapFile); +- ++ ++ assert.doesNotThrow(() => parseSourceMap(JSON.stringify(sourceMapContent))); ++ assert.doesNotThrow(() => new SDK.SourceMap.SourceMap( ++ baseFileUrl, ++ sourceMapFileUrl, ++ sourceMapContent ++ )); ++ ++ // check if the mappings are valid + const sourceMap = new SDK.SourceMap.SourceMap( + baseFileUrl, + sourceMapFileUrl, + sourceMapContent); + +- + if (testActions !== undefined) { + testActions.forEach(({ + actionType, +-- +2.39.3 (Apple Git-145) + From c56193ea8fda54c0a2cb122b84b1a3377e941764 Mon Sep 17 00:00:00 2001 From: Agata Belkius Date: Thu, 2 May 2024 11:14:09 +0100 Subject: [PATCH 60/68] add more tests for invalid sourcemaps --- .../0001-add-tests-for-sourcemaps-spec.patch | 2 +- .../0002-add-test-for-valid-sourcemaps.patch | 2 +- chrome/0003-add-more-tests-cases.patch | 108 ++++++++++++++++++ 3 files changed, 110 insertions(+), 2 deletions(-) create mode 100644 chrome/0003-add-more-tests-cases.patch diff --git a/chrome/0001-add-tests-for-sourcemaps-spec.patch b/chrome/0001-add-tests-for-sourcemaps-spec.patch index 0274104..18e82a1 100644 --- a/chrome/0001-add-tests-for-sourcemaps-spec.patch +++ b/chrome/0001-add-tests-for-sourcemaps-spec.patch @@ -1,7 +1,7 @@ From 5a77ff79e4092740116e1c6871bd15fc5f560e66 Mon Sep 17 00:00:00 2001 From: Agata Belkius Date: Fri, 19 Apr 2024 15:30:48 +0100 -Subject: [PATCH 1/2] add tests for sourcemaps spec +Subject: [PATCH 1/3] add tests for sourcemaps spec --- front_end/BUILD.gn | 1 + diff --git a/chrome/0002-add-test-for-valid-sourcemaps.patch b/chrome/0002-add-test-for-valid-sourcemaps.patch index 169fd3c..d95f240 100644 --- a/chrome/0002-add-test-for-valid-sourcemaps.patch +++ b/chrome/0002-add-test-for-valid-sourcemaps.patch @@ -1,7 +1,7 @@ From ddcad1d602ba5201ebd8560b44731232114a0c9d Mon Sep 17 00:00:00 2001 From: Agata Belkius Date: Tue, 30 Apr 2024 13:53:36 +0100 -Subject: [PATCH 2/2] add test for valid sourcemaps +Subject: [PATCH 2/3] add test for valid sourcemaps --- front_end/core/sdk/SourceMapSpec.test.ts | 17 +++++++++++++---- diff --git a/chrome/0003-add-more-tests-cases.patch b/chrome/0003-add-more-tests-cases.patch new file mode 100644 index 0000000..34e22eb --- /dev/null +++ b/chrome/0003-add-more-tests-cases.patch @@ -0,0 +1,108 @@ +From f07ac89859cef0b251c38310d0933092faf6a652 Mon Sep 17 00:00:00 2001 +From: Agata Belkius +Date: Thu, 2 May 2024 11:09:27 +0100 +Subject: [PATCH 3/3] add more tests cases + +--- + front_end/core/sdk/SourceMapSpec.test.ts | 65 +++++++++++++++++++++--- + 1 file changed, 59 insertions(+), 6 deletions(-) + +diff --git a/front_end/core/sdk/SourceMapSpec.test.ts b/front_end/core/sdk/SourceMapSpec.test.ts +index d8953d42fa..2d6818f785 100644 +--- a/front_end/core/sdk/SourceMapSpec.test.ts ++++ b/front_end/core/sdk/SourceMapSpec.test.ts +@@ -60,18 +60,68 @@ describeWithEnvironment.only('SourceMapSpec', async () => { + baseFile, + sourceMapFile, + testActions, +- sourceMapIsValid ++ sourceMapIsValid, ++ name + }) => { + it(`tests ${sourceMapFile}`, async () => { ++ const consoleErrorSpy = sinon.spy(console, 'error'); ++ const sourceMapContent = await loadSourceMapFromFixture(sourceMapFile); ++ ++ // 1) check if an invalid sourcemap throws on SourceMap instance creation ++ if (!sourceMapIsValid && [ ++ 'sourcesMissing', ++ 'indexMapMissingOffset' ++ ].includes(name)) { ++ assert.throws(() => new SDK.SourceMap.SourceMap( ++ baseFile as Platform.DevToolsPath.UrlString, ++ sourceMapFile as Platform.DevToolsPath.UrlString, ++ sourceMapContent ++ )); ++ ++ return; ++ } ++ ++ // 2) check if an invalid sourcemap throws on mapping creation ++ if (!sourceMapIsValid && [ ++ 'invalidVLQDueToNonBase64Character', ++ 'invalidMappingNotAString1', ++ 'invalidMappingNotAString2', ++ 'invalidMappingSegmentBadSeparator', ++ 'invalidMappingSegmentWithZeroFields', ++ 'invalidMappingSegmentWithTwoFields', ++ 'invalidMappingSegmentWithThreeFields' ++ ].includes(name)) { ++ const sourceMap = new SDK.SourceMap.SourceMap( ++ baseFile as Platform.DevToolsPath.UrlString, ++ sourceMapFile as Platform.DevToolsPath.UrlString, ++ sourceMapContent ++ ); ++ ++ // TODO - findEntry or just mappings should be used here? mappings is the culprit ++ // but it is called from different other methods e.g: findEntry() ++ sourceMap.mappings(); ++ assert.equal(consoleErrorSpy.calledWith("Failed to parse source map"), true); ++ ++ return; ++ } ++ ++ // 3) check if an invalid sourcemap can have the mapping created + if (!sourceMapIsValid) { ++ const sourceMap = new SDK.SourceMap.SourceMap( ++ baseFile as Platform.DevToolsPath.UrlString, ++ sourceMapFile as Platform.DevToolsPath.UrlString, ++ sourceMapContent ++ ); ++ sourceMap.mappings(); + // TODO - right now most of the failure scenarios are actually passing +- return; ++ assert.equal(consoleErrorSpy.notCalled, true); ++ console.warn('Invalid sourcemap passes basic validation'); + } ++ + +- // check if a valid sourcemap can be loaded and a SourceMap object created ++ // 4) check if a valid sourcemap can be parsed and a SourceMap instance created + const baseFileUrl = baseFile as Platform.DevToolsPath.UrlString; + const sourceMapFileUrl = sourceMapFile as Platform.DevToolsPath.UrlString; +- const sourceMapContent = await loadSourceMapFromFixture(sourceMapFile); + + assert.doesNotThrow(() => parseSourceMap(JSON.stringify(sourceMapContent))); + assert.doesNotThrow(() => new SDK.SourceMap.SourceMap( +@@ -79,13 +129,16 @@ describeWithEnvironment.only('SourceMapSpec', async () => { + sourceMapFileUrl, + sourceMapContent + )); ++ + +- // check if the mappings are valid ++ // 5) check if the mappings are valid + const sourceMap = new SDK.SourceMap.SourceMap( + baseFileUrl, + sourceMapFileUrl, + sourceMapContent); +- ++ ++ assert.doesNotThrow(() => sourceMap.findEntry(1, 1)); ++ + if (testActions !== undefined) { + testActions.forEach(({ + actionType, +-- +2.39.3 (Apple Git-145) + From d50e48ce8936ba2a8bde5b6ff73e1ad179f03dc2 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Sat, 18 May 2024 16:54:06 -0700 Subject: [PATCH 61/68] Change both null sources/sourcesContent case to valid While it initially seems like this case should be invalid, I think there is a good argument to be made that it's valid. First, the spec doesn't explicitly rule it out and does allow the possibility of both being null. Second, in practice it does have a meaning for browser engines. For example, if you have a source map with null as a source, and also have a file named "null" present then the browser may load that as the reference source file. --- source-map-spec-tests.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source-map-spec-tests.json b/source-map-spec-tests.json index 47bcd22..2dfcba5 100644 --- a/source-map-spec-tests.json +++ b/source-map-spec-tests.json @@ -75,7 +75,7 @@ "description": "Test a source map that has both null sources and sourcesContent entries", "baseFile": "sources-and-sources-content-both-null.js", "sourceMapFile": "sources-and-sources-content-both-null.js.map", - "sourceMapIsValid": false + "sourceMapIsValid": true }, { "name": "namesMissing", From e34854a435cd8b53499eda0bc2b0df4159714be9 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Sat, 18 May 2024 17:31:07 -0700 Subject: [PATCH 62/68] Rename case for null source and non-null sourcesContent --- resources/sources-null-sources-content-non-null.js | 2 ++ ...s.map => sources-null-sources-content-non-null.js.map} | 0 resources/valid-mapping-null-sources.js | 2 -- source-map-spec-tests.json | 8 ++++---- 4 files changed, 6 insertions(+), 6 deletions(-) create mode 100644 resources/sources-null-sources-content-non-null.js rename resources/{valid-mapping-null-sources.js.map => sources-null-sources-content-non-null.js.map} (100%) delete mode 100644 resources/valid-mapping-null-sources.js diff --git a/resources/sources-null-sources-content-non-null.js b/resources/sources-null-sources-content-non-null.js new file mode 100644 index 0000000..a760594 --- /dev/null +++ b/resources/sources-null-sources-content-non-null.js @@ -0,0 +1,2 @@ +function foo(){return 42}function bar(){return 24}foo();bar(); +//# sourceMappingURL=sources-null-sources-content-non-null.js.map diff --git a/resources/valid-mapping-null-sources.js.map b/resources/sources-null-sources-content-non-null.js.map similarity index 100% rename from resources/valid-mapping-null-sources.js.map rename to resources/sources-null-sources-content-non-null.js.map diff --git a/resources/valid-mapping-null-sources.js b/resources/valid-mapping-null-sources.js deleted file mode 100644 index ee2acf0..0000000 --- a/resources/valid-mapping-null-sources.js +++ /dev/null @@ -1,2 +0,0 @@ -function foo(){return 42}function bar(){return 24}foo();bar(); -//# sourceMappingURL=valid-mapping-null-sources.js.map diff --git a/source-map-spec-tests.json b/source-map-spec-tests.json index 2dfcba5..f8aea91 100644 --- a/source-map-spec-tests.json +++ b/source-map-spec-tests.json @@ -798,10 +798,10 @@ ] }, { - "name": "validMappingNullSources", - "description": "Test a source map that has null sources", - "baseFile": "valid-mapping-null-sources.js", - "sourceMapFile": "valid-mapping-null-sources.js.map", + "name": "sourcesNullSourcesContentNonNull", + "description": "Test a source map that has a null source but has a sourcesContent", + "baseFile": "sources-null-sources-content-non-null.js", + "sourceMapFile": "sources-null-sources-content-non-null.js.map", "sourceMapIsValid": true, "testActions": [ { From 31204d0f044a4c915d0940b55ab1655d91c61ae0 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Sat, 18 May 2024 17:34:27 -0700 Subject: [PATCH 63/68] Add new test case for null sourcesContent With a non-null sources --- .../sources-non-null-sources-content-null.js | 2 ++ ...urces-non-null-sources-content-null.js.map | 7 +++++ source-map-spec-tests.json | 27 +++++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 resources/sources-non-null-sources-content-null.js create mode 100644 resources/sources-non-null-sources-content-null.js.map diff --git a/resources/sources-non-null-sources-content-null.js b/resources/sources-non-null-sources-content-null.js new file mode 100644 index 0000000..939b568 --- /dev/null +++ b/resources/sources-non-null-sources-content-null.js @@ -0,0 +1,2 @@ +function foo(){return 42}function bar(){return 24}foo();bar(); +//# sourceMappingURL=sources-non-null-sources-content-null.js.map diff --git a/resources/sources-non-null-sources-content-null.js.map b/resources/sources-non-null-sources-content-null.js.map new file mode 100644 index 0000000..e573906 --- /dev/null +++ b/resources/sources-non-null-sources-content-null.js.map @@ -0,0 +1,7 @@ +{ + "version": 3, + "names": ["foo"], + "sources": ["basic-mapping-original.js"], + "sourcesContent": [null], + "mappings":"AAAA,SAASA" +} diff --git a/source-map-spec-tests.json b/source-map-spec-tests.json index f8aea91..c735cc1 100644 --- a/source-map-spec-tests.json +++ b/source-map-spec-tests.json @@ -824,6 +824,33 @@ } ] }, + { + "name": "sourcesNonNullSourcesContentNull", + "description": "Test a source map that has a non-null source but has a null sourcesContent", + "baseFile": "sources-non-null-sources-content-null.js", + "sourceMapFile": "sources-non-null-sources-content-null.js.map", + "sourceMapIsValid": true, + "testActions": [ + { + "actionType": "checkMapping", + "generatedLine": 0, + "generatedColumn": 0, + "originalSource": "basic-mapping-original.js", + "originalLine": 0, + "originalColumn": 0, + "mappedName": null + }, + { + "actionType": "checkMapping", + "generatedLine": 0, + "generatedColumn": 9, + "originalSource": "basic-mapping-original.js", + "originalLine": 0, + "originalColumn": 9, + "mappedName": "foo" + } + ] + }, { "name": "transitiveMapping", "description": "Test a simple two-stage transitive mapping from a minified JS to a TypeScript source", From 8670fd057aa9ade8b63e94728f21b7c0761fad50 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Thu, 23 May 2024 17:32:20 -0700 Subject: [PATCH 64/68] Minor fix to valid-mapping-empty-groups Adds a sourcesContent field for an empty file --- resources/valid-mapping-empty-groups.js.map | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/valid-mapping-empty-groups.js.map b/resources/valid-mapping-empty-groups.js.map index 53be4ae..643c9ae 100644 --- a/resources/valid-mapping-empty-groups.js.map +++ b/resources/valid-mapping-empty-groups.js.map @@ -3,5 +3,6 @@ "names": [], "file": "valid-mapping-empty-groups.js", "sources": ["empty-original.js"], + "sourcesContent": [""], "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;" } From 02f2b1b324d9cdc04bc68f360196cf730f761fd2 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Sat, 25 May 2024 14:45:35 -0700 Subject: [PATCH 65/68] Add basic tests for ignore lists --- README.md | 8 ++++ resources/ignore-list-empty.js | 1 + resources/ignore-list-empty.js.map | 8 ++++ resources/ignore-list-out-of-bounds.js | 1 + resources/ignore-list-out-of-bounds.js.map | 8 ++++ resources/ignore-list-valid-1.js | 1 + resources/ignore-list-valid-1.js.map | 8 ++++ resources/ignore-list-wrong-type-1.js | 1 + resources/ignore-list-wrong-type-1.js.map | 8 ++++ resources/ignore-list-wrong-type-2.js | 1 + resources/ignore-list-wrong-type-2.js.map | 8 ++++ resources/ignore-list-wrong-type-3.js | 1 + resources/ignore-list-wrong-type-3.js.map | 8 ++++ source-map-spec-tests.json | 48 ++++++++++++++++++++++ 14 files changed, 110 insertions(+) create mode 100644 resources/ignore-list-empty.js create mode 100644 resources/ignore-list-empty.js.map create mode 100644 resources/ignore-list-out-of-bounds.js create mode 100644 resources/ignore-list-out-of-bounds.js.map create mode 100644 resources/ignore-list-valid-1.js create mode 100644 resources/ignore-list-valid-1.js.map create mode 100644 resources/ignore-list-wrong-type-1.js create mode 100644 resources/ignore-list-wrong-type-1.js.map create mode 100644 resources/ignore-list-wrong-type-2.js create mode 100644 resources/ignore-list-wrong-type-2.js.map create mode 100644 resources/ignore-list-wrong-type-3.js create mode 100644 resources/ignore-list-wrong-type-3.js.map diff --git a/README.md b/README.md index 0a0433e..ab8dc81 100644 --- a/README.md +++ b/README.md @@ -132,6 +132,14 @@ Mozilla [source-map](https://github.com/mozilla/source-map) library: * [X] The original line must be non-negative * [X] The original column must be non-negative * [X] The name index must be non-negative +* Ignore list + - [X] An ignore list is optional, may be missing + - [X] An ignore list can't be a non-array value + * [X] An ignore list can be empty + * [X] An ignore list entry must be a number + * [X] An ignore list entry cannot be out-of-bounds of the sources array + - [X] Ignore list entries are detected and are present + - [X] Items not specified in the ignore list don't show up as ignored * Mappings semantics - [ ] A source map with no mappings does not map any position. - [ ] A single field segment gets mapped to the correct line and column. diff --git a/resources/ignore-list-empty.js b/resources/ignore-list-empty.js new file mode 100644 index 0000000..385a5c3 --- /dev/null +++ b/resources/ignore-list-empty.js @@ -0,0 +1 @@ +//# sourceMappingURL=ignore-list-empty.js.map diff --git a/resources/ignore-list-empty.js.map b/resources/ignore-list-empty.js.map new file mode 100644 index 0000000..7297863 --- /dev/null +++ b/resources/ignore-list-empty.js.map @@ -0,0 +1,8 @@ +{ + "version" : 3, + "sources": ["empty-original.js"], + "sourcesContent": [""], + "mappings": "", + "names": [], + "ignoreList": [] +} diff --git a/resources/ignore-list-out-of-bounds.js b/resources/ignore-list-out-of-bounds.js new file mode 100644 index 0000000..7a0fbb8 --- /dev/null +++ b/resources/ignore-list-out-of-bounds.js @@ -0,0 +1 @@ +//# sourceMappingURL=ignore-list-out-of-bounds.js.map diff --git a/resources/ignore-list-out-of-bounds.js.map b/resources/ignore-list-out-of-bounds.js.map new file mode 100644 index 0000000..fb2566b --- /dev/null +++ b/resources/ignore-list-out-of-bounds.js.map @@ -0,0 +1,8 @@ +{ + "version" : 3, + "sources": ["empty-original.js"], + "sourcesContent": [""], + "mappings": "", + "names": [], + "ignoreList": [1] +} diff --git a/resources/ignore-list-valid-1.js b/resources/ignore-list-valid-1.js new file mode 100644 index 0000000..ea64a55 --- /dev/null +++ b/resources/ignore-list-valid-1.js @@ -0,0 +1 @@ +//# sourceMappingURL=ignore-list-valid-1.js.map diff --git a/resources/ignore-list-valid-1.js.map b/resources/ignore-list-valid-1.js.map new file mode 100644 index 0000000..98eebdf --- /dev/null +++ b/resources/ignore-list-valid-1.js.map @@ -0,0 +1,8 @@ +{ + "version" : 3, + "sources": ["empty-original.js"], + "sourcesContent": [""], + "mappings": "", + "names": [], + "ignoreList": [0] +} diff --git a/resources/ignore-list-wrong-type-1.js b/resources/ignore-list-wrong-type-1.js new file mode 100644 index 0000000..8b40bd3 --- /dev/null +++ b/resources/ignore-list-wrong-type-1.js @@ -0,0 +1 @@ +//# sourceMappingURL=ignore-list-wrong-type-1.js.map diff --git a/resources/ignore-list-wrong-type-1.js.map b/resources/ignore-list-wrong-type-1.js.map new file mode 100644 index 0000000..688740a --- /dev/null +++ b/resources/ignore-list-wrong-type-1.js.map @@ -0,0 +1,8 @@ +{ + "version" : 3, + "sources": ["empty-original.js"], + "sourcesContent": [""], + "mappings": "", + "names": [], + "ignoreList": ["not a number"] +} diff --git a/resources/ignore-list-wrong-type-2.js b/resources/ignore-list-wrong-type-2.js new file mode 100644 index 0000000..35c7791 --- /dev/null +++ b/resources/ignore-list-wrong-type-2.js @@ -0,0 +1 @@ +//# sourceMappingURL=ignore-list-wrong-type-2.js.map diff --git a/resources/ignore-list-wrong-type-2.js.map b/resources/ignore-list-wrong-type-2.js.map new file mode 100644 index 0000000..ca1d30d --- /dev/null +++ b/resources/ignore-list-wrong-type-2.js.map @@ -0,0 +1,8 @@ +{ + "version" : 3, + "sources": ["empty-original.js"], + "sourcesContent": [""], + "mappings": "", + "names": [], + "ignoreList": ["0"] +} diff --git a/resources/ignore-list-wrong-type-3.js b/resources/ignore-list-wrong-type-3.js new file mode 100644 index 0000000..8735d41 --- /dev/null +++ b/resources/ignore-list-wrong-type-3.js @@ -0,0 +1 @@ +//# sourceMappingURL=ignore-list-wrong-type-3.js.map diff --git a/resources/ignore-list-wrong-type-3.js.map b/resources/ignore-list-wrong-type-3.js.map new file mode 100644 index 0000000..7b4ccde --- /dev/null +++ b/resources/ignore-list-wrong-type-3.js.map @@ -0,0 +1,8 @@ +{ + "version" : 3, + "sources": ["empty-original.js"], + "sourcesContent": [""], + "mappings": "", + "names": [], + "ignoreList": 0; +} diff --git a/source-map-spec-tests.json b/source-map-spec-tests.json index c735cc1..d4ec5aa 100644 --- a/source-map-spec-tests.json +++ b/source-map-spec-tests.json @@ -105,6 +105,54 @@ "sourceMapFile": "names-not-string.js.map", "sourceMapIsValid": false }, + { + "name": "ignoreListEmpty", + "description": "Test a source map with an ignore list that has no items", + "baseFile": "ignore-list-empty.js", + "sourceMapFile": "ignore-list-empty.js.map", + "sourceMapIsValid": true + }, + { + "name": "ignoreListValid1", + "description": "Test a source map with a simple valid ignore list", + "baseFile": "ignore-list-valid-1.js", + "sourceMapFile": "ignore-list-valid-1.js.map", + "sourceMapIsValid": true, + "testActions": [ + { + "actionType": "checkIgnoreList", + "present": ["empty-original.js"] + } + ] + }, + { + "name": "ignoreListWrongType1", + "description": "Test a source map with an ignore list with the wrong type of items", + "baseFile": "ignore-list-wrong-type-1.js", + "sourceMapFile": "ignore-list-wrong-type-1.js.map", + "sourceMapIsValid": false + }, + { + "name": "ignoreListWrongType2", + "description": "Test a source map with an ignore list with the wrong type of items", + "baseFile": "ignore-list-wrong-type-2.js", + "sourceMapFile": "ignore-list-wrong-type-2.js.map", + "sourceMapIsValid": false + }, + { + "name": "ignoreListWrongType3", + "description": "Test a source map with an ignore list that is not a list", + "baseFile": "ignore-list-wrong-type-3.js", + "sourceMapFile": "ignore-list-wrong-type-3.js.map", + "sourceMapIsValid": false + }, + { + "name": "ignoreListOutOfBounds", + "description": "Test a source map with an ignore list with an item with an out-of-bounds index", + "baseFile": "ignore-list-out-of-bounds.js", + "sourceMapFile": "ignore-list-out-of-bounds.js.map", + "sourceMapIsValid": false + }, { "name": "unrecognizedProperty", "description": "Test a source map that has an extra field not explicitly encoded in the spec", From 8cd510c3fa8e0ebd05bcea27c5940985937ca6a4 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Wed, 29 May 2024 14:54:05 -0700 Subject: [PATCH 66/68] Fix README headings --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index ab8dc81..707e7a9 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Source Map spec: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze These test cases are still a work-in-progress 🚧. -# Running the tests +#### Running the tests How to run in Firefox: * Check out mozilla-unified (see [Firefox dev setup](https://firefox-source-docs.mozilla.org/setup/index.html) under "Setting up your machine" for details, note that you can use git via [git-cinnabar](https://github.com/glandium/git-cinnabar/)) @@ -33,14 +33,14 @@ How to run in WebKit: Mozilla [source-map](https://github.com/mozilla/source-map) library: * There is a [branch](https://github.com/takikawa/source-map/tree/add-spec-tests) for adding the spec tests to the package. -# Goals of tests +### Goals of tests * Thoroughly test all aspects of the source maps spec that can be tested. * Strictly follow the spec when determining test behavior. -# Test coverage +### Test coverage -## Core spec +#### Core spec * Encoding - [ ] Source map must be a valid JSON document. @@ -161,6 +161,6 @@ Mozilla [source-map](https://github.com/mozilla/source-map) library: * Wasm support - [ ] Create versions of the tests that use a Wasm source. -## Scopes Proposal +### Scopes Proposal TODO From aa3ce8e7ee43a4a35aa6fd330b44c8bc9676e943 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Wed, 29 May 2024 14:54:49 -0700 Subject: [PATCH 67/68] Remove outdated files --- version-numbers.js | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 version-numbers.js diff --git a/version-numbers.js b/version-numbers.js deleted file mode 100644 index e79993b..0000000 --- a/version-numbers.js +++ /dev/null @@ -1,6 +0,0 @@ -// Test that invalid version numbers are rejected. - -assert(isValidSourceMap("./version-valid.map")); -assert(!isValidSourceMap("./version-not-a-number.map")); -assert(!isValidSourceMap("./version-too-low.map")); -assert(!isValidSourceMap("./version-too-high.map")); From 2e9b098770513555c54522e99df64b26ca061313 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Wed, 29 May 2024 14:56:03 -0700 Subject: [PATCH 68/68] Update Firefox info in README --- README.md | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/README.md b/README.md index 707e7a9..5ac28c5 100644 --- a/README.md +++ b/README.md @@ -16,13 +16,6 @@ These test cases are still a work-in-progress 🚧. #### Running the tests -How to run in Firefox: - * Check out mozilla-unified (see [Firefox dev setup](https://firefox-source-docs.mozilla.org/setup/index.html) under "Setting up your machine" for details, note that you can use git via [git-cinnabar](https://github.com/glandium/git-cinnabar/)) - * `cd` to the checked out directory. - * Run `git am /firefox/0001-WIP-Firefox-source-map-spec-tests.patch` - * Run `mach build` (this builds the test too, you'll need to run it if you modify tests/harness) - * Run `mach test devtools/client/shared/source-map-loader/` - How to run in WebKit: * Check out [WebKit](https://github.com/WebKit/WebKit/) * `cd` to the checked out WebKit directory. @@ -30,7 +23,7 @@ How to run in WebKit: * Run `Tools/Scripts/build-webkit` (depending on the platform you may need to pass `--gtk` or other flags) * Run `Tools/Scripts/run-webkit-tests LayoutTests/inspector/model/source-map-spec.html` (again, you may need `--gtk` on Linux) -Mozilla [source-map](https://github.com/mozilla/source-map) library: +For Firefox, see the Mozilla [source-map](https://github.com/mozilla/source-map) library: * There is a [branch](https://github.com/takikawa/source-map/tree/add-spec-tests) for adding the spec tests to the package. ### Goals of tests