Split LoAF sourceLocation to 3 attributes
As per spec, sourceURL / sourceFunctionName / sourceCharPosition
Amended existing test.
Bug: 1523675
Change-Id: Ic3bb8df05bb822fa8b56990e2696d67324b4763f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5250540
Reviewed-by: Ian Clelland <iclelland@chromium.org>
Reviewed-by: Rick Byers <rbyers@chromium.org>
Reviewed-by: Michal Mocny <mmocny@chromium.org>
Commit-Queue: Noam Rosenthal <nrosenthal@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1256409}
diff --git a/long-animation-frame/tentative/loaf-source-location-redirect.html b/long-animation-frame/tentative/loaf-source-location-redirect.html
index a6bfd68..c0bb96b 100644
--- a/long-animation-frame/tentative/loaf-source-location-redirect.html
+++ b/long-animation-frame/tentative/loaf-source-location-redirect.html
@@ -50,22 +50,20 @@
}, script => script.duration >= VERY_LONG_FRAME_DURATION - 5, t);
const result =
- script.sourceLocation.startsWith(postRedirectURL) ? "post-redirect" :
- script.sourceLocation.startsWith(preRedirectURL) ? "pre-redirect" :
- script.sourceLocation === "" ?
+ script.sourceURL.startsWith(postRedirectURL) ? "post-redirect" :
+ script.sourceURL.startsWith(preRedirectURL) ? "pre-redirect" :
+ script.sourceURL === "" ?
"empty" : "other";
- assert_not_equals(result, "other", `Unexpected source location ${script.sourceLocation}`);
+ assert_not_equals(result, "other", `Unexpected source location ${script.sourceURL}`);
if (!cors)
assert_equals(script.executionStart, script.startTime, "Opaque scripts should hide execution start time");
if (cors) {
assert_not_equals(result, "empty", "CORS-ok scripts should expose sourceLocation");
} else {
- const char_index = result === "empty" ? 0 :
- parseInt(script.sourceLocation.match(/\:(\d+)$/)?.[1] ?? "0");
assert_not_equals(result, "post-redirect", "No-CORS classic scripts should not expose post-redirect URL");
- assert_equals(char_index, 0, "No-CORS classic scripts should not expose character index");
+ assert_equals(script.sourceCharPosition, type === "script-block" ? 0 : -1, "No-CORS classic scripts should not expose character index");
}
}, `Test ${type} with ${scriptType}`);
}
diff --git a/long-animation-frame/tentative/loaf-source-location.html b/long-animation-frame/tentative/loaf-source-location.html
index cdd4bb4..51e8565 100644
--- a/long-animation-frame/tentative/loaf-source-location.html
+++ b/long-animation-frame/tentative/loaf-source-location.html
@@ -11,16 +11,15 @@
<div id="log"></div>
<script>
-const source_location_regex = /^([^@]+\@)?https?\:\/\/[^\/]+[^\:]+\:\d*$/;
-
promise_test(async t => {
const [entry, script] = await expect_long_frame_with_script(() => {
requestAnimationFrame(function non_bound_function() {
busy_wait();
});
}, script => script.invoker === "FrameRequestCallback", t);
- assert_true(script.sourceLocation?.startsWith("non_bound_function"));
- assert_regexp_match(script.sourceLocation, source_location_regex);
+ assert_equals(script.sourceURL, location.href);
+ assert_equals(script.sourceFunctionName, "non_bound_function");
+ assert_greater_than(script.sourceCharPosition, 0);
}, "Source location should be extracted from non-bound functions");
promise_test(async t => {
@@ -30,8 +29,9 @@
busy_wait();
}).bind(object));
}, script => script.invoker === "FrameRequestCallback", t);
- assert_true(script.sourceLocation?.startsWith("my_bound_function"));
- assert_regexp_match(script.sourceLocation, source_location_regex);
+ assert_equals(script.sourceURL, location.href);
+ assert_equals(script.sourceFunctionName, "my_bound_function");
+ assert_greater_than(script.sourceCharPosition, 0);
}, "Source location should be extracted from bound functions");
promise_test(async t => {
@@ -39,9 +39,8 @@
t.step_timeout(function my_timeout() {
busy_wait();
});
- }, script => script.invoker === "TimerHandler:setTimeout" && script.sourceLocation, t );
- assert_true(script.sourceLocation.includes("testharness.js"));
- assert_regexp_match(script.sourceLocation, source_location_regex);
+ }, script => script.invoker === "TimerHandler:setTimeout" && script.sourceURL, t );
+ assert_true(script.sourceURL.includes("testharness.js"));
}, "Source location should be extracted for setTimeout");
promise_test(async t => {
@@ -51,7 +50,7 @@
scriptElement.src = scriptLocation;
document.body.appendChild(scriptElement);
}, script => script.invoker === "Window.fetch.then", t);
- assert_true(script.sourceLocation?.includes("promise-generates-loaf.js"));
+ assert_true(script.sourceURL.includes("promise-generates-loaf.js"));
}, "Source location should be extracted for promises");
</script>
diff --git a/long-animation-frame/tentative/loaf-stream-source-location.html b/long-animation-frame/tentative/loaf-stream-source-location.html
index 79fb418..0fd3085 100644
--- a/long-animation-frame/tentative/loaf-stream-source-location.html
+++ b/long-animation-frame/tentative/loaf-stream-source-location.html
@@ -11,8 +11,6 @@
<div id="log"></div>
<script>
-const source_location_regex = /^([^@]+\@)?https?\:\/\/[^\/]+[^\:]+\:\d*$/;
-
promise_test(async t => {
const scriptLocation = new URL("resources/stream-promise-generates-loaf.js", location.href);
const [entry, script] = await expect_long_frame_with_script(() => {
@@ -21,7 +19,7 @@
document.body.appendChild(scriptElement);
}, script => script.invoker === "StreamPromise.resolve.then", t);
- assert_true(script.sourceLocation?.includes("stream-promise-generates-loaf.js"));
+ assert_true(script.sourceURL.includes("stream-promise-generates-loaf.js"));
}, "Source location should be extracted for stream promises");
</script>