Truly independent web browser
LibWeb: Expose Touch Events and dispatch touch contact lists
Andreas Klinga3f24be614b8
diff --git a/Libraries/LibWeb/CMakeLists.txt b/Libraries/LibWeb/CMakeLists.txtindex e0fbea45c99..2b0aceb5054 100644--- a/Libraries/LibWeb/CMakeLists.txt+++ b/Libraries/LibWeb/CMakeLists.txt@@ -966,6 +966,9 @@ set(SOURCESUIEvents/PointerEvent.cppUIEvents/PointerTypes.cppUIEvents/TextEvent.cpp+ UIEvents/Touch.cpp+ UIEvents/TouchEvent.cpp+ UIEvents/TouchList.cppUIEvents/UIEvent.cppUIEvents/WheelEvent.cppUserTiming/PerformanceMark.cppdiff --git a/Libraries/LibWeb/DOM/Document.cpp b/Libraries/LibWeb/DOM/Document.cppindex ad1845cd4c0..85609d3b481 100644--- a/Libraries/LibWeb/DOM/Document.cpp+++ b/Libraries/LibWeb/DOM/Document.cpp@@ -195,6 +195,7 @@#include <LibWeb/HTML/NavigationActivation.h>#include <LibWeb/HTML/NavigationHistoryEntry.h>#include <LibWeb/HTML/NavigationParams.h>+#include <LibWeb/HTML/Navigator.h>#include <LibWeb/HTML/Numbers.h>#include <LibWeb/HTML/Parser/HTMLParser.h>#include <LibWeb/HTML/PolicyContainers.h>@@ -267,6 +268,7 @@#include <LibWeb/UIEvents/PointerEvent.h>#include <LibWeb/UIEvents/PointerTypes.h>#include <LibWeb/UIEvents/TextEvent.h>+#include <LibWeb/UIEvents/TouchEvent.h>#include <LibWeb/UpgradeInsecureRequests/AbstractOperations.h>#include <LibWeb/ViewTransition/ViewTransition.h>#include <LibWeb/WebDriver/BiDi/BiDi.h>@@ -3332,21 +3334,17 @@ static void mark_mouse_transition_event_as_trusted_if_needed(Event& event, Optioevent.set_is_trusted(true);}-void Document::set_hovered_node(GC::Ptr<Node> node, Optional<HoverEventData> hover_event_data, BoundaryEventTypes types)+void Document::set_hovered_node(GC::Ptr<Node> node, Optional<HoverEventData> hover_event_data){- // The style's hover follows the node the events hover. A hover beside the host may have moved it already, while- // the hovered node of the events stayed.- CSS::move_style_hover(*this, node);- if (m_hovered_node == node)- return;-- auto old_hovered_node = m_hovered_node;- m_hovered_node = node;- dispatch_boundary_events(old_hovered_node, node, hover_event_data, types);+ dispatch_boundary_events(m_hovered_node, node, hover_event_data, BoundaryEventTypes::All);}void Document::dispatch_boundary_events(GC::Ptr<Node> old_hovered_node, GC::Ptr<Node> node, Optional<HoverEventData> hover_event_data, BoundaryEventTypes types){+ // The style's hover follows the node the events hover. A hover beside the host may have moved it already, while+ // the hovered node of the events stayed.+ CSS::move_style_hover(*this, node);+ m_hovered_node = node;if (old_hovered_node == node)return;Layout::ForcedReadScope read { *this };@@ -3865,7 +3863,9 @@ WebIDL::ExceptionOr<GC::Ref<Event>> Document::create_event(Utf16FlyString const&} else if (interface.equals_ignoring_ascii_case("textevent"sv)) {event = UIEvents::TextEvent::create(Utf16FlyString {}, time_stamp);} else if (interface.equals_ignoring_ascii_case("touchevent"sv)) {- event = Event::create(FlyString {}, time_stamp); // FIXME: Create TouchEvent+ // INTEROP: Blink gates this legacy factory on touch feature detection even though its constructor is exposed.+ if (HTML::Navigator::max_touch_points() > 0)+ event = UIEvents::TouchEvent::create(FlyString {}, Bindings::TouchEventInit {}, time_stamp);} else if (interface.equals_ignoring_ascii_case("uievent"sv)|| interface.equals_ignoring_ascii_case("uievents"sv)) {event = UIEvents::UIEvent::create(FlyString {}, time_stamp);diff --git a/Libraries/LibWeb/DOM/Document.h b/Libraries/LibWeb/DOM/Document.hindex faac74c4128..682edd07e18 100644--- a/Libraries/LibWeb/DOM/Document.h+++ b/Libraries/LibWeb/DOM/Document.h@@ -436,7 +436,7 @@ public:Mouse,All,};- void set_hovered_node(GC::Ptr<Node>, Optional<HoverEventData> = {}, BoundaryEventTypes = BoundaryEventTypes::All);+ void set_hovered_node(GC::Ptr<Node>, Optional<HoverEventData> = {});void dispatch_boundary_events(GC::Ptr<Node> old_target, GC::Ptr<Node> target, Optional<HoverEventData>, BoundaryEventTypes);Node* hovered_node() { return m_hovered_node.ptr(); }Node const* hovered_node() const { return m_hovered_node.ptr(); }diff --git a/Libraries/LibWeb/DOM/EventDispatcher.cpp b/Libraries/LibWeb/DOM/EventDispatcher.cppindex 9dddd593f06..8f0424f84df 100644--- a/Libraries/LibWeb/DOM/EventDispatcher.cpp+++ b/Libraries/LibWeb/DOM/EventDispatcher.cpp@@ -31,6 +31,7 @@#include <LibWeb/HTML/Window.h>#include <LibWeb/HighResolutionTime/TimeOrigin.h>#include <LibWeb/UIEvents/MouseEvent.h>+#include <LibWeb/UIEvents/TouchEvent.h>namespace Web::DOM {@@ -167,7 +168,12 @@ void EventDispatcher::invoke(Event::PathEntry& struct_, Event& event, Event::Phaevent.set_related_target(struct_.related_target.ptr());// 3. Set event’s touch target list to struct’s touch target list.- event.set_touch_target_list(struct_.touch_target_list);+ // OPTIMIZATION: Every path entry has the same touch target count. Ordinary events keep their empty list.+ if (!struct_.touch_target_list.is_empty()) {+ event.set_touch_target_list(struct_.touch_target_list);+ if (auto* touch_event = as_if<UIEvents::TouchEvent>(&event))+ touch_event->retarget_touch_lists();+ }// 4. If event’s stop propagation flag is set, then return.if (event.should_stop_propagation())diff --git a/Libraries/LibWeb/DOM/EventTarget.cpp b/Libraries/LibWeb/DOM/EventTarget.cppindex 2362d88c94a..b698e07efdb 100644--- a/Libraries/LibWeb/DOM/EventTarget.cpp+++ b/Libraries/LibWeb/DOM/EventTarget.cpp@@ -1137,7 +1137,9 @@ bool EventTarget::dispatch_event(Event& event)return pointer_event->pointer_type() != u"mouse"sv;}- // FIXME: touchend+ // touchend.+ if (event.type() == UIEvents::EventNames::touchend)+ return true;return false;};diff --git a/Libraries/LibWeb/Forward.h b/Libraries/LibWeb/Forward.hindex 9b84ffc5ffd..afaf82310b2 100644--- a/Libraries/LibWeb/Forward.h+++ b/Libraries/LibWeb/Forward.h@@ -1171,6 +1171,9 @@ class KeyboardEvent;class MouseEvent;class PointerEvent;class TextEvent;+class Touch;+class TouchEvent;+class TouchList;class UIEvent;}diff --git a/Libraries/LibWeb/Internals/Internals.cpp b/Libraries/LibWeb/Internals/Internals.cppindex e6f74c59123..7a155ac6e88 100644--- a/Libraries/LibWeb/Internals/Internals.cpp+++ b/Libraries/LibWeb/Internals/Internals.cpp@@ -2036,8 +2036,10 @@ void Internals::perform_per_test_cleanup()m_gamepads.clear();// Clear any input state- if (auto local_root = local_root_of(window()))+ if (auto local_root = local_root_of(window())) {local_root->event_handler().clear_per_test_input_state({});+ WebDriver::reset_input_state(*local_root->top_level_traversable());+ }if (page().input_trace().is_recording())(void)take_input_trace_records(window());diff --git a/Libraries/LibWeb/Page/EventHandler.cpp b/Libraries/LibWeb/Page/EventHandler.cppindex 5216228a7bf..c647ea4aca0 100644--- a/Libraries/LibWeb/Page/EventHandler.cpp+++ b/Libraries/LibWeb/Page/EventHandler.cpp@@ -80,6 +80,7 @@#include <LibWeb/UIEvents/PointerEvent.h>#include <LibWeb/UIEvents/PointerTypes.h>#include <LibWeb/UIEvents/TextEvent.h>+#include <LibWeb/UIEvents/TouchEvent.h>#include <LibWeb/UIEvents/WheelEvent.h>#include <LibWeb/VisualLines.h>#include <LibWebCommon/Clipboard/SystemClipboard.h>@@ -235,7 +236,11 @@ void EventHandler::visit_edges(JS::Cell::Visitor& visitor) constif (m_mouse_selection_target)visitor.visit(m_mouse_selection_target->as_cell());visitor.visit(m_selection_origin);+ visitor.visit(m_native_mouse_hover_target);visitor.visit(m_navigable);+ visitor.visit(m_mouse_pointer.touch);+ for (auto const& entry : m_additional_pointers)+ visitor.visit(entry.value->state.touch);m_drag_and_drop_event_handler->visit_edges(visitor);if (m_auto_scroll_handler)m_auto_scroll_handler->visit_edges(visitor);@@ -1465,6 +1470,8 @@ void EventHandler::update_hover_after_scroll()// hover, could find another.void EventHandler::update_hover_at(CSSPixelPoint visual_viewport_position, GC::Ptr<DOM::Node> hover_target){+ if (m_effective_legacy_mouse_pointer_type != PointerType::Mouse)+ return;// The pointer is where the compositor saw it last, which is as far from where the host last heard of it on screen.auto screen_position = visual_viewport_position;if (m_last_known_mouse_visual_viewport_position.has_value())@@ -1503,6 +1510,8 @@ void EventHandler::update_cursor_after_rendering_update()void EventHandler::update_hover_after_scroll(CSSPixelPoint visual_viewport_position, CSSPixelPoint screen_position, unsigned button, unsigned buttons, unsigned modifiers, GC::Ptr<DOM::Node> hover_target){+ if (m_effective_legacy_mouse_pointer_type != PointerType::Mouse)+ return;if (should_ignore_device_input_event())return;@@ -4432,6 +4441,56 @@ void EventHandler::update_pointer_hover(Layout::BegunRead const& read, PointerStdispatch(boundary, UIEvents::EventNames::pointerenter, previous, false);}+// https://w3c.github.io/touch-events/#touchevent-interface+bool EventHandler::dispatch_touch_event(PointerState& pointer, DOM::Node& target, Utf16FlyString const& name, MouseEventCoordinates const& coordinates, CSSPixelPoint screen_position)+{+ auto original_target = GC::Ref<DOM::EventTarget> { target };+ Bindings::TouchInit init {+ .identifier = pointer.properties.pointer_id,+ .target = original_target,+ };+ init.client_x = coordinates.viewport_position.x().to_double();+ init.client_y = coordinates.viewport_position.y().to_double();+ init.page_x = coordinates.page_offset.x().to_double();+ init.page_y = coordinates.page_offset.y().to_double();+ init.screen_x = screen_position.x().to_double();+ init.screen_y = screen_position.y().to_double();+ if (name == UIEvents::EventNames::touchcancel && pointer.touch) {+ init.client_x = pointer.touch->client_x();+ init.client_y = pointer.touch->client_y();+ init.page_x = pointer.touch->page_x();+ init.page_y = pointer.touch->page_y();+ init.screen_x = pointer.touch->screen_x();+ init.screen_y = pointer.touch->screen_y();+ }+ init.radius_x = pointer.properties.width / 2;+ init.radius_y = pointer.properties.height / 2;+ init.force = pointer.properties.pressure;+ pointer.touch = UIEvents::Touch::create(init);++ Bindings::TouchEventInit event_init;+ event_init.bubbles = true;+ event_init.cancelable = name != UIEvents::EventNames::touchcancel;+ event_init.composed = true;+ event_init.view = m_navigable->active_window_proxy();+ event_init.alt_key = pointer.modifiers & UIEvents::Mod_Alt;+ event_init.meta_key = pointer.modifiers & UIEvents::Mod_Super;+ event_init.ctrl_key = pointer.modifiers & UIEvents::Mod_Ctrl;+ event_init.shift_key = pointer.modifiers & UIEvents::Mod_Shift;+ for (auto const& entry : m_additional_pointers) {+ auto const& contact = entry.value->state;+ if (!contact.touch || !contact.buttons)+ continue;+ event_init.touches.append(*contact.touch);+ if (contact.touch->target() == original_target)+ event_init.target_touches.append(*contact.touch);+ }+ event_init.changed_touches.append(*pointer.touch);+ auto event = UIEvents::TouchEvent::create(name.to_utf16_string(), event_init, HighResolutionTime::current_high_resolution_time(HTML::relevant_global_object(target)));+ event->set_is_trusted(true);+ return original_target->dispatch_event(event);+}+bool EventHandler::has_pointer_capture_in_subtree(i32 pointer_id) const{auto const* state = pointer_state(pointer_id);@@ -4465,21 +4524,25 @@ EventResult EventHandler::handle_pointer_event(Web::MouseEvent const& input, CSSreturn EventResult::Handled;auto pointer = make_ref_counted<AdditionalPointerState>();pointer->state.properties = *properties;- pointer->state.is_primary = true;+ m_additional_pointers.set(properties->pointer_id, move(pointer));+ it = m_additional_pointers.find(properties->pointer_id);+ }+ // NB: Event listeners can replace the document and clear the pointer map while this input is being dispatched.+ auto pointer_ref = it->value;+ auto& pointer = pointer_ref->state;+ // NB: Retain the touch's original target before listeners can clear the pointer map.+ GC::Ptr<DOM::Node> original_touch_target = pointer.touch ? &as<DOM::Node>(*pointer.touch->target()) : nullptr;+ if (!pointer.active) {+ pointer.is_primary = true;for (auto const& navigable : m_navigable->page().hosted_navigables()) {for (auto const& entry : navigable->event_handler().m_additional_pointers) {if (entry.key != properties->pointer_id && entry.value->state.active && entry.value->state.properties.pointer_type == properties->pointer_type) {- pointer->state.is_primary = false;+ pointer.is_primary = false;break;}}}- m_additional_pointers.set(properties->pointer_id, move(pointer));- it = m_additional_pointers.find(properties->pointer_id);}- // NB: Event listeners can replace the document and clear the pointer map while this input is being dispatched.- auto pointer_ref = it->value;- auto& pointer = pointer_ref->state;auto previous_buttons = pointer.buttons;auto previous_position = pointer.last_position;bool cancelled = input.type == Web::MouseEvent::Type::MouseCancel;@@ -4495,12 +4558,13 @@ EventResult EventHandler::handle_pointer_event(Web::MouseEvent const& input, CSSif (input.type == Web::MouseEvent::Type::MouseUp && pointer.buttons == 0)pointer.properties.pressure = 0;- if (pointer.properties.pointer_type == PointerType::Touch && previous_buttons == 0 && pointer.buttons == 0)+ bool is_touch = pointer.properties.pointer_type == PointerType::Touch;+ if (is_touch && previous_buttons == 0 && pointer.buttons == 0)return EventResult::Handled;Layout::ForcedReadScope read { *document };document->update_layout(DOM::UpdateLayoutReason::EventHandlerHandleMouseMove);- if (!has_committed_root_box())+ if (!has_committed_root_box() && !(is_touch && cancelled))return EventResult::Dropped;auto viewport_position = document->visual_viewport()->map_to_layout_viewport(visual_viewport_position);auto hit = target_for_mouse_position(visual_viewport_position);@@ -4511,7 +4575,7 @@ EventResult EventHandler::handle_pointer_event(Web::MouseEvent const& input, CSS// held in another WebContent process, to its owning EventHandler.if (auto* container = as_if<HTML::NavigableContainer>(pointer.nested_target.ptr().ptr())) {auto* child = as_if<HTML::LocalNavigable>(container->content_navigable().ptr());- if (child && child->event_handler().has_pointer_capture_in_subtree(properties->pointer_id)) {+ if (child && (is_touch || child->event_handler().has_pointer_capture_in_subtree(properties->pointer_id))) {if (auto* container_layout = container->layout_node(read)) {auto result = dispatch_event_to_nested_navigable(*this, *container_layout, container, visual_viewport_position, remote_target, [&](EventHandler& handler, CSSPixelPoint position) {return handler.handle_pointer_event(input, position, screen_position, remote_target);@@ -4522,9 +4586,35 @@ EventResult EventHandler::handle_pointer_event(Web::MouseEvent const& input, CSSm_additional_pointers.remove(properties->pointer_id);return *result;}+ } else if (is_touch) {+ // NB: An unrendered frame can no longer map input into its document. Cancel its existing contact+ // at the last delivered position, then suppress the parent proxy until the physical release.+ pointer.nested_target = nullptr;+ auto cleanup = input.clone_without_browser_data();+ cleanup.type = Web::MouseEvent::Type::MouseCancel;+ auto& child_handler = child->event_handler();+ child_handler.set_handling_outdated_input(handling_outdated_input());+ child_handler.set_handling_input_event_id(handling_input_event_id());+ ScopeGuard end_input = [&] {+ child_handler.set_handling_outdated_input(false);+ child_handler.set_handling_input_event_id(0);+ };+ (void)child_handler.handle_pointer_event(cleanup, {}, screen_position, nullptr);+ pointer.active = false;+ if (cancelled || (input.type == Web::MouseEvent::Type::MouseUp && pointer.buttons == 0))+ m_additional_pointers.remove(properties->pointer_id);+ return EventResult::Handled;}}}+ // NB: A touch forwarded to a child belongs to that document until it ends. If that document is no longer+ // reachable, do not start a continuation in this document.+ if (is_touch && !original_touch_target && previous_buttons != 0) {+ pointer.active = false;+ if (cancelled || (input.type == Web::MouseEvent::Type::MouseUp && pointer.buttons == 0))+ m_additional_pointers.remove(properties->pointer_id);+ return EventResult::Handled;+ }GC::Ptr<DOM::Node> nested_target = !pointer.pending_capture_target && layout_node && Painting::is_navigable_container_viewport_paintable(*layout_node) ? hit_target : nullptr;if (auto previous_nested_target = pointer.nested_target.ptr(); previous_nested_target && previous_nested_target != nested_target) {pointer.nested_target = nullptr;@@ -4549,7 +4639,7 @@ EventResult EventHandler::handle_pointer_event(Web::MouseEvent const& input, CSSlayout_node = hit.has_value() ? hit->layout_node(read) : nullptr;}}- if (!pointer.pending_capture_target && layout_node) {+ if ((!is_touch || (input.type == Web::MouseEvent::Type::MouseDown && previous_buttons == 0)) && !pointer.pending_capture_target && layout_node) {auto result = dispatch_event_to_nested_navigable(*this, *layout_node, hit_target, visual_viewport_position, remote_target, [&](EventHandler& child, CSSPixelPoint position) {return child.handle_pointer_event(input, position, screen_position, remote_target);});@@ -4590,7 +4680,11 @@ EventResult EventHandler::handle_pointer_event(Web::MouseEvent const& input, CSSif (auto* target_layout = target->layout_node(read))coordinates = compute_mouse_event_coordinates(coordinates.visual_viewport_position, coordinates.viewport_position, *target_layout);}+ if (!original_touch_target)+ original_touch_target = target;update_pointer_hover(read, pointer, target, coordinates, screen_position);+ if (m_navigable->active_document() != document)+ return EventResult::Handled;if (!target || input.type == Web::MouseEvent::Type::MouseLeave) {if (!target && pointer.is_primary && pointer.properties.pointer_type == PointerType::Pen) {DOM::HoverEventData hover_data {@@ -4602,9 +4696,20 @@ EventResult EventHandler::handle_pointer_event(Web::MouseEvent const& input, CSS.buttons = pointer.buttons,.modifiers = pointer.modifiers,};+ m_effective_legacy_mouse_pointer_type = pointer.properties.pointer_type;document->dispatch_boundary_events(m_effective_legacy_mouse_pointer_position.ptr(), nullptr, hover_data, DOM::Document::BoundaryEventTypes::Mouse);m_effective_legacy_mouse_pointer_position = nullptr;- CSS::move_style_hover(*document, nullptr);+ if (m_navigable->active_document() != document)+ return EventResult::Handled;+ }+ if (is_touch && original_touch_target && input.type != Web::MouseEvent::Type::MouseLeave) {+ auto touch_name = cancelled ? UIEvents::EventNames::touchcancel+ : input.type == Web::MouseEvent::Type::MouseUp && pointer.buttons == 0 ? UIEvents::EventNames::touchend+ : UIEvents::EventNames::touchmove;+ if (!dispatch_touch_event(pointer, *original_touch_target, touch_name, coordinates, screen_position)) {+ pointer.prevent_mouse_event = true;+ pointer.suppress_click = true;+ }if (m_navigable->active_document() != document)return EventResult::Handled;}@@ -4636,8 +4741,19 @@ EventResult EventHandler::handle_pointer_event(Web::MouseEvent const& input, CSSpointer.down_target = target;if (pointer.properties.pointer_type == PointerType::Touch && is<DOM::Element>(*target))pointer.pending_capture_target = as<DOM::Element>(*target);+ if (pointer.properties.pointer_type == PointerType::Touch) {+ for (auto const& navigable : m_navigable->page().hosted_navigables()) {+ for (auto const& entry : navigable->event_handler().m_additional_pointers) {+ auto& other = entry.value->state;+ if (entry.key == properties->pointer_id || !other.active || !other.buttons || other.properties.pointer_type != PointerType::Touch)+ continue;+ pointer.prevent_mouse_event = other.prevent_mouse_event = true;+ pointer.suppress_click = other.suppress_click = true;+ }+ }+ }}- if (pointer.is_primary && !cancelled) {+ if (pointer.is_primary && !cancelled && pointer.properties.pointer_type != PointerType::Touch) {DOM::HoverEventData hover_data {.screen_position = screen_position,.page_offset = coordinates.page_offset,@@ -4647,9 +4763,9 @@ EventResult EventHandler::handle_pointer_event(Web::MouseEvent const& input, CSS.buttons = pointer.buttons,.modifiers = pointer.modifiers,};+ m_effective_legacy_mouse_pointer_type = pointer.properties.pointer_type;document->dispatch_boundary_events(m_effective_legacy_mouse_pointer_position.ptr(), target, hover_data, DOM::Document::BoundaryEventTypes::Mouse);m_effective_legacy_mouse_pointer_position = target;- CSS::move_style_hover(*document, target);if (m_navigable->active_document() != document)return EventResult::Handled;}@@ -4686,32 +4802,120 @@ EventResult EventHandler::handle_pointer_event(Web::MouseEvent const& input, CSSreturn EventResult::Handled;}+ if (is_touch) {+ auto touch_name = cancelled ? UIEvents::EventNames::touchcancel+ : name == UIEvents::EventNames::pointerdown ? UIEvents::EventNames::touchstart+ : name == UIEvents::EventNames::pointerup ? UIEvents::EventNames::touchend+ : UIEvents::EventNames::touchmove;+ auto allowed = dispatch_touch_event(pointer, *original_touch_target, touch_name, coordinates, screen_position);+ if (!allowed && touch_name != UIEvents::EventNames::touchcancel) {+ pointer.prevent_mouse_event = true;+ pointer.suppress_click = true;+ }+ if (m_navigable->active_document() != document)+ return EventResult::Handled;+ }+// https://w3c.github.io/pointerevents/#compatibility-mapping-with-mouse-eventsif (pointer.is_primary && !cancelled) {- if (!pointer.prevent_mouse_event) {+ GC::Ptr<DOM::Node> mouse_target = target;+ auto mouse_coordinates = coordinates;+ if (is_touch && name == UIEvents::EventNames::pointerup && !pointer.suppress_click) {+ // INTEROP: Touch compatibility mouse events use the element at the contact position, independent of+ // pointer capture. The PointerEvent click below still follows the captured pointerup target.+ document->update_layout(DOM::UpdateLayoutReason::EventHandlerHandleMouseUp);+ auto mouse_hit = target_for_mouse_position(visual_viewport_position);+ mouse_target = mouse_hit.has_value() ? mouse_hit->dom_node() : nullptr;+ auto* mouse_layout = mouse_hit.has_value() ? mouse_hit->layout_node(read) : nullptr;+ if (mouse_target && mouse_layout) {+ if (parent_element_for_event_dispatch(*mouse_layout, mouse_target, mouse_layout))+ mouse_coordinates = compute_mouse_event_coordinates(visual_viewport_position, viewport_position, *mouse_layout);+ else+ mouse_target = nullptr;+ }+ }+ auto fire_mouse = [&](Utf16FlyString const& mouse_name, unsigned buttons, int detail) {+ auto mouse_event = UIEvents::MouseEvent::create_from_platform_event(HTML::relevant_global_object(*document), m_navigable->active_window_proxy(), mouse_name,+ screen_position, mouse_coordinates.page_offset, mouse_coordinates.viewport_position, mouse_coordinates.offset, {},+ to_underlying(input.button), buttons, pointer.modifiers, detail)+ .release_value_but_fixme_should_propagate_errors();+ return mouse_target && mouse_target->dispatch_event(mouse_event);+ };+ // https://w3c.github.io/touch-events/#mouse-events+ // INTEROP: Defer a touch's compatibility mouse events until touchend, as Blink and Gecko do, so that canceling+ // touchstart, touchmove or touchend can suppress the whole fallback sequence.+ if (is_touch && name == UIEvents::EventNames::pointerup && !pointer.suppress_click && mouse_target) {+ DOM::HoverEventData hover_data {+ .screen_position = screen_position,+ .page_offset = mouse_coordinates.page_offset,+ .viewport_position = mouse_coordinates.viewport_position,+ .offset = mouse_coordinates.offset,+ .movement = {},+ .buttons = 0,+ .modifiers = pointer.modifiers,+ };+ m_effective_legacy_mouse_pointer_type = pointer.properties.pointer_type;+ document->dispatch_boundary_events(m_effective_legacy_mouse_pointer_position.ptr(), mouse_target, hover_data, DOM::Document::BoundaryEventTypes::Mouse);+ m_effective_legacy_mouse_pointer_position = mouse_target;+ if (m_navigable->active_document() != document)+ return EventResult::Handled;+ if (!pointer.prevent_mouse_event) {+ fire_mouse(UIEvents::EventNames::mousemove, 0, 0);+ if (m_navigable->active_document() != document)+ return EventResult::Handled;+ auto allowed = fire_mouse(UIEvents::EventNames::mousedown, UIEvents::MouseButton::Primary, 1);+ if (m_navigable->active_document() != document)+ return EventResult::Handled;+ if (allowed) {+ document->update_layout(DOM::UpdateLayoutReason::EventHandlerHandleMouseDown);+ if (auto focus_target = focus_candidate_for_position(read, visual_viewport_position))+ HTML::run_focusing_steps(focus_target, nullptr, HTML::FocusTrigger::Click);+ }+ if (m_navigable->active_document() != document)+ return EventResult::Handled;+ fire_mouse(UIEvents::EventNames::mouseup, 0, 1);+ }+ } else if (!is_touch && !pointer.prevent_mouse_event) {auto mouse_name = input.type == Web::MouseEvent::Type::MouseDown ? UIEvents::EventNames::mousedown: input.type == Web::MouseEvent::Type::MouseUp ? UIEvents::EventNames::mouseup: UIEvents::EventNames::mousemove;- auto mouse_event = UIEvents::MouseEvent::create_from_platform_event(HTML::relevant_global_object(*document), m_navigable->active_window_proxy(), mouse_name,- screen_position, coordinates.page_offset, coordinates.viewport_position, coordinates.offset, {},- to_underlying(input.button), pointer.buttons, pointer.modifiers, mouse_name == UIEvents::EventNames::mousemove ? 0 : 1)- .release_value_but_fixme_should_propagate_errors();- auto allowed = target->dispatch_event(mouse_event);+ auto allowed = fire_mouse(mouse_name, pointer.buttons, mouse_name == UIEvents::EventNames::mousemove ? 0 : 1);if (m_navigable->active_document() != document)return EventResult::Handled;if (allowed && mouse_name == UIEvents::EventNames::mousedown) {+ document->update_layout(DOM::UpdateLayoutReason::EventHandlerHandleMouseDown);if (auto focus_target = focus_candidate_for_position(read, visual_viewport_position))HTML::run_focusing_steps(focus_target, nullptr, HTML::FocusTrigger::Click);}}- if (name == UIEvents::EventNames::pointerup && input.button == UIEvents::MouseButton::Primary) {+ if (m_navigable->active_document() != document)+ return EventResult::Handled;+ if (name == UIEvents::EventNames::pointerup && input.button == UIEvents::MouseButton::Primary && !pointer.suppress_click) {auto click_target = capture_target ? target : target_for_click_event(pointer.down_target.ptr().ptr(), *target);if (click_target) {+ document->update_layout(DOM::UpdateLayoutReason::EventHandlerHandleMouseUp);auto click_coordinates = coordinates;if (auto* click_layout = click_target->layout_node(read))click_coordinates = compute_mouse_event_coordinates(visual_viewport_position, viewport_position, *click_layout);+ GC::ConservativeVector<GC::Ref<DOM::Node>> touch_hover_ancestors;+ if (is_touch) {+ for (auto* ancestor = mouse_target.ptr(); ancestor; ancestor = ancestor->parent_or_shadow_host())+ touch_hover_ancestors.append(*ancestor);+ }auto click = create_pointer_event(pointer, *click_target, UIEvents::EventNames::click, click_coordinates, screen_position, 0);- if (click_target->dispatch_event(click))+ auto allowed = click_target->dispatch_event(click);+ if (m_navigable->active_document() != document)+ return EventResult::Handled;+ if (is_touch && mouse_target && !mouse_target->is_connected()) {+ for (auto ancestor : touch_hover_ancestors) {+ if (!ancestor->is_connected())+ continue;+ document->dispatch_boundary_events(ancestor, ancestor, {}, DOM::Document::BoundaryEventTypes::Mouse);+ m_effective_legacy_mouse_pointer_position = ancestor;+ break;+ }+ }+ if (allowed)run_activation_behavior(*click_target, to_underlying(input.button), pointer.modifiers);}}@@ -5064,27 +5268,32 @@ void EventHandler::track_the_effective_position_of_the_legacy_mouse_pointer(GC::// 1. Let T be the target of the pointerdown, pointerup or pointermove event being dispatched. For the pointerleave// event, unset T.- // 2. If T and current effective legacy mouse pointer position are both unset or they are equal, terminate these- // steps.- if (m_effective_legacy_mouse_pointer_position == target && document.hovered_node() == target.ptr())- return;-// AD-HOC: An event older than a pointer move whose hover the screen showed leaves the pointer where that move went.if (m_handling_outdated_input)return;+ m_effective_legacy_mouse_pointer_type = PointerType::Mouse;++ // 2. If T and current effective legacy mouse pointer position are both unset or they are equal, terminate these+ // steps.+ // NB: A primary touch or pen pointer can move the effective legacy mouse pointer position away from the native+ // mouse pointer's boundary target, so the native pointer's boundary events also need to reach T.+ auto previous_pointer_target = m_native_mouse_hover_target;+ if (m_effective_legacy_mouse_pointer_position == target && previous_pointer_target == target)+ return;// 3. Dispatch mouseover, mouseout, mouseenter and mouseleave events as per [UIEVENTS] for a mouse moving from the// current effective legacy mouse pointer position to T. Consider an unset value of either current effective// legacy mouse pointer position or T as an out-of-window mouse position.- if (m_effective_legacy_mouse_pointer_position == document.hovered_node()) {+ if (m_effective_legacy_mouse_pointer_position == previous_pointer_target) {document.set_hovered_node(target, hover_event_data);} else {- document.set_hovered_node(target, hover_event_data, DOM::Document::BoundaryEventTypes::Pointer);+ document.dispatch_boundary_events(previous_pointer_target, target, hover_event_data, DOM::Document::BoundaryEventTypes::Pointer);document.dispatch_boundary_events(m_effective_legacy_mouse_pointer_position.ptr(), target, hover_event_data, DOM::Document::BoundaryEventTypes::Mouse);}// 4. Set effective legacy mouse pointer position to T.m_effective_legacy_mouse_pointer_position = target;+ m_native_mouse_hover_target = target;report_hovered_node_to_client(target);}@@ -5147,6 +5356,8 @@ void EventHandler::reset_hover_for_document_replacement(Badge<HTML::LocalNavigab// move. So, report it gone now. Another handler's report stands: The pointer rests in that handler's document, and// this document (an iframe the pointer once passed through, e.g.) is going away underneath it.m_effective_legacy_mouse_pointer_position = nullptr;+ m_effective_legacy_mouse_pointer_type = PointerType::Mouse;+ m_native_mouse_hover_target = nullptr;m_wheel_scroll_latch.clear();// A capture in the outgoing document ends with it, with no lostpointercapture event into that document.m_mouse_pointer.pending_capture_target = nullptr;@@ -5292,6 +5503,8 @@ void EventHandler::clear_per_test_input_state(Badge<Internals::Internals>)m_hovered_chrome_widget = nullptr;m_captured_chrome_widget = nullptr;m_effective_legacy_mouse_pointer_position = nullptr;+ m_effective_legacy_mouse_pointer_type = PointerType::Mouse;+ m_native_mouse_hover_target = nullptr;m_drag_and_drop_event_handler->reset();m_mousemove_previous_screen_position.clear();m_wheel_scroll_latch.clear();diff --git a/Libraries/LibWeb/Page/EventHandler.h b/Libraries/LibWeb/Page/EventHandler.hindex c2c5cc162f2..34a497c2487 100644--- a/Libraries/LibWeb/Page/EventHandler.h+++ b/Libraries/LibWeb/Page/EventHandler.h@@ -180,6 +180,8 @@ private:// https://w3c.github.io/pointerevents/#the-pointerdown-event// The PREVENT MOUSE EVENT flag.bool prevent_mouse_event { false };+ // NB: A canceled touch event or a multi-touch gesture suppresses the click as well as the mouse events.+ bool suppress_click { false };unsigned buttons { 0 };unsigned modifiers { 0 };// NB: A pointercancel uses the last dispatched position.@@ -192,12 +194,15 @@ private:// https://w3c.github.io/pointerevents/#dfn-pointer-capture-target-override// NB: Once the element is removed, lostpointercapture targets its document.GC::Weak<DOM::Node> capture_target;+ // NB: The contact's latest Touch, which the touch lists of later touch events include.+ GC::Ptr<UIEvents::Touch> touch;};struct AdditionalPointerState : public RefCounted<AdditionalPointerState> {PointerState state;};GC::Ref<UIEvents::PointerEvent> create_pointer_event(PointerState const&, DOM::Node const&, Utf16FlyString const&, MouseEventCoordinates const&, CSSPixelPoint screen_position, i16 button, CSSPixelPoint movement = {}) const;void update_pointer_hover(Layout::BegunRead const&, PointerState&, GC::Ptr<DOM::Node>, MouseEventCoordinates const&, CSSPixelPoint screen_position);+ bool dispatch_touch_event(PointerState&, DOM::Node&, Utf16FlyString const&, MouseEventCoordinates const&, CSSPixelPoint screen_position);bool has_pointer_capture_in_subtree(i32 pointer_id) const;PointerState const* pointer_state(i32 pointer_id) const;PointerState* pointer_state(i32 pointer_id);@@ -305,6 +310,8 @@ private:RefPtr<Painting::ChromeWidget> m_captured_chrome_widget;GC::Weak<DOM::Node> m_effective_legacy_mouse_pointer_position;+ PointerType m_effective_legacy_mouse_pointer_type { PointerType::Mouse };+ GC::Ptr<DOM::Node> m_native_mouse_hover_target;GC::Weak<DOM::Node> m_last_mousedown_target;GC::Weak<DOM::Node> m_mousedown_target;diff --git a/Libraries/LibWeb/UIEvents/EventNames.h b/Libraries/LibWeb/UIEvents/EventNames.hindex ba800490cde..01cbe99e991 100644--- a/Libraries/LibWeb/UIEvents/EventNames.h+++ b/Libraries/LibWeb/UIEvents/EventNames.h@@ -46,6 +46,10 @@ namespace Web::UIEvents::EventNames {__ENUMERATE_UI_EVENT(pointerup) \__ENUMERATE_UI_EVENT(resize) \__ENUMERATE_UI_EVENT(textInput) \+ __ENUMERATE_UI_EVENT(touchcancel) \+ __ENUMERATE_UI_EVENT(touchend) \+ __ENUMERATE_UI_EVENT(touchmove) \+ __ENUMERATE_UI_EVENT(touchstart) \__ENUMERATE_UI_EVENT(wheel)#define __ENUMERATE_UI_EVENT(name) extern WEB_API Utf16FlyString const& name;diff --git a/Libraries/LibWeb/UIEvents/Touch.cpp b/Libraries/LibWeb/UIEvents/Touch.cppnew file mode 100644index 00000000000..32268dc95a3--- /dev/null+++ b/Libraries/LibWeb/UIEvents/Touch.cpp@@ -0,0 +1,59 @@+/*+ * Copyright (c) 2026-present, the Ladybird developers.+ *+ * SPDX-License-Identifier: BSD-2-Clause+ */++#include <LibGC/Heap.h>+#include <LibWeb/UIEvents/Touch.h>++namespace Web::UIEvents {++GC_DEFINE_ALLOCATOR(Touch);++GC::Ref<Touch> Touch::create(Bindings::TouchInit const& init)+{+ return GC::Heap::the().allocate<Touch>(init);+}++// https://w3c.github.io/touch-events/#touch-interface+// Touch objects are immutable; after one is created, its attributes must not change.+Touch::Touch(Bindings::TouchInit const& init)+ : m_target(init.target)+ , m_identifier(init.identifier)+ , m_screen_x(init.screen_x)+ , m_screen_y(init.screen_y)+ , m_client_x(init.client_x)+ , m_client_y(init.client_y)+ , m_page_x(init.page_x)+ , m_page_y(init.page_y)+ , m_radius_x(init.radius_x)+ , m_radius_y(init.radius_y)+ , m_rotation_angle(init.rotation_angle)+ , m_force(init.force)+{+}++GC::Ref<Touch> Touch::clone_with_target(GC::Ref<DOM::EventTarget> target) const+{+ Bindings::TouchInit init { .identifier = m_identifier, .target = target };+ init.client_x = m_client_x;+ init.client_y = m_client_y;+ init.screen_x = m_screen_x;+ init.screen_y = m_screen_y;+ init.page_x = m_page_x;+ init.page_y = m_page_y;+ init.radius_x = m_radius_x;+ init.radius_y = m_radius_y;+ init.rotation_angle = m_rotation_angle;+ init.force = m_force;+ return create(init);+}++void Touch::visit_edges(GC::Cell::Visitor& visitor)+{+ Base::visit_edges(visitor);+ visitor.visit(m_target);+}++}diff --git a/Libraries/LibWeb/UIEvents/Touch.h b/Libraries/LibWeb/UIEvents/Touch.hnew file mode 100644index 00000000000..7aab274e76f--- /dev/null+++ b/Libraries/LibWeb/UIEvents/Touch.h@@ -0,0 +1,53 @@+/*+ * Copyright (c) 2026-present, the Ladybird developers.+ *+ * SPDX-License-Identifier: BSD-2-Clause+ */++#pragma once++#include <LibWeb/Bindings/Touch.h>+#include <LibWeb/Bindings/Wrappable.h>+#include <LibWeb/DOM/EventTarget.h>++namespace Web::UIEvents {++class Touch final : public Bindings::GCAllocatedWrappable {+ WEB_WRAPPABLE(Touch, Bindings::GCAllocatedWrappable);+ GC_DECLARE_ALLOCATOR(Touch);++public:+ static GC::Ref<Touch> create(Bindings::TouchInit const&);+ GC::Ref<Touch> clone_with_target(GC::Ref<DOM::EventTarget>) const;+ GC::Ref<DOM::EventTarget> target() const { return m_target; }+ i32 identifier() const { return m_identifier; }+ double screen_x() const { return m_screen_x; }+ double screen_y() const { return m_screen_y; }+ double client_x() const { return m_client_x; }+ double client_y() const { return m_client_y; }+ double page_x() const { return m_page_x; }+ double page_y() const { return m_page_y; }+ float radius_x() const { return m_radius_x; }+ float radius_y() const { return m_radius_y; }+ float rotation_angle() const { return m_rotation_angle; }+ float force() const { return m_force; }++private:+ explicit Touch(Bindings::TouchInit const&);+ virtual void visit_edges(GC::Cell::Visitor&) override;++ GC::Ref<DOM::EventTarget> m_target;+ i32 m_identifier;+ double m_screen_x;+ double m_screen_y;+ double m_client_x;+ double m_client_y;+ double m_page_x;+ double m_page_y;+ float m_radius_x;+ float m_radius_y;+ float m_rotation_angle;+ float m_force;+};++}diff --git a/Libraries/LibWeb/UIEvents/Touch.idl b/Libraries/LibWeb/UIEvents/Touch.idlnew file mode 100644index 00000000000..94dbc2c3258--- /dev/null+++ b/Libraries/LibWeb/UIEvents/Touch.idl@@ -0,0 +1,34 @@+// https://w3c.github.io/touch-events/#touch-interface+[Exposed=Window]+interface Touch {+ constructor(TouchInit touchInitDict);+ readonly attribute long identifier;+ readonly attribute EventTarget target;+ readonly attribute double screenX;+ readonly attribute double screenY;+ readonly attribute double clientX;+ readonly attribute double clientY;+ readonly attribute double pageX;+ readonly attribute double pageY;+ readonly attribute float radiusX;+ readonly attribute float radiusY;+ readonly attribute float rotationAngle;+ readonly attribute float force;+};++dictionary TouchInit {+ required long identifier;+ required EventTarget target;+ double clientX = 0;+ double clientY = 0;+ double screenX = 0;+ double screenY = 0;+ double pageX = 0;+ double pageY = 0;+ float radiusX = 0;+ float radiusY = 0;+ float rotationAngle = 0;+ float force = 0;+};++// INTEROP: Blink and Gecko omit the draft altitudeAngle, azimuthAngle and touchType attributes.diff --git a/Libraries/LibWeb/UIEvents/TouchEvent.cpp b/Libraries/LibWeb/UIEvents/TouchEvent.cppnew file mode 100644index 00000000000..3ee5617fcee--- /dev/null+++ b/Libraries/LibWeb/UIEvents/TouchEvent.cpp@@ -0,0 +1,96 @@+/*+ * Copyright (c) 2026-present, the Ladybird developers.+ *+ * SPDX-License-Identifier: BSD-2-Clause+ */++#include <LibGC/ConservativeHashMap.h>+#include <LibGC/ConservativeVector.h>+#include <LibGC/Heap.h>+#include <LibGC/RootVector.h>+#include <LibWeb/UIEvents/TouchEvent.h>++namespace Web::UIEvents {++GC_DEFINE_ALLOCATOR(TouchEvent);++GC::Ref<TouchEvent> TouchEvent::create(Utf16String const& type, Bindings::TouchEventInit const& init, HighResolutionTime::DOMHighResTimeStamp time_stamp)+{+ return GC::Heap::the().allocate<TouchEvent>(Utf16FlyString::from_utf16(type.utf16_view()), init, time_stamp);+}++GC::Ref<TouchEvent> TouchEvent::create(FlyString const& type, Bindings::TouchEventInit const& init, HighResolutionTime::DOMHighResTimeStamp time_stamp)+{+ return GC::Heap::the().allocate<TouchEvent>(Utf16FlyString::from_utf8(type.to_string()), init, time_stamp);+}++TouchEvent::TouchEvent(Utf16FlyString const& type, Bindings::TouchEventInit const& init, HighResolutionTime::DOMHighResTimeStamp time_stamp)+ : UIEvent(type, init, time_stamp)+ , m_touches(TouchList::create(init.touches))+ , m_target_touches(TouchList::create(init.target_touches))+ , m_changed_touches(TouchList::create(init.changed_touches))+ , m_original_touches(m_touches)+ , m_original_target_touches(m_target_touches)+ , m_original_changed_touches(m_changed_touches)+ , m_alt_key(init.alt_key)+ , m_meta_key(init.meta_key)+ , m_ctrl_key(init.ctrl_key)+ , m_shift_key(init.shift_key)+{+ for (auto list : { m_touches, m_target_touches, m_changed_touches }) {+ for (u32 index = 0; index < list->length(); ++index)+ touch_target_list().append(list->item(index)->target());+ }+ m_last_touch_targets = touch_target_list();+}++// https://dom.spec.whatwg.org/#concept-event-dispatch+// NB: Each event path entry has retargeted touch targets. Clone changed Touch objects so that snapshots retained by+// another listener remain immutable, and reuse each clone across the three lists.+void TouchEvent::retarget_touch_lists()+{+ auto const& targets = touch_target_list();+ if (targets == m_last_touch_targets)+ return;+ m_last_touch_targets = targets;+ GC::ConservativeHashMap<Touch*, GC::Ref<Touch>> clones;+ GC::RootVector<GC::Ref<Touch>> cloned_touches;+ size_t offset = 0;+ auto retarget = [&](GC::Ref<TouchList> original) {+ GC::ConservativeVector<GC::Ref<Touch>> touches;+ bool changed = false;+ for (u32 index = 0; index < original->length(); ++index) {+ auto touch = original->item(index);+ auto target = targets[offset++];+ if (target == touch->target()) {+ touches.append(*touch);+ continue;+ }+ changed = true;+ auto clone = clones.ensure(touch.ptr(), [&] {+ auto clone = touch->clone_with_target(*target);+ cloned_touches.append(clone);+ return clone;+ });+ touches.append(clone);+ }+ return changed ? TouchList::create(move(touches)) : original;+ };+ m_touches = retarget(m_original_touches);+ m_target_touches = retarget(m_original_target_touches);+ m_changed_touches = retarget(m_original_changed_touches);+}++void TouchEvent::visit_edges(GC::Cell::Visitor& visitor)+{+ Base::visit_edges(visitor);+ visitor.visit(m_touches);+ visitor.visit(m_target_touches);+ visitor.visit(m_changed_touches);+ visitor.visit(m_original_touches);+ visitor.visit(m_original_target_touches);+ visitor.visit(m_original_changed_touches);+ visitor.visit(m_last_touch_targets);+}++}diff --git a/Libraries/LibWeb/UIEvents/TouchEvent.h b/Libraries/LibWeb/UIEvents/TouchEvent.hnew file mode 100644index 00000000000..d57465969aa--- /dev/null+++ b/Libraries/LibWeb/UIEvents/TouchEvent.h@@ -0,0 +1,48 @@+/*+ * Copyright (c) 2026-present, the Ladybird developers.+ *+ * SPDX-License-Identifier: BSD-2-Clause+ */++#pragma once++#include <LibWeb/Bindings/TouchEvent.h>+#include <LibWeb/UIEvents/TouchList.h>+#include <LibWeb/UIEvents/UIEvent.h>++namespace Web::UIEvents {++class TouchEvent final : public UIEvent {+ WEB_WRAPPABLE(TouchEvent, UIEvent);+ GC_DECLARE_ALLOCATOR(TouchEvent);++public:+ static GC::Ref<TouchEvent> create(Utf16String const&, Bindings::TouchEventInit const&, HighResolutionTime::DOMHighResTimeStamp);+ static GC::Ref<TouchEvent> create(FlyString const&, Bindings::TouchEventInit const&, HighResolutionTime::DOMHighResTimeStamp);+ void retarget_touch_lists();+ GC::Ref<TouchList> touches() const { return m_touches; }+ GC::Ref<TouchList> target_touches() const { return m_target_touches; }+ GC::Ref<TouchList> changed_touches() const { return m_changed_touches; }+ bool alt_key() const { return m_alt_key; }+ bool meta_key() const { return m_meta_key; }+ bool ctrl_key() const { return m_ctrl_key; }+ bool shift_key() const { return m_shift_key; }++private:+ TouchEvent(Utf16FlyString const&, Bindings::TouchEventInit const&, HighResolutionTime::DOMHighResTimeStamp);+ virtual void visit_edges(GC::Cell::Visitor&) override;++ GC::Ref<TouchList> m_touches;+ GC::Ref<TouchList> m_target_touches;+ GC::Ref<TouchList> m_changed_touches;+ GC::Ref<TouchList> m_original_touches;+ GC::Ref<TouchList> m_original_target_touches;+ GC::Ref<TouchList> m_original_changed_touches;+ TouchTargetList m_last_touch_targets;+ bool m_alt_key { false };+ bool m_meta_key { false };+ bool m_ctrl_key { false };+ bool m_shift_key { false };+};++}diff --git a/Libraries/LibWeb/UIEvents/TouchEvent.idl b/Libraries/LibWeb/UIEvents/TouchEvent.idlnew file mode 100644index 00000000000..1b1b8a1b2e7--- /dev/null+++ b/Libraries/LibWeb/UIEvents/TouchEvent.idl@@ -0,0 +1,22 @@+// https://w3c.github.io/touch-events/#touchevent-interface+[Exposed=Window]+interface TouchEvent : UIEvent {+ constructor(DOMString type, optional TouchEventInit eventInitDict = {});+ readonly attribute TouchList touches;+ readonly attribute TouchList targetTouches;+ readonly attribute TouchList changedTouches;+ readonly attribute boolean altKey;+ readonly attribute boolean metaKey;+ readonly attribute boolean ctrlKey;+ readonly attribute boolean shiftKey;+};++dictionary TouchEventInit : EventModifierInit {+ sequence<Touch> touches = [];+ sequence<Touch> targetTouches = [];+ sequence<Touch> changedTouches = [];+};++// INTEROP: Expose the interfaces on desktop, as Blink does, while leaving ontouch* handler attributes absent without+// a touch screen. Exposing those attributes would incorrectly make feature detection report touch hardware.+// INTEROP: Blink and Gecko do not implement the draft getModifierState method.diff --git a/Libraries/LibWeb/UIEvents/TouchList.cpp b/Libraries/LibWeb/UIEvents/TouchList.cppnew file mode 100644index 00000000000..68ee49b5173--- /dev/null+++ b/Libraries/LibWeb/UIEvents/TouchList.cpp@@ -0,0 +1,30 @@+/*+ * Copyright (c) 2026-present, the Ladybird developers.+ *+ * SPDX-License-Identifier: BSD-2-Clause+ */++#include <LibGC/Heap.h>+#include <LibWeb/UIEvents/TouchList.h>++namespace Web::UIEvents {++GC_DEFINE_ALLOCATOR(TouchList);++GC::Ref<TouchList> TouchList::create(GC::ConservativeVector<GC::Ref<Touch>> touches)+{+ return GC::Heap::the().allocate<TouchList>(move(touches));+}++TouchList::TouchList(GC::ConservativeVector<GC::Ref<Touch>> touches)+ : m_touches(move(touches))+{+}++void TouchList::visit_edges(GC::Cell::Visitor& visitor)+{+ Base::visit_edges(visitor);+ visitor.visit(m_touches);+}++}diff --git a/Libraries/LibWeb/UIEvents/TouchList.h b/Libraries/LibWeb/UIEvents/TouchList.hnew file mode 100644index 00000000000..cb03e5c9cde--- /dev/null+++ b/Libraries/LibWeb/UIEvents/TouchList.h@@ -0,0 +1,31 @@+/*+ * Copyright (c) 2026-present, the Ladybird developers.+ *+ * SPDX-License-Identifier: BSD-2-Clause+ */++#pragma once++#include <LibGC/ConservativeVector.h>+#include <LibWeb/Bindings/Wrappable.h>+#include <LibWeb/UIEvents/Touch.h>++namespace Web::UIEvents {++class TouchList final : public Bindings::GCAllocatedWrappable {+ WEB_WRAPPABLE(TouchList, Bindings::GCAllocatedWrappable);+ GC_DECLARE_ALLOCATOR(TouchList);++public:+ static GC::Ref<TouchList> create(GC::ConservativeVector<GC::Ref<Touch>>);+ u32 length() const { return m_touches.size(); }+ GC::Ptr<Touch> item(u32 index) const { return index < m_touches.size() ? m_touches[index].ptr() : nullptr; }++private:+ explicit TouchList(GC::ConservativeVector<GC::Ref<Touch>>);+ virtual void visit_edges(GC::Cell::Visitor&) override;++ Vector<GC::Ref<Touch>> m_touches;+};++}diff --git a/Libraries/LibWeb/UIEvents/TouchList.idl b/Libraries/LibWeb/UIEvents/TouchList.idlnew file mode 100644index 00000000000..f8a4c237b6a--- /dev/null+++ b/Libraries/LibWeb/UIEvents/TouchList.idl@@ -0,0 +1,6 @@+// https://w3c.github.io/touch-events/#touchlist-interface+[Exposed=Window]+interface TouchList {+ readonly attribute unsigned long length;+ getter Touch? item(unsigned long index);+};diff --git a/Libraries/LibWeb/idl_files.cmake b/Libraries/LibWeb/idl_files.cmakeindex 0998c303f47..99fec2dabbf 100644--- a/Libraries/LibWeb/idl_files.cmake+++ b/Libraries/LibWeb/idl_files.cmake@@ -611,6 +611,9 @@ libweb_js_bindings(UIEvents/MouseEvent)libweb_js_bindings(UIEvents/PointerEvent)libweb_js_bindings(UIEvents/PointerEventHandlers)libweb_js_bindings(UIEvents/TextEvent)+libweb_js_bindings(UIEvents/Touch)+libweb_js_bindings(UIEvents/TouchEvent)+libweb_js_bindings(UIEvents/TouchList)libweb_js_bindings(UIEvents/UIEvent)libweb_js_bindings(UIEvents/WheelEvent)libweb_js_bindings(URLPattern/URLPattern)diff --git a/Tests/LibWeb/Text/expected/UIEvents/pen-primary-on-reentry.txt b/Tests/LibWeb/Text/expected/UIEvents/pen-primary-on-reentry.txtnew file mode 100644index 00000000000..c63da5602d0--- /dev/null+++ b/Tests/LibWeb/Text/expected/UIEvents/pen-primary-on-reentry.txt@@ -0,0 +1,3 @@+pen 30: primary=true+pen 31: primary=false+pen 31: primary=truediff --git a/Tests/LibWeb/Text/expected/UIEvents/pointer-leaves-local-iframe.txt b/Tests/LibWeb/Text/expected/UIEvents/pointer-leaves-local-iframe.txtindex b3dbd4be753..08bbee1e38e 100644--- a/Tests/LibWeb/Text/expected/UIEvents/pointer-leaves-local-iframe.txt+++ b/Tests/LibWeb/Text/expected/UIEvents/pointer-leaves-local-iframe.txt@@ -2,7 +2,8 @@ pointerout: 145,25pointerleave: 145,25touch pointerdown: primary=truetouchstart: touches=1-touchcancel: touches=0, changed=1+touchend: touches=0, changed=1touch pointerdown: primary=truetouchstart: touches=1+touchend: touches=0, changed=1click: touchdiff --git a/Tests/LibWeb/Text/expected/UIEvents/touch-compatibility-target-during-capture.txt b/Tests/LibWeb/Text/expected/UIEvents/touch-compatibility-target-during-capture.txtnew file mode 100644index 00000000000..ff8007b23f0--- /dev/null+++ b/Tests/LibWeb/Text/expected/UIEvents/touch-compatibility-target-during-capture.txt@@ -0,0 +1,15 @@+pointerdown: child+touchstart: child+pointerup: parent+touchend: child+mousedown: child+mouseup: child+click: parent+pointerdown: child+touchstart: child+pointerup: parent+touchend: child+mousedown: child+mouseup: child+click: parent+after replacement: child=false, parent=truediff --git a/Tests/LibWeb/Text/expected/UIEvents/touch-event-delivery.txt b/Tests/LibWeb/Text/expected/UIEvents/touch-event-delivery.txtnew file mode 100644index 00000000000..26785d1ed25--- /dev/null+++ b/Tests/LibWeb/Text/expected/UIEvents/touch-event-delivery.txt@@ -0,0 +1,30 @@+interfaces: function, function, function+desktop handlers: false, false, false+legacy event factory: NotSupportedError+touchstart@a: touches=1, target=1, changed=1, trusted=true, composed=true+ original target=a, x=20, force=0.75, radius=6,9, control=true+touchmove@a: touches=1, target=1, changed=1, trusted=true, composed=true+ original target=a, x=180, force=0.5, radius=0.5,0.5, control=true+touchend@a: touches=0, target=0, changed=1, trusted=true, composed=true+ original target=a, x=180, force=0, radius=0.5,0.5, control=true+saved snapshot: length=1, x=20, force=0.75, identity=true+list bounds: null, undefined+mouse events after canceled touchstart: 0+touchstart@a: touches=1, target=1, changed=1, trusted=true, composed=true+ original target=a, x=20, force=0.5, radius=0.5,0.5, control=false+touchstart@b: touches=2, target=1, changed=1, trusted=true, composed=true+ original target=b, x=180, force=0.5, radius=0.5,0.5, control=false+touchmove@a: touches=2, target=1, changed=1, trusted=true, composed=true+ original target=a, x=30, force=0.5, radius=0.5,0.5, control=false+touchmove@b: touches=2, target=1, changed=1, trusted=true, composed=true+ original target=b, x=190, force=0.5, radius=0.5,0.5, control=false+touchcancel@a: touches=1, target=0, changed=1, trusted=true, composed=true+ original target=a, x=30, force=0.5, radius=0.5,0.5, control=false+touchend@b: touches=0, target=0, changed=1, trusted=true, composed=true+ original target=b, x=190, force=0, radius=0.5,0.5, control=false+mouse events after canceled contact: 0+touchstart@b: touches=1, target=1, changed=1, trusted=true, composed=true+ original target=b, x=180, force=0.5, radius=0.5,0.5, control=false+touchend@b: touches=0, target=0, changed=1, trusted=true, composed=true+ original target=b, x=180, force=0, radius=0.5,0.5, control=false+mouse events after canceled touchend: 0diff --git a/Tests/LibWeb/Text/expected/UIEvents/touch-legacy-hover.txt b/Tests/LibWeb/Text/expected/UIEvents/touch-legacy-hover.txtnew file mode 100644index 00000000000..e478b614aed--- /dev/null+++ b/Tests/LibWeb/Text/expected/UIEvents/touch-legacy-hover.txt@@ -0,0 +1,14 @@+mouseover: hover=true, color=rgb(0, 255, 0)+mousemove: hover=true, color=rgb(0, 255, 0)+mousedown: hover=true, color=rgb(0, 255, 0)+mouseup: hover=true, color=rgb(0, 255, 0)+click: hover=true, color=rgb(0, 255, 0)+sticky hover: true, color=rgb(0, 255, 0)+mouse after touch: hover=true, native boundaries=0+multi-touch clicks: 0+mouseover: hover=true, color=rgb(0, 255, 0)+mousemove: hover=true, color=rgb(0, 255, 0)+mousedown: hover=true, color=rgb(0, 255, 0)+mouseup: hover=true, color=rgb(0, 255, 0)+click: hover=true, color=rgb(0, 255, 0)+after replacement: child=false, parent=true, color=rgb(0, 0, 255)diff --git a/Tests/LibWeb/Text/expected/UIEvents/touch-origin-across-local-frames.txt b/Tests/LibWeb/Text/expected/UIEvents/touch-origin-across-local-frames.txtnew file mode 100644index 00000000000..3bd47bb8183--- /dev/null+++ b/Tests/LibWeb/Text/expected/UIEvents/touch-origin-across-local-frames.txt@@ -0,0 +1,9 @@+parent to child: parent:touchstart@parent/parent:205,55:1; parent:touchmove@parent/parent:65,55:1; parent:touchend@parent/parent:65,55:0+child to parent: child:touchstart@child/child:25,25:1; child:touchmove@child/child:165,25:1; child:touchend@child/child:165,25:0+child to sibling: child:touchstart@child/child:25,25:1; child:touchmove@child/child:305,25:1; child:touchend@child/child:305,25:0+same document: parent:touchstart@parent/parent:205,55:1; parent:touchmove@parent/parent:205,175:1; parent:touchend@parent/parent:205,175:0+released Pointer targets: pointermove@other; pointerup@other+hidden child: child:touchstart@child/child:25,25:1; child:touchcancel@child/child:25,25:0+removed child: child:touchstart@child/child:25,25:1+next contact: primary=true, parent:touchstart@parent/parent:205,55:1; parent:touchend@parent/parent:205,55:0+compatibility mouse events: 0diff --git a/Tests/LibWeb/Text/expected/UIEvents/touch-target-retained-across-gc.txt b/Tests/LibWeb/Text/expected/UIEvents/touch-target-retained-across-gc.txtnew file mode 100644index 00000000000..29742426ba7--- /dev/null+++ b/Tests/LibWeb/Text/expected/UIEvents/touch-target-retained-across-gc.txt@@ -0,0 +1,3 @@+touchstart: target=target, connected=true, touches=1+touchmove: target=target, connected=false, touches=1+touchend: target=target, connected=false, touches=0diff --git a/Tests/LibWeb/Text/expected/UIEvents/touch-target-retargeting.txt b/Tests/LibWeb/Text/expected/UIEvents/touch-target-retargeting.txtnew file mode 100644index 00000000000..7dd1c0dcc5e--- /dev/null+++ b/Tests/LibWeb/Text/expected/UIEvents/touch-target-retargeting.txt@@ -0,0 +1,4 @@+inside: true, true+outside: true, true, 12.5+saved inside snapshot: true+original: truediff --git a/Tests/LibWeb/Text/expected/UIEvents/webdriver-touch-and-pen-actions.txt b/Tests/LibWeb/Text/expected/UIEvents/webdriver-touch-and-pen-actions.txtindex c65d23c05cb..5da8bc31aa0 100644--- a/Tests/LibWeb/Text/expected/UIEvents/webdriver-touch-and-pen-actions.txt+++ b/Tests/LibWeb/Text/expected/UIEvents/webdriver-touch-and-pen-actions.txt@@ -1,5 +1,4 @@pointerdown:a:touch:true-mousedown:a:mouse:-pointerdown:b:touch:falsegotpointercapture:a:touch:truepointermove:a:touch:true@@ -7,8 +6,6 @@ gotpointercapture:b:touch:falsepointermove:b:touch:falsepointerup:a:touch:truelostpointercapture:a:touch:true-mouseup:a:mouse:--click:a:touch:truepointerup:b:touch:falselostpointercapture:b:touch:falseproperties:12,18,0.75,0.25,30,-20,90,0.5,1.25diff --git a/Tests/LibWeb/Text/expected/all-window-properties.txt b/Tests/LibWeb/Text/expected/all-window-properties.txtindex e312a12e47d..1cd0c5da28e 100644--- a/Tests/LibWeb/Text/expected/all-window-properties.txt+++ b/Tests/LibWeb/Text/expected/all-window-properties.txt@@ -557,6 +557,9 @@ TextTrackCueListTextTrackListTimeRangesToggleEvent+Touch+TouchEvent+TouchListTrackEventTransformStreamTransformStreamDefaultControllerdiff --git a/Tests/LibWeb/Text/expected/wpt-import/touch-events/multi-touch-interactions.txt b/Tests/LibWeb/Text/expected/wpt-import/touch-events/multi-touch-interactions.txtnew file mode 100644index 00000000000..94e3de94480--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/touch-events/multi-touch-interactions.txt@@ -0,0 +1,78 @@+Harness status: OK++Found 73 tests++73 Pass+Pass touchstart event received+Pass touchmove event received+Pass touchend event received+Pass Interaction with mouse events+Pass touchstart #1: changedTouches is a subset of touches+Pass touchstart #1: targetTouches is a subset of touches+Pass touchstart #1: targets of targetTouches are correct+Pass touchstart #1: touches.length is valid+Pass touchstart #1: targetTouches is a subset of changedTouches+Pass touchstart #1: touches and changedTouches have the same length+Pass touchstart #2: changedTouches is a subset of touches+Pass touchstart #2: targetTouches is a subset of touches+Pass touchstart #2: targets of targetTouches are correct+Pass touchstart #2: touches.length is valid+Pass touchstart #2: change in targetTouches.length is valid+Pass touchstart #2: at least one targetTouches item in changedTouches+Pass touchstart #2: change in touches.length is valid+Pass touchstart #2: touches is subset of {changedTouches, last received touches}+Pass touchmove #1: changedTouches is a subset of touches+Pass touchmove #1: targetTouches is a subset of touches+Pass touchmove #1: at least one targetTouches item in changedTouches+Pass touchmove #1: targets of targetTouches are correct+Pass touchmove #1: touches must be same as last received touches+Pass touchmove #2: changedTouches is a subset of touches+Pass touchmove #2: targetTouches is a subset of touches+Pass touchmove #2: at least one targetTouches item in changedTouches+Pass touchmove #2: targets of targetTouches are correct+Pass touchmove #2: touches must be same as last received touches+Pass touchmove #3: changedTouches is a subset of touches+Pass touchmove #3: targetTouches is a subset of touches+Pass touchmove #3: at least one targetTouches item in changedTouches+Pass touchmove #3: targets of targetTouches are correct+Pass touchmove #3: touches must be same as last received touches+Pass touchmove #4: changedTouches is a subset of touches+Pass touchmove #4: targetTouches is a subset of touches+Pass touchmove #4: at least one targetTouches item in changedTouches+Pass touchmove #4: targets of targetTouches are correct+Pass touchmove #4: touches must be same as last received touches+Pass touchend #1: length of changedTouches is valid+Pass touchend #1: changedTouches is a subset of last received touches+Pass touchend #1: no item in changedTouches are in touches or targetTouches+Pass touchend #1: at least one item in changedTouches targeted at this element+Pass touchend #1: targetTouches is a subset of touches+Pass touchend #1: targets of targetTouches are correct+Pass touchend #1: change in targetTouches.length is valid+Pass touchend #1: change in touches.length is valid+Pass touchend #1: event dispatched to correct element<br>+Pass touchend #2: length of changedTouches is valid+Pass touchend #2: changedTouches is a subset of last received touches+Pass touchend #2: no item in changedTouches are in touches or targetTouches+Pass touchend #2: at least one item in changedTouches targeted at this element+Pass touchend #2: targetTouches is a subset of touches+Pass touchend #2: targets of targetTouches are correct+Pass touchend #2: change in targetTouches.length is valid+Pass touchend #2: change in touches.length is valid+Pass touchend #2: event dispatched to correct element<br>+Pass touchstart #3: changedTouches is a subset of touches+Pass touchstart #3: targetTouches is a subset of touches+Pass touchstart #3: targets of targetTouches are correct+Pass touchstart #3: touches.length is valid+Pass touchstart #3: change in targetTouches.length is valid+Pass touchstart #3: at least one targetTouches item in changedTouches+Pass touchstart #3: change in touches.length is valid+Pass touchstart #3: touches is subset of {changedTouches, last received touches}+Pass touchend #3: length of changedTouches is valid+Pass touchend #3: changedTouches is a subset of last received touches+Pass touchend #3: no item in changedTouches are in touches or targetTouches+Pass touchend #3: at least one item in changedTouches targeted at this element+Pass touchend #3: targetTouches is a subset of touches+Pass touchend #3: targets of targetTouches are correct+Pass touchend #3: change in targetTouches.length is valid+Pass touchend #3: change in touches.length is valid+Pass touchend #3: event dispatched to correct element<br>\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/touch-events/multi-touch-interfaces.txt b/Tests/LibWeb/Text/expected/wpt-import/touch-events/multi-touch-interfaces.txtnew file mode 100644index 00000000000..ef40090a1ea--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/touch-events/multi-touch-interfaces.txt@@ -0,0 +1,516 @@+Harness status: OK++Found 511 tests++511 Pass+Pass touchstart event received+Pass touchmove event received+Pass touchend event received+Pass Interaction with mouse events+Pass touchstart1 event is a TouchEvent event+Pass touchstart1.touches attribute exists+Pass touchstart1.touches attribute is of type TouchList+Pass touchstart1.touches's touch list is a TouchList object+Pass touchstart1.touches.TouchList.length attribute exists+Pass touchstart1.touches.TouchList.length attribute is of type number (unsigned long)+Pass touchstart1.touches.TouchList.item attribute exists+Pass touchstart1.touches.TouchList.item attribute is of type function+Pass touchstart1.touches[0]'s touch point is a Touch object+Pass touchstart1.touches[0].Touch.identifier attribute exists+Pass touchstart1.touches[0].Touch.identifier attribute is of type number (long)+Pass touchstart1.touches[0].Touch.target attribute exists+Pass touchstart1.touches[0].Touch.target attribute is of type Element+Pass touchstart1.touches[0].Touch.screenX attribute exists+Pass touchstart1.touches[0].Touch.screenX attribute is of type number (long)+Pass touchstart1.touches[0].Touch.screenY attribute exists+Pass touchstart1.touches[0].Touch.screenY attribute is of type number (long)+Pass touchstart1.touches[0].Touch.clientX attribute exists+Pass touchstart1.touches[0].Touch.clientX attribute is of type number (long)+Pass touchstart1.touches[0].Touch.clientY attribute exists+Pass touchstart1.touches[0].Touch.clientY attribute is of type number (long)+Pass touchstart1.touches[0].Touch.pageX attribute exists+Pass touchstart1.touches[0].Touch.pageX attribute is of type number (long)+Pass touchstart1.touches[0].Touch.pageY attribute exists+Pass touchstart1.touches[0].Touch.pageY attribute is of type number (long)+Pass touchstart1.targetTouches attribute exists+Pass touchstart1.targetTouches attribute is of type TouchList+Pass touchstart1.targetTouches's touch list is a TouchList object+Pass touchstart1.targetTouches.TouchList.length attribute exists+Pass touchstart1.targetTouches.TouchList.length attribute is of type number (unsigned long)+Pass touchstart1.targetTouches.TouchList.item attribute exists+Pass touchstart1.targetTouches.TouchList.item attribute is of type function+Pass touchstart1.targetTouches[0]'s touch point is a Touch object+Pass touchstart1.targetTouches[0].Touch.identifier attribute exists+Pass touchstart1.targetTouches[0].Touch.identifier attribute is of type number (long)+Pass touchstart1.targetTouches[0].Touch.target attribute exists+Pass touchstart1.targetTouches[0].Touch.target attribute is of type Element+Pass touchstart1.targetTouches[0].Touch.screenX attribute exists+Pass touchstart1.targetTouches[0].Touch.screenX attribute is of type number (long)+Pass touchstart1.targetTouches[0].Touch.screenY attribute exists+Pass touchstart1.targetTouches[0].Touch.screenY attribute is of type number (long)+Pass touchstart1.targetTouches[0].Touch.clientX attribute exists+Pass touchstart1.targetTouches[0].Touch.clientX attribute is of type number (long)+Pass touchstart1.targetTouches[0].Touch.clientY attribute exists+Pass touchstart1.targetTouches[0].Touch.clientY attribute is of type number (long)+Pass touchstart1.targetTouches[0].Touch.pageX attribute exists+Pass touchstart1.targetTouches[0].Touch.pageX attribute is of type number (long)+Pass touchstart1.targetTouches[0].Touch.pageY attribute exists+Pass touchstart1.targetTouches[0].Touch.pageY attribute is of type number (long)+Pass touchstart1.changedTouches attribute exists+Pass touchstart1.changedTouches attribute is of type TouchList+Pass touchstart1.changedTouches's touch list is a TouchList object+Pass touchstart1.changedTouches.TouchList.length attribute exists+Pass touchstart1.changedTouches.TouchList.length attribute is of type number (unsigned long)+Pass touchstart1.changedTouches.TouchList.item attribute exists+Pass touchstart1.changedTouches.TouchList.item attribute is of type function+Pass touchstart1.changedTouches[0]'s touch point is a Touch object+Pass touchstart1.changedTouches[0].Touch.identifier attribute exists+Pass touchstart1.changedTouches[0].Touch.identifier attribute is of type number (long)+Pass touchstart1.changedTouches[0].Touch.target attribute exists+Pass touchstart1.changedTouches[0].Touch.target attribute is of type Element+Pass touchstart1.changedTouches[0].Touch.screenX attribute exists+Pass touchstart1.changedTouches[0].Touch.screenX attribute is of type number (long)+Pass touchstart1.changedTouches[0].Touch.screenY attribute exists+Pass touchstart1.changedTouches[0].Touch.screenY attribute is of type number (long)+Pass touchstart1.changedTouches[0].Touch.clientX attribute exists+Pass touchstart1.changedTouches[0].Touch.clientX attribute is of type number (long)+Pass touchstart1.changedTouches[0].Touch.clientY attribute exists+Pass touchstart1.changedTouches[0].Touch.clientY attribute is of type number (long)+Pass touchstart1.changedTouches[0].Touch.pageX attribute exists+Pass touchstart1.changedTouches[0].Touch.pageX attribute is of type number (long)+Pass touchstart1.changedTouches[0].Touch.pageY attribute exists+Pass touchstart1.changedTouches[0].Touch.pageY attribute is of type number (long)+Pass touchstart1.altKey attribute exists+Pass touchstart1.altKey attribute is of type boolean+Pass touchstart1.metaKey attribute exists+Pass touchstart1.metaKey attribute is of type boolean+Pass touchstart1.ctrlKey attribute exists+Pass touchstart1.ctrlKey attribute is of type boolean+Pass touchstart1.shiftKey attribute exists+Pass touchstart1.shiftKey attribute is of type boolean+Pass touchstart2 event is a TouchEvent event+Pass touchstart2.touches attribute exists+Pass touchstart2.touches attribute is of type TouchList+Pass touchstart2.touches's touch list is a TouchList object+Pass touchstart2.touches.TouchList.length attribute exists+Pass touchstart2.touches.TouchList.length attribute is of type number (unsigned long)+Pass touchstart2.touches.TouchList.item attribute exists+Pass touchstart2.touches.TouchList.item attribute is of type function+Pass touchstart2.touches[0]'s touch point is a Touch object+Pass touchstart2.touches[0].Touch.identifier attribute exists+Pass touchstart2.touches[0].Touch.identifier attribute is of type number (long)+Pass touchstart2.touches[0].Touch.target attribute exists+Pass touchstart2.touches[0].Touch.target attribute is of type Element+Pass touchstart2.touches[0].Touch.screenX attribute exists+Pass touchstart2.touches[0].Touch.screenX attribute is of type number (long)+Pass touchstart2.touches[0].Touch.screenY attribute exists+Pass touchstart2.touches[0].Touch.screenY attribute is of type number (long)+Pass touchstart2.touches[0].Touch.clientX attribute exists+Pass touchstart2.touches[0].Touch.clientX attribute is of type number (long)+Pass touchstart2.touches[0].Touch.clientY attribute exists+Pass touchstart2.touches[0].Touch.clientY attribute is of type number (long)+Pass touchstart2.touches[0].Touch.pageX attribute exists+Pass touchstart2.touches[0].Touch.pageX attribute is of type number (long)+Pass touchstart2.touches[0].Touch.pageY attribute exists+Pass touchstart2.touches[0].Touch.pageY attribute is of type number (long)+Pass touchstart2.touches[1]'s touch point is a Touch object+Pass touchstart2.touches[1].Touch.identifier attribute exists+Pass touchstart2.touches[1].Touch.identifier attribute is of type number (long)+Pass touchstart2.touches[1].Touch.target attribute exists+Pass touchstart2.touches[1].Touch.target attribute is of type Element+Pass touchstart2.touches[1].Touch.screenX attribute exists+Pass touchstart2.touches[1].Touch.screenX attribute is of type number (long)+Pass touchstart2.touches[1].Touch.screenY attribute exists+Pass touchstart2.touches[1].Touch.screenY attribute is of type number (long)+Pass touchstart2.touches[1].Touch.clientX attribute exists+Pass touchstart2.touches[1].Touch.clientX attribute is of type number (long)+Pass touchstart2.touches[1].Touch.clientY attribute exists+Pass touchstart2.touches[1].Touch.clientY attribute is of type number (long)+Pass touchstart2.touches[1].Touch.pageX attribute exists+Pass touchstart2.touches[1].Touch.pageX attribute is of type number (long)+Pass touchstart2.touches[1].Touch.pageY attribute exists+Pass touchstart2.touches[1].Touch.pageY attribute is of type number (long)+Pass touchstart2.targetTouches attribute exists+Pass touchstart2.targetTouches attribute is of type TouchList+Pass touchstart2.targetTouches's touch list is a TouchList object+Pass touchstart2.targetTouches.TouchList.length attribute exists+Pass touchstart2.targetTouches.TouchList.length attribute is of type number (unsigned long)+Pass touchstart2.targetTouches.TouchList.item attribute exists+Pass touchstart2.targetTouches.TouchList.item attribute is of type function+Pass touchstart2.targetTouches[0]'s touch point is a Touch object+Pass touchstart2.targetTouches[0].Touch.identifier attribute exists+Pass touchstart2.targetTouches[0].Touch.identifier attribute is of type number (long)+Pass touchstart2.targetTouches[0].Touch.target attribute exists+Pass touchstart2.targetTouches[0].Touch.target attribute is of type Element+Pass touchstart2.targetTouches[0].Touch.screenX attribute exists+Pass touchstart2.targetTouches[0].Touch.screenX attribute is of type number (long)+Pass touchstart2.targetTouches[0].Touch.screenY attribute exists+Pass touchstart2.targetTouches[0].Touch.screenY attribute is of type number (long)+Pass touchstart2.targetTouches[0].Touch.clientX attribute exists+Pass touchstart2.targetTouches[0].Touch.clientX attribute is of type number (long)+Pass touchstart2.targetTouches[0].Touch.clientY attribute exists+Pass touchstart2.targetTouches[0].Touch.clientY attribute is of type number (long)+Pass touchstart2.targetTouches[0].Touch.pageX attribute exists+Pass touchstart2.targetTouches[0].Touch.pageX attribute is of type number (long)+Pass touchstart2.targetTouches[0].Touch.pageY attribute exists+Pass touchstart2.targetTouches[0].Touch.pageY attribute is of type number (long)+Pass touchstart2.targetTouches[1]'s touch point is a Touch object+Pass touchstart2.targetTouches[1].Touch.identifier attribute exists+Pass touchstart2.targetTouches[1].Touch.identifier attribute is of type number (long)+Pass touchstart2.targetTouches[1].Touch.target attribute exists+Pass touchstart2.targetTouches[1].Touch.target attribute is of type Element+Pass touchstart2.targetTouches[1].Touch.screenX attribute exists+Pass touchstart2.targetTouches[1].Touch.screenX attribute is of type number (long)+Pass touchstart2.targetTouches[1].Touch.screenY attribute exists+Pass touchstart2.targetTouches[1].Touch.screenY attribute is of type number (long)+Pass touchstart2.targetTouches[1].Touch.clientX attribute exists+Pass touchstart2.targetTouches[1].Touch.clientX attribute is of type number (long)+Pass touchstart2.targetTouches[1].Touch.clientY attribute exists+Pass touchstart2.targetTouches[1].Touch.clientY attribute is of type number (long)+Pass touchstart2.targetTouches[1].Touch.pageX attribute exists+Pass touchstart2.targetTouches[1].Touch.pageX attribute is of type number (long)+Pass touchstart2.targetTouches[1].Touch.pageY attribute exists+Pass touchstart2.targetTouches[1].Touch.pageY attribute is of type number (long)+Pass touchstart2.changedTouches attribute exists+Pass touchstart2.changedTouches attribute is of type TouchList+Pass touchstart2.changedTouches's touch list is a TouchList object+Pass touchstart2.changedTouches.TouchList.length attribute exists+Pass touchstart2.changedTouches.TouchList.length attribute is of type number (unsigned long)+Pass touchstart2.changedTouches.TouchList.item attribute exists+Pass touchstart2.changedTouches.TouchList.item attribute is of type function+Pass touchstart2.changedTouches[0]'s touch point is a Touch object+Pass touchstart2.changedTouches[0].Touch.identifier attribute exists+Pass touchstart2.changedTouches[0].Touch.identifier attribute is of type number (long)+Pass touchstart2.changedTouches[0].Touch.target attribute exists+Pass touchstart2.changedTouches[0].Touch.target attribute is of type Element+Pass touchstart2.changedTouches[0].Touch.screenX attribute exists+Pass touchstart2.changedTouches[0].Touch.screenX attribute is of type number (long)+Pass touchstart2.changedTouches[0].Touch.screenY attribute exists+Pass touchstart2.changedTouches[0].Touch.screenY attribute is of type number (long)+Pass touchstart2.changedTouches[0].Touch.clientX attribute exists+Pass touchstart2.changedTouches[0].Touch.clientX attribute is of type number (long)+Pass touchstart2.changedTouches[0].Touch.clientY attribute exists+Pass touchstart2.changedTouches[0].Touch.clientY attribute is of type number (long)+Pass touchstart2.changedTouches[0].Touch.pageX attribute exists+Pass touchstart2.changedTouches[0].Touch.pageX attribute is of type number (long)+Pass touchstart2.changedTouches[0].Touch.pageY attribute exists+Pass touchstart2.changedTouches[0].Touch.pageY attribute is of type number (long)+Pass touchstart2.altKey attribute exists+Pass touchstart2.altKey attribute is of type boolean+Pass touchstart2.metaKey attribute exists+Pass touchstart2.metaKey attribute is of type boolean+Pass touchstart2.ctrlKey attribute exists+Pass touchstart2.ctrlKey attribute is of type boolean+Pass touchstart2.shiftKey attribute exists+Pass touchstart2.shiftKey attribute is of type boolean+Pass touchmove1 event is a TouchEvent event+Pass touchmove1.touches attribute exists+Pass touchmove1.touches attribute is of type TouchList+Pass touchmove1.touches's touch list is a TouchList object+Pass touchmove1.touches.TouchList.length attribute exists+Pass touchmove1.touches.TouchList.length attribute is of type number (unsigned long)+Pass touchmove1.touches.TouchList.item attribute exists+Pass touchmove1.touches.TouchList.item attribute is of type function+Pass touchmove1.touches[0]'s touch point is a Touch object+Pass touchmove1.touches[0].Touch.identifier attribute exists+Pass touchmove1.touches[0].Touch.identifier attribute is of type number (long)+Pass touchmove1.touches[0].Touch.target attribute exists+Pass touchmove1.touches[0].Touch.target attribute is of type Element+Pass touchmove1.touches[0].Touch.screenX attribute exists+Pass touchmove1.touches[0].Touch.screenX attribute is of type number (long)+Pass touchmove1.touches[0].Touch.screenY attribute exists+Pass touchmove1.touches[0].Touch.screenY attribute is of type number (long)+Pass touchmove1.touches[0].Touch.clientX attribute exists+Pass touchmove1.touches[0].Touch.clientX attribute is of type number (long)+Pass touchmove1.touches[0].Touch.clientY attribute exists+Pass touchmove1.touches[0].Touch.clientY attribute is of type number (long)+Pass touchmove1.touches[0].Touch.pageX attribute exists+Pass touchmove1.touches[0].Touch.pageX attribute is of type number (long)+Pass touchmove1.touches[0].Touch.pageY attribute exists+Pass touchmove1.touches[0].Touch.pageY attribute is of type number (long)+Pass touchmove1.touches[1]'s touch point is a Touch object+Pass touchmove1.touches[1].Touch.identifier attribute exists+Pass touchmove1.touches[1].Touch.identifier attribute is of type number (long)+Pass touchmove1.touches[1].Touch.target attribute exists+Pass touchmove1.touches[1].Touch.target attribute is of type Element+Pass touchmove1.touches[1].Touch.screenX attribute exists+Pass touchmove1.touches[1].Touch.screenX attribute is of type number (long)+Pass touchmove1.touches[1].Touch.screenY attribute exists+Pass touchmove1.touches[1].Touch.screenY attribute is of type number (long)+Pass touchmove1.touches[1].Touch.clientX attribute exists+Pass touchmove1.touches[1].Touch.clientX attribute is of type number (long)+Pass touchmove1.touches[1].Touch.clientY attribute exists+Pass touchmove1.touches[1].Touch.clientY attribute is of type number (long)+Pass touchmove1.touches[1].Touch.pageX attribute exists+Pass touchmove1.touches[1].Touch.pageX attribute is of type number (long)+Pass touchmove1.touches[1].Touch.pageY attribute exists+Pass touchmove1.touches[1].Touch.pageY attribute is of type number (long)+Pass touchmove1.targetTouches attribute exists+Pass touchmove1.targetTouches attribute is of type TouchList+Pass touchmove1.targetTouches's touch list is a TouchList object+Pass touchmove1.targetTouches.TouchList.length attribute exists+Pass touchmove1.targetTouches.TouchList.length attribute is of type number (unsigned long)+Pass touchmove1.targetTouches.TouchList.item attribute exists+Pass touchmove1.targetTouches.TouchList.item attribute is of type function+Pass touchmove1.targetTouches[0]'s touch point is a Touch object+Pass touchmove1.targetTouches[0].Touch.identifier attribute exists+Pass touchmove1.targetTouches[0].Touch.identifier attribute is of type number (long)+Pass touchmove1.targetTouches[0].Touch.target attribute exists+Pass touchmove1.targetTouches[0].Touch.target attribute is of type Element+Pass touchmove1.targetTouches[0].Touch.screenX attribute exists+Pass touchmove1.targetTouches[0].Touch.screenX attribute is of type number (long)+Pass touchmove1.targetTouches[0].Touch.screenY attribute exists+Pass touchmove1.targetTouches[0].Touch.screenY attribute is of type number (long)+Pass touchmove1.targetTouches[0].Touch.clientX attribute exists+Pass touchmove1.targetTouches[0].Touch.clientX attribute is of type number (long)+Pass touchmove1.targetTouches[0].Touch.clientY attribute exists+Pass touchmove1.targetTouches[0].Touch.clientY attribute is of type number (long)+Pass touchmove1.targetTouches[0].Touch.pageX attribute exists+Pass touchmove1.targetTouches[0].Touch.pageX attribute is of type number (long)+Pass touchmove1.targetTouches[0].Touch.pageY attribute exists+Pass touchmove1.targetTouches[0].Touch.pageY attribute is of type number (long)+Pass touchmove1.targetTouches[1]'s touch point is a Touch object+Pass touchmove1.targetTouches[1].Touch.identifier attribute exists+Pass touchmove1.targetTouches[1].Touch.identifier attribute is of type number (long)+Pass touchmove1.targetTouches[1].Touch.target attribute exists+Pass touchmove1.targetTouches[1].Touch.target attribute is of type Element+Pass touchmove1.targetTouches[1].Touch.screenX attribute exists+Pass touchmove1.targetTouches[1].Touch.screenX attribute is of type number (long)+Pass touchmove1.targetTouches[1].Touch.screenY attribute exists+Pass touchmove1.targetTouches[1].Touch.screenY attribute is of type number (long)+Pass touchmove1.targetTouches[1].Touch.clientX attribute exists+Pass touchmove1.targetTouches[1].Touch.clientX attribute is of type number (long)+Pass touchmove1.targetTouches[1].Touch.clientY attribute exists+Pass touchmove1.targetTouches[1].Touch.clientY attribute is of type number (long)+Pass touchmove1.targetTouches[1].Touch.pageX attribute exists+Pass touchmove1.targetTouches[1].Touch.pageX attribute is of type number (long)+Pass touchmove1.targetTouches[1].Touch.pageY attribute exists+Pass touchmove1.targetTouches[1].Touch.pageY attribute is of type number (long)+Pass touchmove1.changedTouches attribute exists+Pass touchmove1.changedTouches attribute is of type TouchList+Pass touchmove1.changedTouches's touch list is a TouchList object+Pass touchmove1.changedTouches.TouchList.length attribute exists+Pass touchmove1.changedTouches.TouchList.length attribute is of type number (unsigned long)+Pass touchmove1.changedTouches.TouchList.item attribute exists+Pass touchmove1.changedTouches.TouchList.item attribute is of type function+Pass touchmove1.changedTouches[0]'s touch point is a Touch object+Pass touchmove1.changedTouches[0].Touch.identifier attribute exists+Pass touchmove1.changedTouches[0].Touch.identifier attribute is of type number (long)+Pass touchmove1.changedTouches[0].Touch.target attribute exists+Pass touchmove1.changedTouches[0].Touch.target attribute is of type Element+Pass touchmove1.changedTouches[0].Touch.screenX attribute exists+Pass touchmove1.changedTouches[0].Touch.screenX attribute is of type number (long)+Pass touchmove1.changedTouches[0].Touch.screenY attribute exists+Pass touchmove1.changedTouches[0].Touch.screenY attribute is of type number (long)+Pass touchmove1.changedTouches[0].Touch.clientX attribute exists+Pass touchmove1.changedTouches[0].Touch.clientX attribute is of type number (long)+Pass touchmove1.changedTouches[0].Touch.clientY attribute exists+Pass touchmove1.changedTouches[0].Touch.clientY attribute is of type number (long)+Pass touchmove1.changedTouches[0].Touch.pageX attribute exists+Pass touchmove1.changedTouches[0].Touch.pageX attribute is of type number (long)+Pass touchmove1.changedTouches[0].Touch.pageY attribute exists+Pass touchmove1.changedTouches[0].Touch.pageY attribute is of type number (long)+Pass touchmove1.altKey attribute exists+Pass touchmove1.altKey attribute is of type boolean+Pass touchmove1.metaKey attribute exists+Pass touchmove1.metaKey attribute is of type boolean+Pass touchmove1.ctrlKey attribute exists+Pass touchmove1.ctrlKey attribute is of type boolean+Pass touchmove1.shiftKey attribute exists+Pass touchmove1.shiftKey attribute is of type boolean+Pass touchmove2 event is a TouchEvent event+Pass touchmove2.touches attribute exists+Pass touchmove2.touches attribute is of type TouchList+Pass touchmove2.touches's touch list is a TouchList object+Pass touchmove2.touches.TouchList.length attribute exists+Pass touchmove2.touches.TouchList.length attribute is of type number (unsigned long)+Pass touchmove2.touches.TouchList.item attribute exists+Pass touchmove2.touches.TouchList.item attribute is of type function+Pass touchmove2.touches[0]'s touch point is a Touch object+Pass touchmove2.touches[0].Touch.identifier attribute exists+Pass touchmove2.touches[0].Touch.identifier attribute is of type number (long)+Pass touchmove2.touches[0].Touch.target attribute exists+Pass touchmove2.touches[0].Touch.target attribute is of type Element+Pass touchmove2.touches[0].Touch.screenX attribute exists+Pass touchmove2.touches[0].Touch.screenX attribute is of type number (long)+Pass touchmove2.touches[0].Touch.screenY attribute exists+Pass touchmove2.touches[0].Touch.screenY attribute is of type number (long)+Pass touchmove2.touches[0].Touch.clientX attribute exists+Pass touchmove2.touches[0].Touch.clientX attribute is of type number (long)+Pass touchmove2.touches[0].Touch.clientY attribute exists+Pass touchmove2.touches[0].Touch.clientY attribute is of type number (long)+Pass touchmove2.touches[0].Touch.pageX attribute exists+Pass touchmove2.touches[0].Touch.pageX attribute is of type number (long)+Pass touchmove2.touches[0].Touch.pageY attribute exists+Pass touchmove2.touches[0].Touch.pageY attribute is of type number (long)+Pass touchmove2.touches[1]'s touch point is a Touch object+Pass touchmove2.touches[1].Touch.identifier attribute exists+Pass touchmove2.touches[1].Touch.identifier attribute is of type number (long)+Pass touchmove2.touches[1].Touch.target attribute exists+Pass touchmove2.touches[1].Touch.target attribute is of type Element+Pass touchmove2.touches[1].Touch.screenX attribute exists+Pass touchmove2.touches[1].Touch.screenX attribute is of type number (long)+Pass touchmove2.touches[1].Touch.screenY attribute exists+Pass touchmove2.touches[1].Touch.screenY attribute is of type number (long)+Pass touchmove2.touches[1].Touch.clientX attribute exists+Pass touchmove2.touches[1].Touch.clientX attribute is of type number (long)+Pass touchmove2.touches[1].Touch.clientY attribute exists+Pass touchmove2.touches[1].Touch.clientY attribute is of type number (long)+Pass touchmove2.touches[1].Touch.pageX attribute exists+Pass touchmove2.touches[1].Touch.pageX attribute is of type number (long)+Pass touchmove2.touches[1].Touch.pageY attribute exists+Pass touchmove2.touches[1].Touch.pageY attribute is of type number (long)+Pass touchmove2.targetTouches attribute exists+Pass touchmove2.targetTouches attribute is of type TouchList+Pass touchmove2.targetTouches's touch list is a TouchList object+Pass touchmove2.targetTouches.TouchList.length attribute exists+Pass touchmove2.targetTouches.TouchList.length attribute is of type number (unsigned long)+Pass touchmove2.targetTouches.TouchList.item attribute exists+Pass touchmove2.targetTouches.TouchList.item attribute is of type function+Pass touchmove2.targetTouches[0]'s touch point is a Touch object+Pass touchmove2.targetTouches[0].Touch.identifier attribute exists+Pass touchmove2.targetTouches[0].Touch.identifier attribute is of type number (long)+Pass touchmove2.targetTouches[0].Touch.target attribute exists+Pass touchmove2.targetTouches[0].Touch.target attribute is of type Element+Pass touchmove2.targetTouches[0].Touch.screenX attribute exists+Pass touchmove2.targetTouches[0].Touch.screenX attribute is of type number (long)+Pass touchmove2.targetTouches[0].Touch.screenY attribute exists+Pass touchmove2.targetTouches[0].Touch.screenY attribute is of type number (long)+Pass touchmove2.targetTouches[0].Touch.clientX attribute exists+Pass touchmove2.targetTouches[0].Touch.clientX attribute is of type number (long)+Pass touchmove2.targetTouches[0].Touch.clientY attribute exists+Pass touchmove2.targetTouches[0].Touch.clientY attribute is of type number (long)+Pass touchmove2.targetTouches[0].Touch.pageX attribute exists+Pass touchmove2.targetTouches[0].Touch.pageX attribute is of type number (long)+Pass touchmove2.targetTouches[0].Touch.pageY attribute exists+Pass touchmove2.targetTouches[0].Touch.pageY attribute is of type number (long)+Pass touchmove2.targetTouches[1]'s touch point is a Touch object+Pass touchmove2.targetTouches[1].Touch.identifier attribute exists+Pass touchmove2.targetTouches[1].Touch.identifier attribute is of type number (long)+Pass touchmove2.targetTouches[1].Touch.target attribute exists+Pass touchmove2.targetTouches[1].Touch.target attribute is of type Element+Pass touchmove2.targetTouches[1].Touch.screenX attribute exists+Pass touchmove2.targetTouches[1].Touch.screenX attribute is of type number (long)+Pass touchmove2.targetTouches[1].Touch.screenY attribute exists+Pass touchmove2.targetTouches[1].Touch.screenY attribute is of type number (long)+Pass touchmove2.targetTouches[1].Touch.clientX attribute exists+Pass touchmove2.targetTouches[1].Touch.clientX attribute is of type number (long)+Pass touchmove2.targetTouches[1].Touch.clientY attribute exists+Pass touchmove2.targetTouches[1].Touch.clientY attribute is of type number (long)+Pass touchmove2.targetTouches[1].Touch.pageX attribute exists+Pass touchmove2.targetTouches[1].Touch.pageX attribute is of type number (long)+Pass touchmove2.targetTouches[1].Touch.pageY attribute exists+Pass touchmove2.targetTouches[1].Touch.pageY attribute is of type number (long)+Pass touchmove2.changedTouches attribute exists+Pass touchmove2.changedTouches attribute is of type TouchList+Pass touchmove2.changedTouches's touch list is a TouchList object+Pass touchmove2.changedTouches.TouchList.length attribute exists+Pass touchmove2.changedTouches.TouchList.length attribute is of type number (unsigned long)+Pass touchmove2.changedTouches.TouchList.item attribute exists+Pass touchmove2.changedTouches.TouchList.item attribute is of type function+Pass touchmove2.changedTouches[0]'s touch point is a Touch object+Pass touchmove2.changedTouches[0].Touch.identifier attribute exists+Pass touchmove2.changedTouches[0].Touch.identifier attribute is of type number (long)+Pass touchmove2.changedTouches[0].Touch.target attribute exists+Pass touchmove2.changedTouches[0].Touch.target attribute is of type Element+Pass touchmove2.changedTouches[0].Touch.screenX attribute exists+Pass touchmove2.changedTouches[0].Touch.screenX attribute is of type number (long)+Pass touchmove2.changedTouches[0].Touch.screenY attribute exists+Pass touchmove2.changedTouches[0].Touch.screenY attribute is of type number (long)+Pass touchmove2.changedTouches[0].Touch.clientX attribute exists+Pass touchmove2.changedTouches[0].Touch.clientX attribute is of type number (long)+Pass touchmove2.changedTouches[0].Touch.clientY attribute exists+Pass touchmove2.changedTouches[0].Touch.clientY attribute is of type number (long)+Pass touchmove2.changedTouches[0].Touch.pageX attribute exists+Pass touchmove2.changedTouches[0].Touch.pageX attribute is of type number (long)+Pass touchmove2.changedTouches[0].Touch.pageY attribute exists+Pass touchmove2.changedTouches[0].Touch.pageY attribute is of type number (long)+Pass touchmove2.altKey attribute exists+Pass touchmove2.altKey attribute is of type boolean+Pass touchmove2.metaKey attribute exists+Pass touchmove2.metaKey attribute is of type boolean+Pass touchmove2.ctrlKey attribute exists+Pass touchmove2.ctrlKey attribute is of type boolean+Pass touchmove2.shiftKey attribute exists+Pass touchmove2.shiftKey attribute is of type boolean+Pass touchend2 event is a TouchEvent event+Pass touchend2.touches attribute exists+Pass touchend2.touches attribute is of type TouchList+Pass touchend2.touches's touch list is a TouchList object+Pass touchend2.touches.TouchList.length attribute exists+Pass touchend2.touches.TouchList.length attribute is of type number (unsigned long)+Pass touchend2.touches.TouchList.item attribute exists+Pass touchend2.touches.TouchList.item attribute is of type function+Pass touchend2.touches[0]'s touch point is a Touch object+Pass touchend2.touches[0].Touch.identifier attribute exists+Pass touchend2.touches[0].Touch.identifier attribute is of type number (long)+Pass touchend2.touches[0].Touch.target attribute exists+Pass touchend2.touches[0].Touch.target attribute is of type Element+Pass touchend2.touches[0].Touch.screenX attribute exists+Pass touchend2.touches[0].Touch.screenX attribute is of type number (long)+Pass touchend2.touches[0].Touch.screenY attribute exists+Pass touchend2.touches[0].Touch.screenY attribute is of type number (long)+Pass touchend2.touches[0].Touch.clientX attribute exists+Pass touchend2.touches[0].Touch.clientX attribute is of type number (long)+Pass touchend2.touches[0].Touch.clientY attribute exists+Pass touchend2.touches[0].Touch.clientY attribute is of type number (long)+Pass touchend2.touches[0].Touch.pageX attribute exists+Pass touchend2.touches[0].Touch.pageX attribute is of type number (long)+Pass touchend2.touches[0].Touch.pageY attribute exists+Pass touchend2.touches[0].Touch.pageY attribute is of type number (long)+Pass touchend2.targetTouches attribute exists+Pass touchend2.targetTouches attribute is of type TouchList+Pass touchend2.targetTouches's touch list is a TouchList object+Pass touchend2.targetTouches.TouchList.length attribute exists+Pass touchend2.targetTouches.TouchList.length attribute is of type number (unsigned long)+Pass touchend2.targetTouches.TouchList.item attribute exists+Pass touchend2.targetTouches.TouchList.item attribute is of type function+Pass touchend2.targetTouches[0]'s touch point is a Touch object+Pass touchend2.targetTouches[0].Touch.identifier attribute exists+Pass touchend2.targetTouches[0].Touch.identifier attribute is of type number (long)+Pass touchend2.targetTouches[0].Touch.target attribute exists+Pass touchend2.targetTouches[0].Touch.target attribute is of type Element+Pass touchend2.targetTouches[0].Touch.screenX attribute exists+Pass touchend2.targetTouches[0].Touch.screenX attribute is of type number (long)+Pass touchend2.targetTouches[0].Touch.screenY attribute exists+Pass touchend2.targetTouches[0].Touch.screenY attribute is of type number (long)+Pass touchend2.targetTouches[0].Touch.clientX attribute exists+Pass touchend2.targetTouches[0].Touch.clientX attribute is of type number (long)+Pass touchend2.targetTouches[0].Touch.clientY attribute exists+Pass touchend2.targetTouches[0].Touch.clientY attribute is of type number (long)+Pass touchend2.targetTouches[0].Touch.pageX attribute exists+Pass touchend2.targetTouches[0].Touch.pageX attribute is of type number (long)+Pass touchend2.targetTouches[0].Touch.pageY attribute exists+Pass touchend2.targetTouches[0].Touch.pageY attribute is of type number (long)+Pass touchend2.changedTouches attribute exists+Pass touchend2.changedTouches attribute is of type TouchList+Pass touchend2.changedTouches's touch list is a TouchList object+Pass touchend2.changedTouches.TouchList.length attribute exists+Pass touchend2.changedTouches.TouchList.length attribute is of type number (unsigned long)+Pass touchend2.changedTouches.TouchList.item attribute exists+Pass touchend2.changedTouches.TouchList.item attribute is of type function+Pass touchend2.changedTouches[0]'s touch point is a Touch object+Pass touchend2.changedTouches[0].Touch.identifier attribute exists+Pass touchend2.changedTouches[0].Touch.identifier attribute is of type number (long)+Pass touchend2.changedTouches[0].Touch.target attribute exists+Pass touchend2.changedTouches[0].Touch.target attribute is of type Element+Pass touchend2.changedTouches[0].Touch.screenX attribute exists+Pass touchend2.changedTouches[0].Touch.screenX attribute is of type number (long)+Pass touchend2.changedTouches[0].Touch.screenY attribute exists+Pass touchend2.changedTouches[0].Touch.screenY attribute is of type number (long)+Pass touchend2.changedTouches[0].Touch.clientX attribute exists+Pass touchend2.changedTouches[0].Touch.clientX attribute is of type number (long)+Pass touchend2.changedTouches[0].Touch.clientY attribute exists+Pass touchend2.changedTouches[0].Touch.clientY attribute is of type number (long)+Pass touchend2.changedTouches[0].Touch.pageX attribute exists+Pass touchend2.changedTouches[0].Touch.pageX attribute is of type number (long)+Pass touchend2.changedTouches[0].Touch.pageY attribute exists+Pass touchend2.changedTouches[0].Touch.pageY attribute is of type number (long)+Pass touchend2.altKey attribute exists+Pass touchend2.altKey attribute is of type boolean+Pass touchend2.metaKey attribute exists+Pass touchend2.metaKey attribute is of type boolean+Pass touchend2.ctrlKey attribute exists+Pass touchend2.ctrlKey attribute is of type boolean+Pass touchend2.shiftKey attribute exists+Pass touchend2.shiftKey attribute is of type boolean\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/touch-events/single-touch.txt b/Tests/LibWeb/Text/expected/wpt-import/touch-events/single-touch.txtnew file mode 100644index 00000000000..d12eb94ae9a--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/touch-events/single-touch.txt@@ -0,0 +1,232 @@+Harness status: OK++Found 227 tests++227 Pass+Pass Verify touch events for a single touch drag operation+Pass touchstart event is a TouchEvent event+Pass touchstart.touches attribute exists check_TouchEvent+Pass touchstart.touches attribute is of type TouchList+Pass touchstart.touches's touch list is a TouchList object+Pass touchstart.touches.TouchList.length attribute exists check_touchList_object+Pass touchstart.touches.TouchList.length attribute is of type number (unsigned long)+Pass touchstart.touches.TouchList.item attribute exists check_touchList_object+Pass touchstart.touches.TouchList.item attribute is of type function+Pass touchstart.touches[0]'s touch point is a Touch object+Pass touchstart.touches[0].Touch.identifier attribute exists check_Touch_object+Pass touchstart.touches[0].Touch.identifier attribute is of type number (long)+Pass touchstart.touches[0].Touch.target attribute exists check_Touch_object+Pass touchstart.touches[0].Touch.target attribute is of type Element+Pass touchstart.touches[0].Touch.screenX attribute exists check_Touch_object+Pass touchstart.touches[0].Touch.screenX attribute is of type number (long)+Pass touchstart.touches[0].Touch.screenY attribute exists check_Touch_object+Pass touchstart.touches[0].Touch.screenY attribute is of type number (long)+Pass touchstart.touches[0].Touch.clientX attribute exists check_Touch_object+Pass touchstart.touches[0].Touch.clientX attribute is of type number (long)+Pass touchstart.touches[0].Touch.clientY attribute exists check_Touch_object+Pass touchstart.touches[0].Touch.clientY attribute is of type number (long)+Pass touchstart.touches[0].Touch.pageX attribute exists check_Touch_object+Pass touchstart.touches[0].Touch.pageX attribute is of type number (long)+Pass touchstart.touches[0].Touch.pageY attribute exists check_Touch_object+Pass touchstart.touches[0].Touch.pageY attribute is of type number (long)+Pass touchstart.targetTouches attribute exists check_TouchEvent+Pass touchstart.targetTouches attribute is of type TouchList+Pass touchstart.targetTouches's touch list is a TouchList object+Pass touchstart.targetTouches.TouchList.length attribute exists check_touchList_object+Pass touchstart.targetTouches.TouchList.length attribute is of type number (unsigned long)+Pass touchstart.targetTouches.TouchList.item attribute exists check_touchList_object+Pass touchstart.targetTouches.TouchList.item attribute is of type function+Pass touchstart.targetTouches[0]'s touch point is a Touch object+Pass touchstart.targetTouches[0].Touch.identifier attribute exists check_Touch_object+Pass touchstart.targetTouches[0].Touch.identifier attribute is of type number (long)+Pass touchstart.targetTouches[0].Touch.target attribute exists check_Touch_object+Pass touchstart.targetTouches[0].Touch.target attribute is of type Element+Pass touchstart.targetTouches[0].Touch.screenX attribute exists check_Touch_object+Pass touchstart.targetTouches[0].Touch.screenX attribute is of type number (long)+Pass touchstart.targetTouches[0].Touch.screenY attribute exists check_Touch_object+Pass touchstart.targetTouches[0].Touch.screenY attribute is of type number (long)+Pass touchstart.targetTouches[0].Touch.clientX attribute exists check_Touch_object+Pass touchstart.targetTouches[0].Touch.clientX attribute is of type number (long)+Pass touchstart.targetTouches[0].Touch.clientY attribute exists check_Touch_object+Pass touchstart.targetTouches[0].Touch.clientY attribute is of type number (long)+Pass touchstart.targetTouches[0].Touch.pageX attribute exists check_Touch_object+Pass touchstart.targetTouches[0].Touch.pageX attribute is of type number (long)+Pass touchstart.targetTouches[0].Touch.pageY attribute exists check_Touch_object+Pass touchstart.targetTouches[0].Touch.pageY attribute is of type number (long)+Pass touchstart.changedTouches attribute exists check_TouchEvent+Pass touchstart.changedTouches attribute is of type TouchList+Pass touchstart.changedTouches's touch list is a TouchList object+Pass touchstart.changedTouches.TouchList.length attribute exists check_touchList_object+Pass touchstart.changedTouches.TouchList.length attribute is of type number (unsigned long)+Pass touchstart.changedTouches.TouchList.item attribute exists check_touchList_object+Pass touchstart.changedTouches.TouchList.item attribute is of type function+Pass touchstart.changedTouches[0]'s touch point is a Touch object+Pass touchstart.changedTouches[0].Touch.identifier attribute exists check_Touch_object+Pass touchstart.changedTouches[0].Touch.identifier attribute is of type number (long)+Pass touchstart.changedTouches[0].Touch.target attribute exists check_Touch_object+Pass touchstart.changedTouches[0].Touch.target attribute is of type Element+Pass touchstart.changedTouches[0].Touch.screenX attribute exists check_Touch_object+Pass touchstart.changedTouches[0].Touch.screenX attribute is of type number (long)+Pass touchstart.changedTouches[0].Touch.screenY attribute exists check_Touch_object+Pass touchstart.changedTouches[0].Touch.screenY attribute is of type number (long)+Pass touchstart.changedTouches[0].Touch.clientX attribute exists check_Touch_object+Pass touchstart.changedTouches[0].Touch.clientX attribute is of type number (long)+Pass touchstart.changedTouches[0].Touch.clientY attribute exists check_Touch_object+Pass touchstart.changedTouches[0].Touch.clientY attribute is of type number (long)+Pass touchstart.changedTouches[0].Touch.pageX attribute exists check_Touch_object+Pass touchstart.changedTouches[0].Touch.pageX attribute is of type number (long)+Pass touchstart.changedTouches[0].Touch.pageY attribute exists check_Touch_object+Pass touchstart.changedTouches[0].Touch.pageY attribute is of type number (long)+Pass touchstart.altKey attribute exists check_TouchEvent+Pass touchstart.altKey attribute is of type boolean+Pass touchstart.metaKey attribute exists check_TouchEvent+Pass touchstart.metaKey attribute is of type boolean+Pass touchstart.ctrlKey attribute exists check_TouchEvent+Pass touchstart.ctrlKey attribute is of type boolean+Pass touchstart.shiftKey attribute exists check_TouchEvent+Pass touchstart.shiftKey attribute is of type boolean+Pass touchstart: all TouchList lengths are correct+Pass touchstart: all TouchList identifiers are consistent+Pass touchstart: event target same as targetTouches target+Pass touchstart: touch pageX/pageY inside of target element+Pass touchstart: touch clientX/clientY is consistent with pageX/pageY+Pass touchstart: touch screenX/screenY pageX/pageY and clientX/clientY values are no less than 0+Pass touchmove event is a TouchEvent event+Pass touchmove.touches attribute exists check_TouchEvent+Pass touchmove.touches attribute is of type TouchList+Pass touchmove.touches's touch list is a TouchList object+Pass touchmove.touches.TouchList.length attribute exists check_touchList_object+Pass touchmove.touches.TouchList.length attribute is of type number (unsigned long)+Pass touchmove.touches.TouchList.item attribute exists check_touchList_object+Pass touchmove.touches.TouchList.item attribute is of type function+Pass touchmove.touches[0]'s touch point is a Touch object+Pass touchmove.touches[0].Touch.identifier attribute exists check_Touch_object+Pass touchmove.touches[0].Touch.identifier attribute is of type number (long)+Pass touchmove.touches[0].Touch.target attribute exists check_Touch_object+Pass touchmove.touches[0].Touch.target attribute is of type Element+Pass touchmove.touches[0].Touch.screenX attribute exists check_Touch_object+Pass touchmove.touches[0].Touch.screenX attribute is of type number (long)+Pass touchmove.touches[0].Touch.screenY attribute exists check_Touch_object+Pass touchmove.touches[0].Touch.screenY attribute is of type number (long)+Pass touchmove.touches[0].Touch.clientX attribute exists check_Touch_object+Pass touchmove.touches[0].Touch.clientX attribute is of type number (long)+Pass touchmove.touches[0].Touch.clientY attribute exists check_Touch_object+Pass touchmove.touches[0].Touch.clientY attribute is of type number (long)+Pass touchmove.touches[0].Touch.pageX attribute exists check_Touch_object+Pass touchmove.touches[0].Touch.pageX attribute is of type number (long)+Pass touchmove.touches[0].Touch.pageY attribute exists check_Touch_object+Pass touchmove.touches[0].Touch.pageY attribute is of type number (long)+Pass touchmove.targetTouches attribute exists check_TouchEvent+Pass touchmove.targetTouches attribute is of type TouchList+Pass touchmove.targetTouches's touch list is a TouchList object+Pass touchmove.targetTouches.TouchList.length attribute exists check_touchList_object+Pass touchmove.targetTouches.TouchList.length attribute is of type number (unsigned long)+Pass touchmove.targetTouches.TouchList.item attribute exists check_touchList_object+Pass touchmove.targetTouches.TouchList.item attribute is of type function+Pass touchmove.targetTouches[0]'s touch point is a Touch object+Pass touchmove.targetTouches[0].Touch.identifier attribute exists check_Touch_object+Pass touchmove.targetTouches[0].Touch.identifier attribute is of type number (long)+Pass touchmove.targetTouches[0].Touch.target attribute exists check_Touch_object+Pass touchmove.targetTouches[0].Touch.target attribute is of type Element+Pass touchmove.targetTouches[0].Touch.screenX attribute exists check_Touch_object+Pass touchmove.targetTouches[0].Touch.screenX attribute is of type number (long)+Pass touchmove.targetTouches[0].Touch.screenY attribute exists check_Touch_object+Pass touchmove.targetTouches[0].Touch.screenY attribute is of type number (long)+Pass touchmove.targetTouches[0].Touch.clientX attribute exists check_Touch_object+Pass touchmove.targetTouches[0].Touch.clientX attribute is of type number (long)+Pass touchmove.targetTouches[0].Touch.clientY attribute exists check_Touch_object+Pass touchmove.targetTouches[0].Touch.clientY attribute is of type number (long)+Pass touchmove.targetTouches[0].Touch.pageX attribute exists check_Touch_object+Pass touchmove.targetTouches[0].Touch.pageX attribute is of type number (long)+Pass touchmove.targetTouches[0].Touch.pageY attribute exists check_Touch_object+Pass touchmove.targetTouches[0].Touch.pageY attribute is of type number (long)+Pass touchmove.changedTouches attribute exists check_TouchEvent+Pass touchmove.changedTouches attribute is of type TouchList+Pass touchmove.changedTouches's touch list is a TouchList object+Pass touchmove.changedTouches.TouchList.length attribute exists check_touchList_object+Pass touchmove.changedTouches.TouchList.length attribute is of type number (unsigned long)+Pass touchmove.changedTouches.TouchList.item attribute exists check_touchList_object+Pass touchmove.changedTouches.TouchList.item attribute is of type function+Pass touchmove.changedTouches[0]'s touch point is a Touch object+Pass touchmove.changedTouches[0].Touch.identifier attribute exists check_Touch_object+Pass touchmove.changedTouches[0].Touch.identifier attribute is of type number (long)+Pass touchmove.changedTouches[0].Touch.target attribute exists check_Touch_object+Pass touchmove.changedTouches[0].Touch.target attribute is of type Element+Pass touchmove.changedTouches[0].Touch.screenX attribute exists check_Touch_object+Pass touchmove.changedTouches[0].Touch.screenX attribute is of type number (long)+Pass touchmove.changedTouches[0].Touch.screenY attribute exists check_Touch_object+Pass touchmove.changedTouches[0].Touch.screenY attribute is of type number (long)+Pass touchmove.changedTouches[0].Touch.clientX attribute exists check_Touch_object+Pass touchmove.changedTouches[0].Touch.clientX attribute is of type number (long)+Pass touchmove.changedTouches[0].Touch.clientY attribute exists check_Touch_object+Pass touchmove.changedTouches[0].Touch.clientY attribute is of type number (long)+Pass touchmove.changedTouches[0].Touch.pageX attribute exists check_Touch_object+Pass touchmove.changedTouches[0].Touch.pageX attribute is of type number (long)+Pass touchmove.changedTouches[0].Touch.pageY attribute exists check_Touch_object+Pass touchmove.changedTouches[0].Touch.pageY attribute is of type number (long)+Pass touchmove.altKey attribute exists check_TouchEvent+Pass touchmove.altKey attribute is of type boolean+Pass touchmove.metaKey attribute exists check_TouchEvent+Pass touchmove.metaKey attribute is of type boolean+Pass touchmove.ctrlKey attribute exists check_TouchEvent+Pass touchmove.ctrlKey attribute is of type boolean+Pass touchmove.shiftKey attribute exists check_TouchEvent+Pass touchmove.shiftKey attribute is of type boolean+Pass touchmove: all TouchList lengths are correct+Pass touchmove: all TouchList identifiers matches touchstart identifier+Pass touchmove: event target same as targetTouches target+Pass touchmove: touch pageX/pageY inside of one of the target elements+Pass touchmove: touch clientX/clientY is consistent with pageX/pageY+Pass touchmove: touch screenX/screenY pageX/pageY and clientX/clientY values are no less than 0+Pass touchend event is a TouchEvent event+Pass touchend.touches attribute exists check_TouchEvent+Pass touchend.touches attribute is of type TouchList+Pass touchend.touches's touch list is a TouchList object+Pass touchend.touches.TouchList.length attribute exists check_touchList_object+Pass touchend.touches.TouchList.length attribute is of type number (unsigned long)+Pass touchend.touches.TouchList.item attribute exists check_touchList_object+Pass touchend.touches.TouchList.item attribute is of type function+Pass touchend.targetTouches attribute exists check_TouchEvent+Pass touchend.targetTouches attribute is of type TouchList+Pass touchend.targetTouches's touch list is a TouchList object+Pass touchend.targetTouches.TouchList.length attribute exists check_touchList_object+Pass touchend.targetTouches.TouchList.length attribute is of type number (unsigned long)+Pass touchend.targetTouches.TouchList.item attribute exists check_touchList_object+Pass touchend.targetTouches.TouchList.item attribute is of type function+Pass touchend.changedTouches attribute exists check_TouchEvent+Pass touchend.changedTouches attribute is of type TouchList+Pass touchend.changedTouches's touch list is a TouchList object+Pass touchend.changedTouches.TouchList.length attribute exists check_touchList_object+Pass touchend.changedTouches.TouchList.length attribute is of type number (unsigned long)+Pass touchend.changedTouches.TouchList.item attribute exists check_touchList_object+Pass touchend.changedTouches.TouchList.item attribute is of type function+Pass touchend.changedTouches[0]'s touch point is a Touch object+Pass touchend.changedTouches[0].Touch.identifier attribute exists check_Touch_object+Pass touchend.changedTouches[0].Touch.identifier attribute is of type number (long)+Pass touchend.changedTouches[0].Touch.target attribute exists check_Touch_object+Pass touchend.changedTouches[0].Touch.target attribute is of type Element+Pass touchend.changedTouches[0].Touch.screenX attribute exists check_Touch_object+Pass touchend.changedTouches[0].Touch.screenX attribute is of type number (long)+Pass touchend.changedTouches[0].Touch.screenY attribute exists check_Touch_object+Pass touchend.changedTouches[0].Touch.screenY attribute is of type number (long)+Pass touchend.changedTouches[0].Touch.clientX attribute exists check_Touch_object+Pass touchend.changedTouches[0].Touch.clientX attribute is of type number (long)+Pass touchend.changedTouches[0].Touch.clientY attribute exists check_Touch_object+Pass touchend.changedTouches[0].Touch.clientY attribute is of type number (long)+Pass touchend.changedTouches[0].Touch.pageX attribute exists check_Touch_object+Pass touchend.changedTouches[0].Touch.pageX attribute is of type number (long)+Pass touchend.changedTouches[0].Touch.pageY attribute exists check_Touch_object+Pass touchend.changedTouches[0].Touch.pageY attribute is of type number (long)+Pass touchend.altKey attribute exists check_TouchEvent+Pass touchend.altKey attribute is of type boolean+Pass touchend.metaKey attribute exists check_TouchEvent+Pass touchend.metaKey attribute is of type boolean+Pass touchend.ctrlKey attribute exists check_TouchEvent+Pass touchend.ctrlKey attribute is of type boolean+Pass touchend.shiftKey attribute exists check_TouchEvent+Pass touchend.shiftKey attribute is of type boolean+Pass touchend: all TouchList lengths are correct+Pass touchend: touches identifier matches changedTouches identifier+Pass touchend: touch pageX/pageY inside expected element+Pass touchend: touch clientX/clientY is consistent with pageX/pageY+Pass touchend: touch screenX/screenY pageX/pageY and clientX/clientY values are no less than 0\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/touch-events/touch-touchevent-constructor.txt b/Tests/LibWeb/Text/expected/wpt-import/touch-events/touch-touchevent-constructor.txtindex 70ae9ad6989..bcda58b7828 100644--- a/Tests/LibWeb/Text/expected/wpt-import/touch-events/touch-touchevent-constructor.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/touch-events/touch-touchevent-constructor.txt@@ -2,9 +2,9 @@ Harness status: OKFound 5 tests-5 Fail-Fail Touch constructor with insufficient properties-Fail Touch constructor with non-EventTarget target-Fail Touch constructor exists and creates a Touch object with minimum properties-Fail Touch constructor exists and creates a Touch object with requested properties-Fail TouchEvent constructor exists and creates a TouchEvent object with requested properties\ No newline at end of file+5 Pass+Pass Touch constructor with insufficient properties+Pass Touch constructor with non-EventTarget target+Pass Touch constructor exists and creates a Touch object with minimum properties+Pass Touch constructor exists and creates a Touch object with requested properties+Pass TouchEvent constructor exists and creates a TouchEvent object with requested properties\ No newline at end of filediff --git a/Tests/LibWeb/Text/input/UIEvents/pen-primary-on-reentry.html b/Tests/LibWeb/Text/input/UIEvents/pen-primary-on-reentry.htmlnew file mode 100644index 00000000000..7059adb07df--- /dev/null+++ b/Tests/LibWeb/Text/input/UIEvents/pen-primary-on-reentry.html@@ -0,0 +1,17 @@+<!doctype html>+<style>body{margin:0}#target{width:100px;height:100px}</style>+<div id="target"></div>+<script src="../include.js"></script>+<script>+asyncTest(async done => {+ target.addEventListener("pointermove", event => println(`pen ${event.pointerId}: primary=${event.isPrimary}`));+ const first={pointerType:"pen",pointerId:30};+ const second={pointerType:"pen",pointerId:31};+ await internals.mouseEventThroughUIProcess("mousemove",20,20,{pointer:first});+ await internals.mouseEventThroughUIProcess("mousemove",30,30,{pointer:second});+ await internals.mouseEventThroughUIProcess("mouseleave",20,20,{pointer:first});+ await internals.mouseEventThroughUIProcess("mouseleave",30,30,{pointer:second});+ await internals.mouseEventThroughUIProcess("mousemove",30,30,{pointer:second});+ done();+});+</script>diff --git a/Tests/LibWeb/Text/input/UIEvents/pointer-leaves-local-iframe.html b/Tests/LibWeb/Text/input/UIEvents/pointer-leaves-local-iframe.htmlindex 4fffe9c5c3b..ba6cd4440cb 100644--- a/Tests/LibWeb/Text/input/UIEvents/pointer-leaves-local-iframe.html+++ b/Tests/LibWeb/Text/input/UIEvents/pointer-leaves-local-iframe.html@@ -42,8 +42,8 @@println(`touch pointerdown: primary=${event.isPrimary}`);});target.addEventListener("touchstart", event => println(`touchstart: touches=${event.touches.length}`));- target.addEventListener("touchcancel", event =>- println(`touchcancel: touches=${event.touches.length}, changed=${event.changedTouches.length}`)+ target.addEventListener("touchend", event =>+ println(`touchend: touches=${event.touches.length}, changed=${event.changedTouches.length}`));target.addEventListener("click", event => println(`click: ${event.pointerType}`));const first = { pointerType: "touch", pointerId: 21 };diff --git a/Tests/LibWeb/Text/input/UIEvents/touch-compatibility-target-during-capture.html b/Tests/LibWeb/Text/input/UIEvents/touch-compatibility-target-during-capture.htmlnew file mode 100644index 00000000000..d7051b57ac0--- /dev/null+++ b/Tests/LibWeb/Text/input/UIEvents/touch-compatibility-target-during-capture.html@@ -0,0 +1,30 @@+<!doctype html>+<style>body { margin:0 } #parent { width:100px; height:100px } #child { width:50px; height:50px }</style>+<div id="parent"><div id="child"></div></div>+<script src="../include.js"></script>+<script>+asyncTest(async done => {+ const parent = document.getElementById("parent");+ for (const type of ["pointerdown", "pointerup", "touchstart", "touchend", "mousedown", "mouseup", "click"])+ document.addEventListener(type, event => {+ println(`${type}: ${event.target.id}`);+ if (type === "pointerdown")+ parent.setPointerCapture(event.pointerId);+ });+ const tap = () => internals.performActions(JSON.stringify({actions:[{+ type:"pointer", id:"contact", parameters:{pointerType:"touch"},+ actions:[{type:"pointerMove",x:20,y:20},{type:"pointerDown",button:0},{type:"pointerUp",button:0}]+ }]}));+ await tap();+ parent.addEventListener("click", () => {+ const child = parent.firstElementChild;+ child.remove();+ parent.append(child.cloneNode());+ }, {once:true});+ await tap();+ await new Promise(resolve => requestAnimationFrame(resolve));+ await new Promise(resolve => requestAnimationFrame(resolve));+ println(`after replacement: child=${parent.firstElementChild.matches(":hover")}, parent=${parent.matches(":hover")}`);+ done();+});+</script>diff --git a/Tests/LibWeb/Text/input/UIEvents/touch-event-delivery.html b/Tests/LibWeb/Text/input/UIEvents/touch-event-delivery.htmlnew file mode 100644index 00000000000..c74fb6b26cd--- /dev/null+++ b/Tests/LibWeb/Text/input/UIEvents/touch-event-delivery.html@@ -0,0 +1,48 @@+<!doctype html>+<meta charset="utf-8">+<style>body { margin:0 } #a,#b { width:100px; height:100px; position:absolute; top:0 } #b { left:150px }</style>+<div id="a"></div><div id="b"></div>+<script src="../include.js"></script>+<script>+asyncTest(async done => {+ println(`interfaces: ${typeof Touch}, ${typeof TouchList}, ${typeof TouchEvent}`);+ println(`desktop handlers: ${"ontouchstart" in window}, ${"ontouchmove" in document}, ${"ontouchend" in a}`);+ try {+ document.createEvent("TouchEvent");+ println("legacy event factory unexpectedly enabled");+ } catch (error) {+ println(`legacy event factory: ${error.name}`);+ }+ const source = (id, actions) => ({type:"pointer", id, parameters:{pointerType:"touch"}, actions});+ const move = (x, y) => ({type:"pointerMove",x,y});+ const down = {type:"pointerDown",button:0};+ const up = {type:"pointerUp",button:0};+ let initial;+ let mouseEvents = 0;+ for (const type of ["mousedown", "mouseup", "click"])+ document.addEventListener(type, () => ++mouseEvents);+ for (const type of ["touchstart", "touchmove", "touchend", "touchcancel"])+ document.addEventListener(type, event => {+ if (!initial)+ initial = event;+ println(`${type}@${event.target.id}: touches=${event.touches.length}, target=${event.targetTouches.length}, changed=${event.changedTouches.length}, trusted=${event.isTrusted}, composed=${event.composed}`);+ println(` original target=${event.changedTouches[0].target.id}, x=${event.changedTouches[0].clientX}, force=${event.changedTouches[0].force}, radius=${event.changedTouches[0].radiusX},${event.changedTouches[0].radiusY}, control=${event.ctrlKey}`);+ });+ a.addEventListener("touchstart", event => event.preventDefault(), {passive:false});+ await internals.performActions(JSON.stringify({actions:[{type:"key",id:"control",actions:[{type:"keyDown",value:"\uE009"}]}]}));+ await internals.performActions(JSON.stringify({actions:[source("first",[move(20,20),{...down,width:12,height:18,pressure:0.75},move(180,20),up])]}));+ await internals.performActions(JSON.stringify({actions:[{type:"key",id:"control",actions:[{type:"keyUp",value:"\uE009"}]}]}));+ println(`saved snapshot: length=${initial.touches.length}, x=${initial.touches[0].clientX}, force=${initial.touches[0].force}, identity=${initial.touches[0]===initial.changedTouches[0]}`);+ println(`list bounds: ${initial.touches.item(99)}, ${initial.touches[99]}`);+ println(`mouse events after canceled touchstart: ${mouseEvents}`);+ await internals.performActions(JSON.stringify({actions:[+ source("first",[move(20,20),down,move(30,30),{type:"pointerCancel"}]),+ source("second",[move(180,20),down,move(190,30),up]),+ ]}));+ println(`mouse events after canceled contact: ${mouseEvents}`);+ b.addEventListener("touchend", event => event.preventDefault(), {once:true,passive:false});+ await internals.performActions(JSON.stringify({actions:[source("end-canceled",[move(180,20),down,up])]}));+ println(`mouse events after canceled touchend: ${mouseEvents}`);+ done();+});+</script>diff --git a/Tests/LibWeb/Text/input/UIEvents/touch-legacy-hover.html b/Tests/LibWeb/Text/input/UIEvents/touch-legacy-hover.htmlnew file mode 100644index 00000000000..7d6f25340b4--- /dev/null+++ b/Tests/LibWeb/Text/input/UIEvents/touch-legacy-hover.html@@ -0,0 +1,44 @@+<!doctype html>+<style>+body { margin:0 }+#container { position:absolute; width:100px; height:100px }+.target { width:100px; height:100px }+.target:hover { background-color:rgb(0,255,0) }+#container:hover { color:rgb(0,0,255) }+#mouse { position:absolute; left:150px; width:100px; height:100px }+</style>+<div id="container"><div class="target"></div></div><div id="mouse"></div>+<script src="../include.js"></script>+<script>+asyncTest(async done => {+ const frame=()=>new Promise(resolve=>requestAnimationFrame(resolve));+ const container=document.getElementById("container");+ const target=container.firstElementChild;+ await internals.mouseEventThroughUIProcess("mousemove",180,20);+ const nativeBoundaries=[];+ for (const type of ["pointerover","pointerout"])+ document.addEventListener(type,event=>{if(event.pointerType==="mouse")nativeBoundaries.push(type)});+ for (const type of ["mouseover","mousemove","mousedown","mouseup","click"])+ container.addEventListener(type,event=>println(`${type}: hover=${event.target.matches(":hover")}, color=${getComputedStyle(event.target).backgroundColor}`),true);+ const source=(id,actions)=>({type:"pointer",id,parameters:{pointerType:"touch"},actions});+ const move=(x,y)=>({type:"pointerMove",x,y});+ const down={type:"pointerDown",button:0},up={type:"pointerUp",button:0};+ const tap=()=>internals.performActions(JSON.stringify({actions:[source("tap",[move(20,20),down,up])]}));+ await tap();+ await frame();+ await frame();+ println(`sticky hover: ${target.matches(":hover")}, color=${getComputedStyle(target).backgroundColor}`);+ await internals.mouseEventThroughUIProcess("mousemove",180,20);+ println(`mouse after touch: hover=${mouse.matches(":hover")}, native boundaries=${nativeBoundaries.length}`);+ let clicks=0;+ document.addEventListener("click",()=>++clicks);+ await internals.performActions(JSON.stringify({actions:[source("one",[move(20,20),down,up]),source("two",[move(180,20),down,up])]}));+ println(`multi-touch clicks: ${clicks}`);+ target.addEventListener("click",()=>{target.remove();container.appendChild(target.cloneNode())},{once:true});+ await tap();+ await frame();+ await frame();+ println(`after replacement: child=${container.firstElementChild.matches(":hover")}, parent=${container.matches(":hover")}, color=${getComputedStyle(container).color}`);+ done();+});+</script>diff --git a/Tests/LibWeb/Text/input/UIEvents/touch-origin-across-local-frames.html b/Tests/LibWeb/Text/input/UIEvents/touch-origin-across-local-frames.htmlnew file mode 100644index 00000000000..24bec6c1a32--- /dev/null+++ b/Tests/LibWeb/Text/input/UIEvents/touch-origin-across-local-frames.html@@ -0,0 +1,113 @@+<!doctype html>+<meta charset="utf-8" />+<style>+ body {+ margin: 0;+ }+ iframe,+ #parent {+ position: absolute;+ top: 30px;+ width: 100px;+ height: 100px;+ border: 0;+ }+ #first {+ left: 40px;+ }+ #parent {+ left: 180px;+ }+ #other {+ position: absolute;+ left: 180px;+ top: 150px;+ width: 100px;+ height: 100px;+ }+ #second {+ left: 320px;+ }+</style>+<iframe id="first" srcdoc="<style>body{margin:0}div{width:100px;height:100px}</style><div id='child'></div>"></iframe>+<div id="parent"></div>+<div id="other"></div>+<iframe+ id="second"+ srcdoc="<style>body{margin:0}div{width:100px;height:100px}</style><div id='sibling'></div>"+></iframe>+<script src="../include.js"></script>+<script>+ asyncTest(async done => {+ const frames = [...document.querySelectorAll("iframe")];+ for (const frame of frames) {+ if (!frame.contentDocument.querySelector("div")) await new Promise(resolve => (frame.onload = resolve));+ }+ const documents = [document, ...frames.map(frame => frame.contentDocument)];+ const names = ["parent", "child", "sibling"];+ const touches = [];+ const pointerTargets = [];+ let mouseEvents = 0;+ let primary;+ for (const [index, owner] of documents.entries()) {+ owner.addEventListener("pointerdown", event => {+ event.target.releasePointerCapture(event.pointerId);+ primary = event.isPrimary;+ });+ for (const type of ["pointermove", "pointerup"])+ owner.addEventListener(type, event => pointerTargets.push(`${type}@${event.target.id}`));+ for (const type of ["touchstart", "touchmove", "touchend", "touchcancel"]) {+ owner.addEventListener(+ type,+ event => {+ const touch = event.changedTouches[0];+ touches.push(+ `${names[index]}:${type}@${event.target.id}/${touch.target.id}:${touch.clientX},${touch.clientY}:${event.touches.length}`+ );+ if (type === "touchstart") event.preventDefault();+ },+ { passive: false }+ );+ }+ for (const type of ["mousedown", "mouseup", "click"]) owner.addEventListener(type, () => ++mouseEvents);+ }+ const send = (type, x, y, id) =>+ internals.mouseEventThroughUIProcess(type, x, y, {+ pointer: { pointerType: "touch", pointerId: id },+ buttons: type === "mouseup" ? 0 : 1,+ });+ const contact = async (label, id, start, end) => {+ touches.length = 0;+ await send("mousedown", ...start, id);+ await send("mousemove", ...end, id);+ await send("mouseup", ...end, id);+ println(`${label}: ${touches.join("; ")}`);+ };+ // NB: Releasing implicit Pointer capture must not change the Touch event's starting document or target.+ await contact("parent to child", 31, [205, 55], [65, 55]);+ await contact("child to parent", 32, [65, 55], [205, 55]);+ await contact("child to sibling", 33, [65, 55], [345, 55]);+ pointerTargets.length = 0;+ await contact("same document", 36, [205, 55], [205, 175]);+ println(`released Pointer targets: ${pointerTargets.join("; ")}`);+ touches.length = 0;+ await send("mousedown", 65, 55, 37);+ frames[0].style.display = "none";+ await send("mousemove", 205, 55, 37);+ await send("mouseup", 205, 55, 37);+ println(`hidden child: ${touches.join("; ")}`);+ frames[0].style.display = "";+ touches.length = 0;+ await send("mousedown", 65, 55, 34);+ frames[0].remove();+ await send("mousemove", 205, 55, 34);+ await send("mouseup", 205, 55, 34);+ println(`removed child: ${touches.join("; ")}`);+ touches.length = 0;+ await send("mousedown", 205, 55, 35);+ await send("mouseup", 205, 55, 35);+ println(`next contact: primary=${primary}, ${touches.join("; ")}`);+ println(`compatibility mouse events: ${mouseEvents}`);+ done();+ });+</script>diff --git a/Tests/LibWeb/Text/input/UIEvents/touch-target-retained-across-gc.html b/Tests/LibWeb/Text/input/UIEvents/touch-target-retained-across-gc.htmlnew file mode 100644index 00000000000..d774d7ebc84--- /dev/null+++ b/Tests/LibWeb/Text/input/UIEvents/touch-target-retained-across-gc.html@@ -0,0 +1,23 @@+<!doctype html>+<style>body{margin:0}#target{width:100px;height:100px}</style>+<div id="target"></div>+<script src="../include.js"></script>+<script>+asyncTest(async done => {+ let target = document.getElementById("target");+ for (const type of ["touchstart", "touchmove", "touchend"])+ target.addEventListener(type, event => {+ println(`${type}: target=${event.target.id}, connected=${event.target.isConnected}, touches=${event.touches.length}`);+ if (type === "touchstart") {+ event.preventDefault();+ event.target.remove();+ target = null;+ }+ }, {passive:false});+ const send = actions => internals.performActions(JSON.stringify({actions:[{type:"pointer",id:"contact",parameters:{pointerType:"touch"},actions}]}));+ await send([{type:"pointerMove",x:20,y:20},{type:"pointerDown",button:0}]);+ internals.gc();+ await send([{type:"pointerMove",x:30,y:30},{type:"pointerUp",button:0}]);+ done();+});+</script>diff --git a/Tests/LibWeb/Text/input/UIEvents/touch-target-retargeting.html b/Tests/LibWeb/Text/input/UIEvents/touch-target-retargeting.htmlnew file mode 100644index 00000000000..0b98d42df7f--- /dev/null+++ b/Tests/LibWeb/Text/input/UIEvents/touch-target-retargeting.html@@ -0,0 +1,24 @@+<!doctype html>+<script src="../include.js"></script>+<script>+test(() => {+ const host = document.createElement("div");+ document.body.append(host);+ const root = host.attachShadow({mode:"closed"});+ const target = document.createElement("div");+ root.append(target);+ const original = new Touch({identifier:1,target,clientX:12.5});+ const event = new TouchEvent("touchstart", {bubbles:true, composed:true, touches:[original], targetTouches:[original], changedTouches:[original]});+ let inside;+ target.addEventListener("touchstart", event => {+ inside = event.touches;+ println(`inside: ${event.touches[0].target === target}, ${event.touches[0] === event.changedTouches[0]}`);+ });+ host.addEventListener("touchstart", event => {+ println(`outside: ${event.touches[0].target === host}, ${event.touches[0] === event.changedTouches[0]}, ${event.touches[0].clientX}`);+ println(`saved inside snapshot: ${inside[0].target === target}`);+ });+ target.dispatchEvent(event);+ println(`original: ${original.target === target}`);+});+</script>diff --git a/Tests/LibWeb/Text/input/wpt-import/touch-events/multi-touch-interactions.html b/Tests/LibWeb/Text/input/wpt-import/touch-events/multi-touch-interactions.htmlnew file mode 100644index 00000000000..ad4357b0bd4--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/touch-events/multi-touch-interactions.html@@ -0,0 +1,52 @@+<!DOCTYPE HTML>+<html>+<!--+ Test cases for Touch Events v1 Recommendation+ http://www.w3.org/TR/touch-events/++ These tests are based on Mozilla-Nokia-Google's single-touch+ tests and to some extent Olli Pettay's multi-touch tests.++ The primary purpose of the tests in this document is checking that the interactions+ of various Touch events are correctly implemented under any touch patterns.++ This document references Test Assertions (abbrev TA below) written by Cathy Chan+ http://www.w3.org/2010/webevents/wiki/TestAssertions+-->++<head>+<title>Touch Events Multi-Touch Interaction Test</title>+<meta name="viewport" content="width=device-width">+<script src="../resources/testharness.js"></script>+<script src="../resources/testharnessreport.js"></script>+<script src="../resources/testdriver.js"></script>+<script src="../resources/testdriver-actions.js"></script>+<script src="../resources/testdriver-vendor.js"></script>+<script src="multi-touch-interactions.js"></script>+<style>+ div {+ margin: 0em;+ padding: 1.5em;+ }+ #target0 {+ background: yellow;+ border: 1px solid orange;+ }+ #target1 {+ background: lightblue;+ border: 1px solid blue;+ }+</style>+</head>+<body onload="run()">+ <h1>Touch Events: Multi-Touch Interaction Test</h1>+ <div id="target0">+ Touch this box with one finger, then another one...+ </div>+ <div id="target1">+ ...then drag to this box, then touch with a third finger, and lift all your fingers.+ </div>+ <div id="debug"></div>+ <div id="log"></div>+</body>+</html>diff --git a/Tests/LibWeb/Text/input/wpt-import/touch-events/multi-touch-interactions.js b/Tests/LibWeb/Text/input/wpt-import/touch-events/multi-touch-interactions.jsnew file mode 100644index 00000000000..9b883ef7e01--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/touch-events/multi-touch-interactions.js@@ -0,0 +1,392 @@+setup({explicit_done: true});++var debug = document.getElementById("debug");++function debug_print (x) {+/* uncomment below statement to show debug messages */+// document.getElementById("debug").innerHTML += x;+}++var starting_elements = {};++function check_list_subset_of_targetlist(list, list_name, targetlist, targetlist_name) {+ var exist_in_targetlist;+ for(i=0; i<list.length; i++) {+ exist_in_targetlist=false;+ for(j=0; j<targetlist.length; j++)+ if(list.item(i).identifier==targetlist.item(j).identifier)+ exist_in_targetlist=true;++ assert_true(exist_in_targetlist, list_name + ".item("+i+") exists in " + targetlist_name);+ }+}++function check_list_subset_of_two_targetlists(list, list_name, targetlist1, targetlist1_name, targetlist2, targetlist2_name) {+ var exist_in_targetlists;+ for(i=0; i<list.length; i++) {+ exist_in_targetlists=false;+ for(j=0; j<targetlist1.length; j++)+ if(list.item(i).identifier==targetlist1.item(j).identifier)+ exist_in_targetlists=true;++ if(!exist_in_targetlists)+ for(j=0; j<targetlist2.length; j++)+ if(list.item(i).identifier==targetlist2.item(j).identifier)+ exist_in_targetlists=true;++ assert_true(exist_in_targetlists, list_name + ".item("+i+") exists in " + targetlist1_name + " or " + targetlist2_name);+ }++}++function is_at_least_one_item_in_targetlist(list, targetlist) {+ for(i=0; i<list.length; i++)+ for(j=0; j<targetlist.length; j++)+ if(list.item(i).identifier==targetlist.item(j).identifier)+ return true;++ return false;+}++function check_no_item_in_targetlist(list, list_name, targetlist, targetlist_name) {+ for(i=0; i<list.length; i++)+ for(j=0; j<targetlist.length; j++) {+ assert_false(list.item(i).identifier==targetlist.item(j).identifier, list_name + ".item("+i+") exists in " + targetlist_name);+ return;+ }+}++function check_targets(list, target) {+ for(i=0; i<list.length; i++)+ assert_true(list.item(i).target==target, "item(" + i + ").target is element receiving event");+}++function check_starting_elements(list) {+ for (i=0; i<list.length; i++) {+ assert_equals(list.item(i).target, starting_elements[list.item(i).identifier], "item(" + i + ").target matches starting element");+ }+}++function run() {+ var target0 = document.getElementById("target0");+ var target1 = document.getElementById("target1");++ var test_touchstart = async_test("touchstart event received");+ var test_touchmove = async_test("touchmove event received");+ var test_touchend = async_test("touchend event received");+ var test_mousedown = async_test("Interaction with mouse events");++ var touchstart_received = 0;+ var touchmove_received = 0;+ var touchend_received = 0;+ var touchstart_identifier;++ // last received touch lists for comparison+ var last_touches;+ var last_targetTouches={};+ var last_changedTouches={};++ var actions_promise;++ on_event(window, "touchstart", function onTouchStart(ev) {+ // process event only if it's targeted at target0 or target1+ if(ev.target != target0 && ev.target != target1 )+ return;++ ev.preventDefault();++ if(!touchstart_received) {+ // Check event ordering TA: 1.6.1+ test_touchstart.step(function() {+ assert_equals(touchmove_received, 0, "touchstart precedes touchmove");+ assert_equals(touchend_received, 0, "touchstart precedes touchend");+ });+ test_touchstart.done();+ test_mousedown.done(); // If we got here, then the mouse event test is not needed.+ }+ touchstart_received++;++ // TA: 1.3.2.2, 1.3.2.4+ test(function() {+ assert_true(ev.changedTouches.length >= 1, "changedTouches.length is at least 1");+ assert_true(ev.changedTouches.length <= ev.touches.length, "changedTouches.length is smaller than touches.length");+ check_list_subset_of_targetlist(ev.changedTouches, "changedTouches", ev.touches, "touches");+ }, "touchstart #" + touchstart_received + ": changedTouches is a subset of touches");++ // TA: 1.3.3.2, 1.3.3.3+ test(function() {+ assert_true(ev.targetTouches.length >= 1, "targetTouches.length is at least 1");+ assert_true(ev.targetTouches.length <= ev.touches.length, "targetTouches.length is smaller than touches.length");+ check_list_subset_of_targetlist(ev.targetTouches, "targetTouches", ev.touches, "touches");+ }, "touchstart #" + touchstart_received + ": targetTouches is a subset of touches");++ // TA: 1.3.3.9+ test(function() {+ check_targets(ev.targetTouches, ev.target);+ }, "touchstart #" + touchstart_received + ": targets of targetTouches are correct");++ // TA: 1.3.4.2+ test(function() {+ assert_true(ev.touches.length >= 1, "touches.length is at least 1");+ }, "touchstart #" + touchstart_received + ": touches.length is valid");++ if(touchstart_received == 1) {+ // TA: 1.3.3.5, 1.3.3.7+ test(function() {+ assert_true(ev.targetTouches.length <= ev.changedTouches.length, "targetTouches.length is smaller than changedTouches.length");+ check_list_subset_of_targetlist(ev.targetTouches, "targetTouches", ev.changedTouches, "changedTouches");+ }, "touchstart #" + touchstart_received + ": targetTouches is a subset of changedTouches");++ // TA: 1.3.4.3+ test(function() {+ assert_equals(ev.touches.length, ev.changedTouches.length, "touches and changedTouches have the same length");+ }, "touchstart #" + touchstart_received + ": touches and changedTouches have the same length");+ } else {+ // TA: 1.3.3.6+ test(function() {+ var diff_in_targetTouches = ev.targetTouches.length - (last_targetTouches[ev.target.id] ? last_targetTouches[ev.target.id].length : 0);+ assert_true(diff_in_targetTouches > 0, "targetTouches.length is larger than last received targetTouches.length");+ assert_true(diff_in_targetTouches <= ev.changedTouches.length, "change in targetTouches.length is smaller than changedTouches.length");+ }, "touchstart #" + touchstart_received + ": change in targetTouches.length is valid");++ // TA: 1.3.3.8+ test(function() {+ assert_true(is_at_least_one_item_in_targetlist(ev.targetTouches, ev.changedTouches), "at least one item of targetTouches is in changedTouches");+ }, "touchstart #" + touchstart_received + ": at least one targetTouches item in changedTouches");++ // TA: 1.3.4.4+ test(function() {+ var diff_in_touches = ev.touches.length - last_touches.length;+ assert_true(diff_in_touches > 0, "touches.length is larger than last received touches.length");+ assert_equals(diff_in_touches, ev.changedTouches.length, "change in touches.length equals changedTouches.length");+ }, "touchstart #" + touchstart_received + ": change in touches.length is valid");++ // TA: 1.3.4.5+ test(function() {+ check_list_subset_of_two_targetlists(ev.touches, "touches", ev.changedTouches, "changedTouches", last_touches, "last touches");+ }, "touchstart #" + touchstart_received + ": touches is subset of {changedTouches, last received touches}");+ }++ // save starting element of each new touch point+ for (i=0; i<ev.changedTouches.length; i++) {+ starting_elements[ev.changedTouches.item(i).identifier] = ev.changedTouches.item(i).target;+ }++ last_touches = ev.touches;+ last_targetTouches[ev.target.id] = ev.targetTouches;+ last_changedTouches = {}; // changedTouches are only saved for touchend events+ });++ on_event(window, "touchmove", function onTouchMove(ev) {+ // process event only if it's targeted at target0 or target1+ if(ev.target != target0 && ev.target != target1 )+ return;++ ev.preventDefault();++ // TA: 1.6.1+ test_touchmove.step(function() {+ assert_true(touchstart_received>0, "touchmove follows touchstart");+ // assert_false(touchend_received, "touchmove precedes touchend"); // this applies to scenario tests+ });+ test_touchmove.done();++ touchmove_received++;++ // do the detailed checking only for a few times+ if(touchmove_received<6) {+ // TA: 1.4.2.2, 1.4.2.4+ test(function() {+ assert_true(ev.changedTouches.length >= 1, "changedTouches.length is at least 1");+ assert_true(ev.changedTouches.length <= ev.touches.length, "changedTouches.length is smaller than touches.length");+ check_list_subset_of_targetlist(ev.changedTouches, "changedTouches", ev.touches, "touches");+ }, "touchmove #" + touchmove_received + ": changedTouches is a subset of touches");++ // TA: 1.4.3.2, 1.4.3.4+ test(function() {+ assert_true(ev.targetTouches.length >= 1, "targetTouches.length is at least 1");+ assert_true(ev.targetTouches.length <= ev.touches.length, "targetTouches.length is smaller than touches.length");+ check_list_subset_of_targetlist(ev.targetTouches, "targetTouches", ev.touches, "touches");+ }, "touchmove #" + touchmove_received + ": targetTouches is a subset of touches");++ // TA: 1.4.3.6+ test(function() {+ assert_true(is_at_least_one_item_in_targetlist(ev.targetTouches, ev.changedTouches), "at least one item of targetTouches is in changedTouches");+ }, "touchmove #" + touchmove_received + ": at least one targetTouches item in changedTouches");++ // TA: 1.4.3.8+ test(function() {+ check_targets(ev.targetTouches, ev.target);+ }, "touchmove #" + touchmove_received + ": targets of targetTouches are correct");++ // TA: 1.4.4.2+ test(function() {+ assert_equals(ev.touches.length, last_touches.length, "length of touches is same as length of last received touches");+ check_list_subset_of_targetlist(ev.touches, "touches", last_touches, "last received touches");+ }, "touchmove #" + touchmove_received + ": touches must be same as last received touches");++ // TA: 1.6.3+ check_starting_elements(ev.changedTouches);+ }++ last_touches = ev.touches;+ last_targetTouches[ev.target.id] = ev.targetTouches;+ last_changedTouches = {}; // changedTouches are only saved for touchend events+ });++ on_event(window, "touchend", function onTouchEnd(ev) {+ // process event only if it's targeted at target0 or target1+ if(ev.target != target0 && ev.target != target1 )+ return;++ test_touchend.step(function() {+ assert_true(touchstart_received>0, "touchend follows touchstart");+ });+ test_touchend.done();++ touchend_received++;++ debug_print("touchend #" + touchend_received + ":<br>");+ debug_print("changedTouches.length=" + ev.changedTouches.length + "<br>");+ debug_print("targetTouches.length=" + ev.targetTouches.length + "<br>");+ debug_print("touches.length=" + ev.touches.length + "<br>");+ for(i=0; i<ev.changedTouches.length; i++)+ debug_print("changedTouches.item(" + i + ").target=" + ev.changedTouches.item(i).target.id + "<br>");++ // TA: 1.5.2.2+ test(function() {+ assert_true(ev.changedTouches.length >= 1, "changedTouches.length is at least 1");+ }, "touchend #" + touchend_received + ": length of changedTouches is valid");++ // TA: 1.5.2.3+ test(function() {+ check_list_subset_of_targetlist(ev.changedTouches, "changedTouches", last_touches, "last received touches");+ }, "touchend #" + touchend_received + ": changedTouches is a subset of last received touches");++ // TA: 1.5.2.4, 1.5.2.5+ test(function() {+ check_no_item_in_targetlist(ev.changedTouches, "changedTouches", ev.touches, "touches");+ check_no_item_in_targetlist(ev.changedTouches, "changedTouches", ev.targetTouches, "targetTouches");+ }, "touchend #" + touchend_received + ": no item in changedTouches are in touches or targetTouches");++ // TA: 1.5.2.6+ test(function() {+ var found=false;+ for (i=0; i<ev.changedTouches.length; i++)+ if (ev.changedTouches.item(i).target == ev.target)+ found=true;+ assert_true(found, "at least one item in changedTouches has matching target");+ }, "touchend #" + touchend_received + ": at least one item in changedTouches targeted at this element");++ // TA: 1.5.3.2, 1.5.3.3+ test(function() {+ assert_true(ev.targetTouches.length >= 0, "targetTouches.length is non-negative");+ assert_true(ev.targetTouches.length <= ev.touches.length, "targetTouches.length is smaller than touches.length");+ check_list_subset_of_targetlist(ev.targetTouches, "targetTouches", ev.touches, "touches");+ }, "touchend #" + touchend_received + ": targetTouches is a subset of touches");++ // TA: 1.5.3.5 (new)+ test(function() {+ check_targets(ev.targetTouches, ev.target);+ }, "touchend #" + touchend_received + ": targets of targetTouches are correct");++ // In some cases, when multiple touch points are released simultaneously+ // the UA would dispatch the "same" touchend event (same changedTouches, same touches, but possibly different targetTouches)+ // to each of the elements that are starting elements of the released touch points.+ // in these situations, the subsequent events are exempt from TA 1.5.3.4 and 1.5.4.2+ var same_event_as_last = false;+ if (last_changedTouches && last_changedTouches.length==ev.changedTouches.length) {+ same_event_as_last = true; // assume true until proven otherwise+ for (i=0; i<last_changedTouches.length; i++) {+ var match = false;+ for (j=0; j<ev.changedTouches.length; j++)+ if (last_changedTouches.item(i) == ev.changedTouches.item(j)) {+ match = true;+ break;+ }+ if (!match)+ same_event_as_last = false;+ }+ }++ if (!same_event_as_last) {+ // TA: 1.5.3.4+ // Getting semi-random failures on this and 1.5.4.2.+ // See 1.5.4.2. Not sure if it's the same issue...+ test(function() {+ assert_true(last_targetTouches[ev.target.id].length > 0, "last received targetTouches.length is not zero");+ var diff_in_targetTouches = last_targetTouches[ev.target.id].length - ev.targetTouches.length;+ debug_print("diff_in_targetTouches=" + diff_in_targetTouches + "<br>");+ assert_true(diff_in_targetTouches > 0, "targetTouches.length is smaller than last received targetTouches.length");+ assert_true(diff_in_targetTouches <= ev.changedTouches.length, "change in targetTouches.length is smaller than changedTouches.length");+ }, "touchend #" + touchend_received + ": change in targetTouches.length is valid");++ // TA: 1.5.4.2+ // Getting semi-random failures on this and 1.5.3.4.+ // It looks like if fingers are lifted simultaneously, the "same" touchend event can be dispatched to two target elements+ // but adapted to the element (same touches, changedTouches but different targetTouches).+ // When one event is processed after another, ev.touches would end up being identical to last_touches, leading to failure.+ // Question is why done() does not stop the processing of the latter event.+ test(function() {+ assert_true(last_touches.length > 0, "last received touches.length is not zero");+ var diff_in_touches = last_touches.length - ev.touches.length;+ debug_print("diff_in_touches=" + diff_in_touches + "<br>");+ assert_true(diff_in_touches > 0, "touches.length is smaller than last received touches.length");+ assert_equals(diff_in_touches, ev.changedTouches.length, "change in touches.length equals changedTouches.length");+ }, "touchend #" + touchend_received + ": change in touches.length is valid");+ }++ // TA: 1.6.4+ debug_print("touchend #" + touchend_received + ": TA 1.6.4<br>");+ test(function() {+ check_starting_elements(ev.changedTouches);+ }, "touchend #" + touchend_received + ": event dispatched to correct element<br>");++ debug_print("touchend #" + touchend_received + ": saving touch lists<br>");++ last_touches = ev.touches;+ last_targetTouches[ev.target.id] = ev.targetTouches;+ last_changedTouches = ev.changedTouches;++ debug_print("touchend #" + touchend_received + ": done<br>");+ if(ev.touches.length==0)+ actions_promise.then( () => done() );+ });++ on_event(target0, "mousedown", function onMouseDown(ev) {+ test_mousedown.step(function() {+ assert_true(touchstart_received,+ "The touchstart event must be dispatched before any mouse " ++ "events. (If this fails, it might mean that the user agent does " ++ "not implement W3C touch events at all.)"+ );+ });+ test_mousedown.done();++ if (!touchstart_received) {+ // Abort the tests. If touch events are not supported, then most of+ // the other event handlers will never be called, and the test will+ // time out with misleading results.+ done();+ }+ });++ actions_promise = new test_driver.Actions()+ .addPointer("touchPointer1", "touch")+ .addPointer("touchPointer2", "touch")+ .addPointer("touchPointer3", "touch")+ .pointerMove(0, 0, {origin: target0, sourceName: "touchPointer1"})+ .pointerMove(3, 0, {origin: target0, sourceName: "touchPointer2"})+ .pointerDown({sourceName: "touchPointer1"})+ .pointerDown({sourceName: "touchPointer2"})+ .pointerMove(0, 10, {origin: target0, sourceName: "touchPointer1"})+ .pointerMove(3, 10, {origin: target0, sourceName: "touchPointer2"})+ .pointerMove(0, 0, {origin: target1, sourceName: "touchPointer1"})+ .pointerMove(3, 0, {origin: target1, sourceName: "touchPointer2"})+ .pointerMove(6, 0, {origin: target0, sourceName: "touchPointer3"})+ .pointerDown({sourceName: "touchPointer3"})+ .pointerUp({sourceName: "touchPointer1"})+ .pointerUp({sourceName: "touchPointer2"})+ .pointerUp({sourceName: "touchPointer3"})+ .send();+}diff --git a/Tests/LibWeb/Text/input/wpt-import/touch-events/multi-touch-interfaces.html b/Tests/LibWeb/Text/input/wpt-import/touch-events/multi-touch-interfaces.htmlnew file mode 100644index 00000000000..4195e4ec797--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/touch-events/multi-touch-interfaces.html@@ -0,0 +1,295 @@+<!DOCTYPE HTML>+<html>+<!--+ Test cases for Touch Events v1 Recommendation+ http://www.w3.org/TR/touch-events/++ These tests are based on Mozilla-Nokia-Google's single-touch+ tests and to some extent Olli Pettay's multi-touch tests.++ The primary purpose of the tests in this document is checking that the+ various interfaces of the Touch Events APIs are correctly implemented.+ Other interactions are covered in other test files.++ This document references Test Assertions (abbrev TA below) written by Cathy Chan+ http://www.w3.org/2010/webevents/wiki/TestAssertions+-->++<head>+<title>Touch Events Multi-Touch Interface Tests</title>+<meta name="viewport" content="width=device-width">+<script src="../resources/testharness.js"></script>+<script src="../resources/testharnessreport.js"></script>+<script src="../resources/testdriver.js"></script>+<script src="../resources/testdriver-actions.js"></script>+<script src="../resources/testdriver-vendor.js"></script>+<script>+ setup({explicit_done: true});++ // Check a Touch object's atttributes for existence and correct type+ // TA: 1.1.2, 1.1.3+ function check_Touch_object (t, element) {+ test(function() {+ assert_equals(Object.prototype.toString.call(t), "[object Touch]", "touch is of type Touch");+ }, element + "'s touch point is a Touch object");+ [+ ["long", "identifier"],+ ["EventTarget", "target"],+ ["long", "screenX"],+ ["long", "screenY"],+ ["long", "clientX"],+ ["long", "clientY"],+ ["long", "pageX"],+ ["long", "pageY"],+ ].forEach(function(attr) {+ var type = attr[0];+ var name = attr[1];++ // existence check+ test(function() {+ assert_true(name in t, name + " attribute in Touch object");+ }, element + ".Touch." + name + " attribute exists");++ // type check+ switch(type) {+ case "long":+ test(function() {+ assert_equals(typeof t[name], "number", name + " attribute of type long");+ }, element + ".Touch." + name + " attribute is of type number (long)");+ break;+ case "EventTarget":+ // An event target is some type of Element+ test(function() {+ assert_true(t[name] instanceof Element, "EventTarget must be an Element.");+ }, element + ".Touch." + name + " attribute is of type Element");+ break;+ default:+ break;+ }+ });+ }++ // Check a TouchList object's attributes and methods for existence and proper type+ // Also make sure all of the members of the list are Touch objects+ // TA: 1.2.1, 1.2.2, 1.2.5, 1.2.6+ function check_TouchList_object (tl, element) {+ test(function() {+ assert_equals(Object.prototype.toString.call(tl), "[object TouchList]", "touch list is of type TouchList");+ }, element + "'s touch list is a TouchList object");+ [+ ["unsigned long", "length"],+ ["function", "item"],+ ].forEach(function(attr) {+ var type = attr[0];+ var name = attr[1];++ // existence check+ test(function() {+ assert_true(name in tl, name + " attribute in TouchList");+ }, element + ".TouchList." + name + " attribute exists");++ // type check+ switch(type) {+ case "unsigned long":+ test(function() {+ assert_equals(typeof tl[name], "number", name + " attribute of type long");+ }, element + ".TouchList." + name + " attribute is of type number (unsigned long)");+ break;+ case "function":+ test(function() {+ assert_equals(typeof tl[name], "function", name + " attribute of type function");+ }, element + ".TouchList." + name + " attribute is of type function");+ break;+ default:+ break;+ }+ });+ // Each member of tl should be a proper Touch object+ for (var i=0; i < tl.length; i++) {+ check_Touch_object(tl.item(i), element + "[" + i + "]");+ }+ }++ // Check a TouchEvent event's attributes for existence and proper type+ // Also check that each of the event's TouchList objects are valid+ // TA: 1.{3,4,5}.1.1, 1.{3,4,5}.1.2+ function check_TouchEvent(ev, touchstart_count) {+ test(function() {+ assert_true(ev instanceof TouchEvent, "event is a TouchEvent event");+ }, ev.type + touchstart_count + " event is a TouchEvent event");+ [+ ["TouchList", "touches"],+ ["TouchList", "targetTouches"],+ ["TouchList", "changedTouches"],+ ["boolean", "altKey"],+ ["boolean", "metaKey"],+ ["boolean", "ctrlKey"],+ ["boolean", "shiftKey"],+ ].forEach(function(attr) {+ var type = attr[0];+ var name = attr[1];++ // existence check+ test(function() {+ assert_true(name in ev, name + " attribute in " + ev.type + " event");+ }, ev.type + touchstart_count + "." + name + " attribute exists");++ // type check+ switch(type) {+ case "boolean":+ test(function() {+ assert_equals(typeof ev[name], "boolean", name + " attribute of type boolean");+ }, ev.type + touchstart_count + "." + name + " attribute is of type boolean");+ break;+ case "TouchList":+ test(function() {+ assert_equals(Object.prototype.toString.call(ev[name]), "[object TouchList]", name + " attribute of type TouchList");+ }, ev.type + touchstart_count + "." + name + " attribute is of type TouchList");+ // Now check the validity of the TouchList+ check_TouchList_object(ev[name], ev.type + touchstart_count + "." + name);+ break;+ default:+ break;+ }+ });+ }++ function is_touch_over_element(touch, element) {+ var bounds = element.getBoundingClientRect();+ return touch.pageX >= bounds.left && touch.pageX <= bounds.right &&+ touch.pageY >= bounds.top && touch.pageY <= bounds.bottom;+ }++ function check_touch_clientXY(touch) {+ assert_equals(touch.clientX, touch.pageX - window.pageXOffset, "touch.clientX is touch.pageX - window.pageXOffset.");+ assert_equals(touch.clientY, touch.pageY - window.pageYOffset, "touch.clientY is touch.pageY - window.pageYOffset.");+ }++ async function run() {+ var target0 = document.getElementById("target0");+ var target1 = document.getElementById("target1");++ var test_touchstart = async_test("touchstart event received");+ var test_touchmove = async_test("touchmove event received");+ var test_touchend = async_test("touchend event received");+ var test_mousedown = async_test("Interaction with mouse events");++ var touchstart_received = 0;+ var touchmove_received = 0;+ var touchend_received = false;+ var invalid_touchmove_received = false;++ on_event(target0, "touchstart", function onTouchStart(ev) {+ ev.preventDefault();++ if(!touchstart_received) {+ // Check event ordering TA: 1.6.2+ test_touchstart.step(function() {+ assert_true(touchmove_received==0, "touchstart precedes touchmove");+ assert_false(touchend_received, "touchstart precedes touchend");+ });+ test_touchstart.done();+ test_mousedown.done(); // If we got here, then the mouse event test is not needed.+ }++ if(++touchstart_received <= 2)+ check_TouchEvent(ev, touchstart_received);+ });++ on_event(target0, "touchmove", function onTouchMove(ev) {+ ev.preventDefault();++ if(!touchmove_received) {+ test_touchmove.step(function() {+ assert_true(touchstart_received>0, "touchmove follows touchstart");+ assert_false(touchend_received, "touchmove precedes touchend");+ });+ test_touchmove.done();+ }++ if(++touchmove_received <= 2)+ check_TouchEvent(ev, touchmove_received);+ });++ on_event(target1, "touchmove", function onTouchMove(ev) {+ invalid_touchmove_received = true;+ });++ on_event(window, "touchend", function onTouchEnd(ev) {+ touchend_received = true;++ test_touchend.step(function() {+ assert_true(touchstart_received>0, "touchend follows touchstart");+ assert_true(touchmove_received>0, "touchend follows touchmove");+ assert_false(invalid_touchmove_received, "touchmove dispatched to correct target");+ });+ test_touchend.done();++ check_TouchEvent(ev, touchstart_received);+ done();+ });++ on_event(target0, "mousedown", function onMouseDown(ev) {+ test_mousedown.step(function() {+ assert_true(touchstart_received,+ "The touchstart event must be dispatched before any mouse " ++ "events. (If this fails, it might mean that the user agent does " ++ "not implement W3C touch events at all.)"+ );+ });+ test_mousedown.done();++ if (!touchstart_received) {+ // Abort the tests. If touch events are not supported, then most of+ // the other event handlers will never be called, and the test will+ // time out with misleading results.+ done();+ }+ });++ await new test_driver.Actions()+ .addPointer("touchPointer1", "touch")+ .addPointer("touchPointer2", "touch")+ .pointerMove(0, 0, {origin: target0, sourceName: "touchPointer1"})+ .pointerMove(3, 0, {origin: target0, sourceName: "touchPointer2"})+ .pointerDown({sourceName: "touchPointer1"})+ .pointerDown({sourceName: "touchPointer2"})+ .pointerMove(0, 10, {origin: target0, sourceName: "touchPointer1"})+ .pause(10, "pointer", {sourceName: "touchPointer2"})+ .pause(10, "pointer", {sourceName: "touchPointer1"})+ .pointerMove(3, 10, {origin: target0, sourceName: "touchPointer2"})+ .pointerMove(0, 0, {origin: target1, sourceName: "touchPointer1"})+ .pause(10, "pointer", {sourceName: "touchPointer2"})+ .pause(10, "pointer", {sourceName: "touchPointer1"})+ .pointerMove(3, 0, {origin: target1, sourceName: "touchPointer2"})+ .pointerUp({sourceName: "touchPointer1"})+ .pointerUp({sourceName: "touchPointer2"})+ .send();+ }+</script>+<style>+ div {+ margin: 0em;+ padding: 2em;+ }+ #target0 {+ background: yellow;+ border: 1px solid orange;+ }+ #target1 {+ background: lightblue;+ border: 1px solid blue;+ }+</style>+</head>+<body onload="run()">+ <h1>Touch Events: multi-touch interface tests</h1>+ <div id="target0">+ Touch this box with one finger, then another one...+ </div>+ <div id="target1">+ ...then drag to this box and lift your fingers.+ </div>+ <div id="log"></div>+</body>+</html>diff --git a/Tests/LibWeb/Text/input/wpt-import/touch-events/single-touch.html b/Tests/LibWeb/Text/input/wpt-import/touch-events/single-touch.htmlnew file mode 100644index 00000000000..59b73b458a2--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/touch-events/single-touch.html@@ -0,0 +1,437 @@+<!DOCTYPE HTML>+<html>+<!--+ Test cases for Touch Events v1 Recommendation+ http://www.w3.org/TR/touch-events/++ These tests are based on Matt Bruebeck's single-touch tests.+ There are NO multi-touch tests in this document.++ This document references Test Assertions (abbrev TA below) written by Cathy Chan+ http://www.w3.org/2010/webevents/wiki/TestAssertions+-->++<head>+ <title>Touch Events Single Touch Tests</title>+ <meta name="viewport" content="width=device-width">+ <script src="../resources/testharness.js"></script>+ <script src="../resources/testharnessreport.js"></script>+ <script src="../resources/testdriver.js"></script>+ <script src="../resources/testdriver-actions.js"></script>+ <script src="../resources/testdriver-vendor.js"></script>+ <script src="support/touch.js"></script>+++ <script>+ // Check a Touch object's attributes for existence and correct type+ // TA: 1.1.2, 1.1.3+ function check_Touch_object (t, element) {+ test(function() {+ assert_equals(Object.prototype.toString.call(t), "[object Touch]",+ `${name} attribute of type TouchList`);+ }, `${element}'s touch point is a Touch object`);+ [+ ["long", "identifier"],+ ["EventTarget", "target"],+ ["long", "screenX"],+ ["long", "screenY"],+ ["long", "clientX"],+ ["long", "clientY"],+ ["long", "pageX"],+ ["long", "pageY"],+ ].forEach(function(attr) {+ var type = attr[0];+ var name = attr[1];++ // existence check+ test(function() {+ assert_true(name in t, `${name} attribute in Touch object`);+ }, `${element}.Touch.${name} attribute exists check_Touch_object`);++ // type check+ switch(type) {+ case "long":+ test(function() {+ assert_equals(typeof t[name], "number",+ `${name} attribute of type long`);+ }, `${element}.Touch.${name} attribute is of type number (long)`);+ break;++ case "EventTarget":+ // An event target is some type of Element+ test(function() {+ assert_true(t[name] instanceof Element,+ "EventTarget must be an Element.");+ }, `${element}.Touch.${name} attribute is of type Element`);+ break;++ default:+ break;+ }+ });+ }++ // Check a TouchList object's attributes and methods for existence and+ // proper type.+ // Also make sure all of the members of the list are Touch objects+ // TA: 1.2.1, 1.2.2, 1.2.5+ function check_TouchList_object (tl, element) {+ const context = "check_touchList_object";+ const ulong = "number (unsigned long)";+ test(function() {+ assert_equals(Object.prototype.toString.call(tl),+ "[object TouchList]",+ `${name} attribute of type TouchList`);+ }, `${element}'s touch list is a TouchList object`);+ [+ ["unsigned long", "length"],+ ["function", "item"],+ ].forEach(function(attr) {+ var type = attr[0];+ var name = attr[1];++ // existence check+ test(function() {+ assert_true(name in tl, `${name} attribute in TouchList`);+ }, `${element}.TouchList.${name} attribute exists ${context}`);++ // type check+ switch(type) {+ case "unsigned long":+ test(function() {+ assert_equals(typeof tl[name], "number",+ `${name} attribute of type long`);+ }, `${element}.TouchList.${name} attribute is of type ${ulong}`);+ break;++ case "function":+ test(function() {+ assert_equals(typeof tl[name], "function",+ `${name} attribute of type function`);+ }, `${element}.TouchList.${name} attribute is of type function`);+ break;++ default:+ break;+ }+ });++ // Each member of tl should be a proper Touch object+ for (var i=0; i < tl.length; i++) {+ check_Touch_object(tl.item(i), `${element}[${i}]`);+ }+ }++ // Check a TouchEvent event's attributes for existence and proper type+ // Also check that each of the event's TouchList objects are valid+ // TA: 1.{3,4,5}.1.1, 1.{3,4,5}.1.2+ function check_TouchEvent(ev) {+ test(function() {+ assert_true(ev instanceof TouchEvent, "event is a TouchEvent event");+ }, `${ev.type} event is a TouchEvent event`);+ [+ ["TouchList", "touches"],+ ["TouchList", "targetTouches"],+ ["TouchList", "changedTouches"],+ ["boolean", "altKey"],+ ["boolean", "metaKey"],+ ["boolean", "ctrlKey"],+ ["boolean", "shiftKey"],+ ].forEach(function(attr) {+ var type = attr[0];+ var name = attr[1];++ // existence check+ test(function() {+ assert_true(name in ev,+ `${name} attribute in ${ev.type} event`);+ }, `${ev.type}.${name} attribute exists check_TouchEvent`);++ // type check+ switch(type) {+ case "boolean":+ test(function() {+ assert_equals(+ typeof ev[name], "boolean",+ `${name} attribute of type boolean`);+ }, `${ev.type}.${name} attribute is of type boolean`);+ break;++ case "TouchList":+ test(function() {+ assert_equals(+ Object.prototype.toString.call(ev[name]),+ "[object TouchList]",+ `${name} attribute of type TouchList`);+ }, `${ev.type}.${name} attribute is of type TouchList`);+ // Now check the validity of the TouchList+ check_TouchList_object(ev[name], `${ev.type}.${name}`);+ break;++ default:+ break;+ }+ });+ }++ function is_touch_over_element(touch, element) {+ var bounds = element.getBoundingClientRect();+ return touch.pageX >= bounds.left && touch.pageX <= bounds.right &&+ touch.pageY >= bounds.top && touch.pageY <= bounds.bottom;+ }++ function check_touch_clientXY(touch) {+ assert_equals(touch.clientX, touch.pageX - window.pageXOffset,+ "touch.clientX is touch.pageX - window.pageXOffset.");+ assert_equals(touch.clientY, touch.pageY - window.pageYOffset,+ "touch.clientY is touch.pageY - window.pageYOffset.");+ }++ function check_screenXY_clientXY_pageXY(touch) {+ assert_greater_than_equal(touch.screenX, 0,+ "touch.screenX is no less than 0");+ assert_greater_than_equal(touch.screenY, 0,+ "touch.screenY is no less than 0");+ assert_greater_than_equal(touch.clientX, 0,+ "touch.clientX is no less than 0");+ assert_greater_than_equal(touch.clientY, 0,+ "touch.clientY is no less than 0");+ assert_greater_than_equal(touch.pageX, 0,+ "touch.pageX is no less than 0");+ assert_greater_than_equal(touch.pageY, 0,+ "touch.pageY is no less than 0");+ }++ function validateTouchstart(ev) {+ check_TouchEvent(ev);++ // TA: 1.3.2.1, 1.3.3.1, 1.3.4.1+ test(function() {+ assert_equals(ev.touches.length, 1, "One touch point.");+ assert_equals(ev.changedTouches.length, 1,+ "One changed touch point.");+ assert_equals(ev.targetTouches.length, 1, "One target touch point.");+ }, "touchstart: all TouchList lengths are correct");++ var t = ev.touches[0];+ var ct = ev.changedTouches[0];+ var tt = ev.targetTouches[0];++ touchstart_identifier = t.identifier;+ // TA: 1.3.3.3, 1.3.2.3, 1.3.3.4 (indirect (transitive))+ test(function() {+ assert_equals(ct.identifier, touchstart_identifier,+ "changedTouches identifier matches.");+ assert_equals(tt.identifier, touchstart_identifier,+ "targetTouches identifier matches.");+ }, "touchstart: all TouchList identifiers are consistent");++ // TA: 1.3.3.9+ test(function() {+ assert_equals(tt.target, ev.target,+ "event target same as targetTouches target.");+ }, "touchstart: event target same as targetTouches target");++ test(function() {+ assert_true(is_touch_over_element(t, target0),+ "touch.pageX/pageY is over target0.");+ }, "touchstart: touch pageX/pageY inside of target element");+ test(function() {+ check_touch_clientXY(t);+ }, "touchstart: touch clientX/clientY is consistent with pageX/pageY");+ test(function() {+ check_screenXY_clientXY_pageXY(t);+ }, "touchstart: touch screenX/screenY pageX/pageY and " ++ "clientX/clientY values are no less than 0");+ }++ function validateTouchmove(ev) {+ check_TouchEvent(ev);++ // TA: 1.4.2.1, 1.4.3.1+ test(function() {+ assert_equals(ev.touches.length, 1, "One touch point.");+ assert_equals(ev.changedTouches.length, 1, "One changed touch point.");+ assert_equals(ev.targetTouches.length, 1, "One target touch point.");+ }, "touchmove: all TouchList lengths are correct");++ // 1.4.2.3, 1.4.3.3, 1.4.3.5, 1.4.4.3+ test(function() {+ assert_equals(ev.touches[0].identifier, touchstart_identifier,+ "Touch identifier matches.");+ assert_equals(ev.changedTouches[0].identifier, touchstart_identifier,+ "Changed touch identifier matches.");+ assert_equals(ev.targetTouches[0].identifier, touchstart_identifier,+ "Target touch identifier matches.");+ }, "touchmove: all TouchList identifiers matches touchstart identifier");++ // TA: 1.4.3.8+ var tt = ev.targetTouches[0];+ test(function() {+ assert_equals(tt.target, ev.target,+ "event target same as targetTouches target.");+ }, "touchmove: event target same as targetTouches target");++ test(function() {+ assert_true(is_touch_over_element(tt, target0) ||+ is_touch_over_element(tt, target1),+ "touch.pageX/pageY is over one of the targets.");+ }, "touchmove: touch pageX/pageY inside of one of the target elements");++ test(function() {+ check_touch_clientXY(tt);+ }, "touchmove: touch clientX/clientY is consistent with pageX/pageY");++ test(function() {+ check_screenXY_clientXY_pageXY(tt);+ }, "touchmove: touch screenX/screenY pageX/pageY and clientX/clientY " ++ "values are no less than 0");+ }++ function validateTouchend(ev) {+ check_TouchEvent(ev);++ // TA: 1.5.1.2, 1.5.3.1, 1.5.4.1+ test(function() {+ assert_equals(ev.touches.length, 0, "Zero touch points.");+ assert_equals(ev.changedTouches.length, 1, "One changed touch point.");+ assert_equals(ev.targetTouches.length, 0, "Zero target touch points.");+ }, "touchend: all TouchList lengths are correct");++ var t = ev.changedTouches[0];++ // TA: 1.5.2.6, 1.5.2.3+ test(function() {+ assert_equals(t.identifier, touchstart_identifier,+ "changedTouches identifier matches.");+ }, "touchend: touches identifier matches changedTouches identifier");++ test(function() {+ assert_true(is_touch_over_element(t, target1),+ "touch.pageX/pageY is over target1.");+ }, "touchend: touch pageX/pageY inside expected element");++ test(function() {+ check_touch_clientXY(t);+ }, "touchend: touch clientX/clientY is consistent with pageX/pageY");++ test(function() {+ check_screenXY_clientXY_pageXY(t);+ }, "touchend: touch screenX/screenY pageX/pageY and clientX/clientY " ++ "values are no less than 0");+ }++ function createEventPromise(eventType) {+ const target0 = document.getElementById("target0");+ const doneButton = document.getElementById('done');+ return new Promise((resolve, reject) => {+ doneButton.addEventListener('click', reject, { once: true });+ target0.addEventListener(eventType, event => {+ doneButton.removeEventListener('click', reject);+ resolve(event);+ }, { once: true });+ });+ }++ async function run() {+ await waitTillReadyForTouchInput();++ const target0 = document.getElementById("target0");+ const target1 = document.getElementById("target1");+ const doneButton = document.getElementById('done');++ promise_test(async t => {+ const events = [];++ const recordTouchEvents = (target) => {+ const listener = event => {+ events.push(`${target.id}:${event.type}`);+ };+ target.addEventListener('touchstart', listener);+ target.addEventListener('touchmove', listener);+ target.addEventListener('touchend', listener);+ };+ recordTouchEvents(target0);+ recordTouchEvents(target1);++ const touchstartPromise = createEventPromise('touchstart');+ const touchmovePromise = createEventPromise('touchmove');+ const touchendPromise = createEventPromise('touchend');++ await new test_driver.Actions()+ .addPointer("touchPointer1", "touch")+ .pointerMove(0, 0, {origin: target0, sourceName: "touchPointer1"})+ .pointerDown({sourceName: "touchPointer1"})+ .pointerMove(0, 10, {origin: target0, sourceName: "touchPointer1"})+ .pointerMove(0, 0, {origin: target1, sourceName: "touchPointer1"})+ .pointerUp({sourceName: "touchPointer1"})+ .send();++ // Signal test completion. Any events not processed by the time the+ // button is clicked will not be received. This safeguards against a+ // timeout on platforms lacking support for touch events.+ await new test_driver.Actions()+ .pointerMove(0, 0, {origin: doneButton})+ .pointerDown()+ .pointerUp()+ .send();++ try {+ const touchstartEvent = await touchstartPromise;+ validateTouchstart(touchstartEvent);+ } catch (e) {+ assert_unreached('touchstart event not received');+ }++ try {+ const touchmoveEvent = await touchmovePromise;+ validateTouchmove(touchmoveEvent);+ } catch (e) {+ assert_unreached('touchmove event not received');+ }++ try {+ const touchendEvent = await touchendPromise;+ validateTouchend(touchendEvent);+ } catch (e) {+ assert_unreached('touchend event not received');+ }++ assert_array_equals(+ events,+ ["target0:touchstart", "target0:touchmove", "target0:touchmove", "target0:touchend"],+ "unexpected event ordering");++ }, 'Verify touch events for a single touch drag operation');+ }+ </script>+ <style>+ * {+ touch-action: none;+ }+ div {+ margin: 0em;+ padding: 2em;+ }+ #target0 {+ background: yellow;+ border: 1px solid orange;+ }+ #target1 {+ background: lightblue;+ border: 1px solid blue;+ }+ </style>+</head>+<body onload="run()">+ <h1>Touch Events: single-touch tests</h1>+ <div id="target0">+ Touch this box with one finger (or other pointing device)...+ </div>+ <div id="target1">+ ...then drag to this box and lift your finger. Then tap on Done.+ </div>+ <button id="done">Done</button>+ <div id="log"></div>+</body>+</html>