mirror of
https://github.com/servo/servo.git
synced 2025-10-02 09:39:14 +01:00
script: Add line number argument to module script compilation functions (#39544)
Script: added ```line_no``` as argument to both ```fetch_inline_module_script()``` & ```compile_module_script()``` to fix the inline script reporting wrong line issue ([#39415](https://github.com/servo/servo/issues/39415)). Originally, the function ```compile_module_script()``` hardwires the value 1 when invoking ```CompileOptionsWrapper::new()```. This is fine if the script is written in separate JS file, but for inline scripts, it will cause confusion if the ```<script>``` tag doesn't start from line #1. ```line_no``` is obtained from ```line_number```, a member variable from ```HTMLScriptElement```. Credits to @jdm for actually pointing out which functions to fix. Testing: Created a WPT test for this change, specifically: ```tests/wpt/tests/html/semantics/scripting-1/the-script-element/module/evaluation-error-5.html```. Fixes: issue [#39415](https://github.com/servo/servo/issues/39415) --------- Signed-off-by: RichardTjokroutomo <richard.tjokro2@gmail.com> Signed-off-by: Rocketjumper <112361665+RichardTjokroutomo@users.noreply.github.com> Co-authored-by: Josh Matthews <josh@joshmatthews.net> Co-authored-by: Euclid Ye <yezhizhenjiakang@gmail.com>
This commit is contained in:
parent
5018cd8015
commit
91e4188a64
4 changed files with 33 additions and 4 deletions
7
tests/wpt/meta/MANIFEST.json
vendored
7
tests/wpt/meta/MANIFEST.json
vendored
|
@ -758650,6 +758650,13 @@
|
|||
{}
|
||||
]
|
||||
],
|
||||
"evaluation-error-5.html": [
|
||||
"3021ecd4a9f9c68a5632c43d1253e4938debf994",
|
||||
[
|
||||
null,
|
||||
{}
|
||||
]
|
||||
],
|
||||
"execorder.html": [
|
||||
"6a7513dc1361de0716584df8a5e7c8b3df2b69f3",
|
||||
[
|
||||
|
|
16
tests/wpt/tests/html/semantics/scripting-1/the-script-element/module/evaluation-error-5.html
vendored
Normal file
16
tests/wpt/tests/html/semantics/scripting-1/the-script-element/module/evaluation-error-5.html
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Handling of evaluation errors, 5</title>
|
||||
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
setup({allow_uncaught_exception: true});
|
||||
const test_load = async_test("Test for the inline module script error that reports wrong line\n");
|
||||
window.addEventListener("error", test_load.step_func_done(ev => {
|
||||
|
||||
const expectedLine = 16;
|
||||
assert_equals(ev.lineno, expectedLine);
|
||||
|
||||
}));
|
||||
</script>
|
||||
<script type="module">a</script>
|
Loading…
Add table
Add a link
Reference in a new issue