Skip to content

Commit

Permalink
Occasional debug assertion under IntlNumberFormat::initializeNumberFo…
Browse files Browse the repository at this point in the history
…rmat when running Speedometer 3

https://bugs.webkit.org/show_bug.cgi?id=265113
rdar://118619451

Reviewed by Chris Dumez.

Grab the JSC API lock before calling into `JSObject::hasProperty()` when checking for the presence
of the `tableauPrep` property.

* LayoutTests/fast/events/key-event-with-quirks-enabled-expected.txt: Added.
* LayoutTests/fast/events/key-event-with-quirks-enabled.html: Added.
* Source/WebCore/bindings/js/JSLocalDOMWindowCustom.cpp:
(WebCore::JSLocalDOMWindow::getOwnPropertySlot):
(WebCore::JSLocalDOMWindow::getOwnPropertySlotByIndex):

Add a new debug assertion when reading properties off of the window object without having the JS API
lock; without the fix above, the assertion is hit in the new layout test, where site-specific quirks
are enabled.

* Source/WebCore/page/Quirks.cpp:
(WebCore::Quirks::needsDisableDOMPasteAccessQuirk const):

Canonical link: https://commits.webkit.org/270961@main
  • Loading branch information
whsieh committed Nov 20, 2023
1 parent ac61808 commit a6eac11
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
12 changes: 12 additions & 0 deletions LayoutTests/fast/events/key-event-with-quirks-enabled-expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Tests that basic key events work, and do not trigger assertions when quirks are enabled.

On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".


PASS Received keydown
PASS Received keyup
PASS receivedKeyUp became true
PASS successfullyParsed is true

TEST COMPLETE

31 changes: 31 additions & 0 deletions LayoutTests/fast/events/key-event-with-quirks-enabled.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!DOCTYPE html> <!-- webkit-test-runner [ NeedsSiteSpecificQuirks=true ] -->
<html>
<head>
<script src="../../resources/js-test.js"></script>
<script src="../../resources/ui-helper.js"></script>
</head>
<body>
<input id="textField"></input>
<script>
jsTestIsAsync = true;
receivedKeyUp = false;

addEventListener("load", async () => {
description("Tests that basic key events work, and do not trigger assertions when quirks are enabled.");

let textField = document.getElementById("textField");
textField.addEventListener("keydown", () => testPassed("Received keydown"));
textField.addEventListener("keyup", () => {
testPassed("Received keyup");
receivedKeyUp = true;
});

await UIHelper.activateElementAndWaitForInputSession(textField);
await UIHelper.keyDown("a");

await shouldBecomeEqual("receivedKeyUp", "true");
finishJSTest();
});
</script>
</body>
</html>
2 changes: 2 additions & 0 deletions Source/WebCore/bindings/js/JSLocalDOMWindowCustom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ bool JSLocalDOMWindow::getOwnPropertySlot(JSObject* object, JSGlobalObject* lexi

auto* thisObject = jsCast<JSLocalDOMWindow*>(object);

ASSERT(lexicalGlobalObject->vm().currentThreadIsHoldingAPILock());
// Construct3 assumes that the presence of OffscreenCanvas implies
// that WebGL will always be available, which isn't true yet.
// Disable OffscreenCanvas when the Construct3 library is present
Expand Down Expand Up @@ -245,6 +246,7 @@ bool JSLocalDOMWindow::getOwnPropertySlotByIndex(JSObject* object, JSGlobalObjec
// Indexed getters take precendence over regular properties, so caching would be invalid.
slot.disableCaching();

ASSERT(lexicalGlobalObject->vm().currentThreadIsHoldingAPILock());
// These are also allowed cross-origin, so come before the access check.
if (frame && index < frame->tree().scopedChildCount()) {
// FIXME: <rdar://118263337> LocalDOMWindow::length needs to include RemoteFrames.
Expand Down
3 changes: 3 additions & 0 deletions Source/WebCore/page/Quirks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
#include "UserContentTypes.h"
#include "UserScript.h"
#include "UserScriptTypes.h"
#include <JavaScriptCore/JSLock.h>

#if PLATFORM(COCOA)
#include <wtf/cocoa/RuntimeApplicationChecksCocoa.h>
Expand Down Expand Up @@ -1613,6 +1614,8 @@ bool Quirks::needsDisableDOMPasteAccessQuirk() const
auto* globalObject = m_document->globalObject();
if (!globalObject)
return false;

JSC::JSLockHolder lock(globalObject->vm());
auto tableauPrepProperty = JSC::Identifier::fromString(globalObject->vm(), "tableauPrep"_s);
return globalObject->hasProperty(globalObject, tableauPrepProperty);
}();
Expand Down

0 comments on commit a6eac11

Please sign in to comment.