Skip to content

Commit bc9674a

Browse files
committed
REGRESSION(r274607): media controls script is visible in Web Inspector even without the engineering "Show WebKit-internal scripts" enabled
https://bugs.webkit.org/show_bug.cgi?id=223961 Reviewed by Yusuke Suzuki. It turns out that Web Inspector will only ignore scripts that have a source URL directive that matches `__InjectedScript_*.js`, not those that have a (source) URL matching that. In addition to Web Inspector ignoring these scripts in the UI, it will also cause the `Debugger` to not pause in scripts with a matching source URL directive (unless the local build engineering only "Pause in WebKit-internal scripts" is enabled). Source/JavaScriptCore: * Scripts/make-js-file-arrays.py: (main): Add a `//# sourceURL=__InjectedScript_*.js` to the contents before it's encoded. Source/WebCore: * html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::ensureMediaControlsInjectedScript): Change the `ScriptSourceCode` here to not have a `URL` and have `make-js-file-arrays.py` add a `//# sourceURL=__InjectedScript_*.js` to the contents before it's encoded. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275262 268f45cc-cd09-0410-ab3c-d52691b4dbfc Canonical link: https://commits.webkit.org/235949@main
1 parent fd90d87 commit bc9674a

4 files changed

Lines changed: 42 additions & 8 deletions

File tree

Source/JavaScriptCore/ChangeLog

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
2021-03-30 Devin Rousso <drousso@apple.com>
2+
3+
REGRESSION(r274607): media controls script is visible in Web Inspector even without the engineering "Show WebKit-internal scripts" enabled
4+
https://bugs.webkit.org/show_bug.cgi?id=223961
5+
6+
Reviewed by Yusuke Suzuki.
7+
8+
It turns out that Web Inspector will only ignore scripts that have a source URL directive
9+
that matches `__InjectedScript_*.js`, not those that have a (source) URL matching that.
10+
11+
In addition to Web Inspector ignoring these scripts in the UI, it will also cause the
12+
`Debugger` to not pause in scripts with a matching source URL directive (unless the
13+
local build engineering only "Pause in WebKit-internal scripts" is enabled).
14+
15+
* Scripts/make-js-file-arrays.py:
16+
(main):
17+
Add a `//# sourceURL=__InjectedScript_*.js` to the contents before it's encoded.
18+
119
2021-03-30 Sam Weinig <weinig@apple.com>
220

321
JSGlobalObject's m_customGetterFunctionMap and m_customSetterFunctionMap should be sets, not maps, and should use both the identifier and function pointer as the key

Source/JavaScriptCore/Scripts/make-js-file-arrays.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ def main():
7070
print('namespace {0:s} {{'.format(namespace), file=sourceFile)
7171

7272
for inputFileName in inputPaths:
73+
variableName = os.path.splitext(os.path.basename(inputFileName))[0]
74+
sourceURLDirective = "//# sourceURL=__InjectedScript_" + variableName + ".js\n"
7375

7476
if is_3:
7577
inputStream = io.open(inputFileName, encoding='utf-8')
@@ -79,9 +81,9 @@ def main():
7981
data = inputStream.read()
8082

8183
if not options.no_minify:
82-
characters = jsmin(data)
84+
characters = sourceURLDirective + jsmin(data)
8385
else:
84-
characters = data
86+
characters = sourceURLDirective + data
8587

8688
if options.fail_if_non_ascii:
8789
for character in characters:
@@ -97,8 +99,6 @@ def main():
9799
# because UTF-8 characters may need more than one byte.
98100
size = len(codepoints)
99101

100-
variableName = os.path.splitext(os.path.basename(inputFileName))[0]
101-
102102
print('extern const char {0:s}JavaScript[{1:d}];'.format(variableName, size), file=headerFile)
103103
print('const char {0:s}JavaScript[{1:d}] = {{'.format(variableName, size), file=sourceFile)
104104

Source/WebCore/ChangeLog

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
2021-03-30 Devin Rousso <drousso@apple.com>
2+
3+
REGRESSION(r274607): media controls script is visible in Web Inspector even without the engineering "Show WebKit-internal scripts" enabled
4+
https://bugs.webkit.org/show_bug.cgi?id=223961
5+
6+
Reviewed by Yusuke Suzuki.
7+
8+
It turns out that Web Inspector will only ignore scripts that have a source URL directive
9+
that matches `__InjectedScript_*.js`, not those that have a (source) URL matching that.
10+
11+
In addition to Web Inspector ignoring these scripts in the UI, it will also cause the
12+
`Debugger` to not pause in scripts with a matching source URL directive (unless the
13+
local build engineering only "Pause in WebKit-internal scripts" is enabled).
14+
15+
* html/HTMLMediaElement.cpp:
16+
(WebCore::HTMLMediaElement::ensureMediaControlsInjectedScript):
17+
Change the `ScriptSourceCode` here to not have a `URL` and have `make-js-file-arrays.py`
18+
add a `//# sourceURL=__InjectedScript_*.js` to the contents before it's encoded.
19+
120
2021-03-30 Venky Dass <yaranamavenkataramana@apple.com>
221

322
Nullptr crash in Crash in WebCore::positionInParentBeforeNode(..) where a NULL check is missing.

Source/WebCore/html/HTMLMediaElement.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7160,13 +7160,10 @@ bool HTMLMediaElement::ensureMediaControlsInjectedScript()
71607160
if (functionValue.isCallable(vm))
71617161
return true;
71627162

7163-
unsigned index = 0;
71647163
for (auto& mediaControlsScript : mediaControlsScripts) {
71657164
if (mediaControlsScript.isEmpty())
71667165
continue;
7167-
// Setting a scriptURL allows the source to be debuggable in the inspector.
7168-
URL scriptURL = URL({ }, makeString("__InjectedScript_mediaControlsScript"_s, ++index, ".js"));
7169-
scriptController.evaluateInWorldIgnoringException(ScriptSourceCode(mediaControlsScript, WTFMove(scriptURL)), world);
7166+
scriptController.evaluateInWorldIgnoringException(ScriptSourceCode(mediaControlsScript), world);
71707167
if (UNLIKELY(scope.exception())) {
71717168
auto* exception = scope.exception();
71727169
scope.clearException();

0 commit comments

Comments
 (0)