Skip to content

Commit

Permalink
Remove non-standard HashChangeEvent.initHashChangeEvent
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=271094

Reviewed by Ryosuke Niwa.

This patch aligns WebKit with Blink / Chrome and Web Specification [1]:

[1] https://html.spec.whatwg.org/multipage/nav-history-apis.html#the-hashchangeevent-interface

By removing `initHashChangeEvent`, WebKit aligns with Web Specification
and Blink also removed it in 2015 via below commit:

Reference: https://src.chromium.org/viewvc/blink?view=revision&revision=202347

* Source/WebCore/dom/HashChangeEvent.idl:
* Source/WebCore/dom/HashChangeEvent.h:
(initHashChangeEvent): Removed
* LayoutTests/fast/events/initEvent-after-dispatching.html: Rebaselined
* LayoutTests/fast/events/initEvent-after-dispatching-expected.txt: Rebaselined

Canonical link: https://commits.webkit.org/276232@main
  • Loading branch information
Ahmad Saleem committed Mar 16, 2024
1 parent 56dbddd commit cf053c0
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 36 deletions.
14 changes: 0 additions & 14 deletions LayoutTests/fast/events/initEvent-after-dispatching-expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,6 @@ PASS testEvent.bubbles is false
PASS testEvent.cancelable is false
PASS document.body.dispatchEvent(testEvent) is true

* HashChangeEvent.prototype.initHashChangeEvent()
testEvent = document.createEvent(createEventString)
PASS testEvent.__proto__ is window[eventType].prototype
testEvent[initMethodName]('firstType', true, true)
PASS testEvent.type is "firstType"
PASS testEvent.bubbles is true
PASS testEvent.cancelable is true
PASS document.body.dispatchEvent(testEvent) is true
testEvent[initMethodName]('secondType', false, false)
PASS testEvent.type is "secondType"
PASS testEvent.bubbles is false
PASS testEvent.cancelable is false
PASS document.body.dispatchEvent(testEvent) is true

* KeyboardEvent.prototype.initKeyboardEvent()
testEvent = document.createEvent(createEventString)
PASS testEvent.__proto__ is window[eventType].prototype
Expand Down
1 change: 0 additions & 1 deletion LayoutTests/fast/events/initEvent-after-dispatching.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
}

testEventInitFunction("compositionevent", "CompositionEvent", "initCompositionEvent");
testEventInitFunction("hashchangeevent", "HashChangeEvent", "initHashChangeEvent");
testEventInitFunction("keyboardevent", "KeyboardEvent", "initKeyboardEvent");
testEventInitFunction("messageevent", "MessageEvent", "initMessageEvent");
testEventInitFunction("textevent", "TextEvent", "initTextEvent");
Expand Down
13 changes: 1 addition & 12 deletions Source/WebCore/dom/HashChangeEvent.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2010 Apple Inc. All rights reserved.
* Copyright (C) 2010-2024 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
Expand Down Expand Up @@ -48,17 +48,6 @@ class HashChangeEvent final : public Event {
return adoptRef(*new HashChangeEvent(type, initializer, isTrusted));
}

void initHashChangeEvent(const AtomString& eventType, bool canBubble, bool cancelable, const String& oldURL, const String& newURL)
{
if (isBeingDispatched())
return;

initEvent(eventType, canBubble, cancelable);

m_oldURL = oldURL;
m_newURL = newURL;
}

const String& oldURL() const { return m_oldURL; }
const String& newURL() const { return m_newURL; }

Expand Down
13 changes: 4 additions & 9 deletions Source/WebCore/dom/HashChangeEvent.idl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2010 Apple Inc. All rights reserved.
* Copyright (C) 2010-2024 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
Expand All @@ -17,17 +17,12 @@
* Boston, MA 02110-1301, USA.
*/

// Introduced in http://www.whatwg.org/specs/web-apps/current-work/multipage/history.html#event-hashchange
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#the-hashchangeevent-interface

[
Exposed=Window
] interface HashChangeEvent : Event {
constructor([AtomString] DOMString type, optional HashChangeEventInit eventInitDict);

undefined initHashChangeEvent([AtomString] DOMString type,
optional boolean canBubble = false,
optional boolean cancelable = false,
optional USVString oldURL = "undefined",
optional USVString newURL = "undefined");
constructor([AtomString] DOMString type, optional HashChangeEventInit eventInitDict = {});

readonly attribute USVString oldURL;
readonly attribute USVString newURL;
Expand Down

0 comments on commit cf053c0

Please sign in to comment.