Bug 1433671: Add MOZ_CAN_RUN_SCRIPT annotations to AccessibleCaret and other stuff. r=bz

MozReview-Commit-ID: Js0CF7WQM73
This commit is contained in:
Emilio Cobos Álvarez 2018-01-29 20:35:17 +01:00
parent 3f80fd8acc
commit a4486328c8
16 changed files with 192 additions and 71 deletions

View File

@ -2886,6 +2886,7 @@ public:
* Synthesize a mouse event to the given widget
* (see nsIDOMWindowUtils.sendMouseEvent).
*/
MOZ_CAN_RUN_SCRIPT
static nsresult SendMouseEvent(const nsCOMPtr<nsIPresShell>& aPresShell,
const nsAString& aType,
float aX,

View File

@ -84,6 +84,8 @@ protected:
mozilla::layers::LayerTransactionChild* GetLayerTransaction();
mozilla::layers::WebRenderBridgeChild* GetWebRenderBridge();
// Until callers are annotated.
MOZ_CAN_RUN_SCRIPT_BOUNDARY
NS_IMETHOD SendMouseEventCommon(const nsAString& aType,
float aX,
float aY,

View File

@ -274,6 +274,8 @@ protected:
*
* If aAdjustWidget is false, don't change the widget focus state.
*/
// MOZ_CAN_RUN_SCRIPT_BOUNDARY for now, until we annotate callers.
MOZ_CAN_RUN_SCRIPT_BOUNDARY
bool Blur(nsPIDOMWindowOuter* aWindowToClear,
nsPIDOMWindowOuter* aAncestorWindowToFocus,
bool aIsLeavingDocument,

View File

@ -138,6 +138,7 @@ public:
WidgetPointerEvent* aPointerEvent,
WidgetGUIEvent* aMouseOrTouchEvent);
MOZ_CAN_RUN_SCRIPT
static void DispatchPointerFromMouseOrTouch(PresShell* aShell,
nsIFrame* aFrame,
nsIContent* aContent,

View File

@ -356,6 +356,7 @@ public:
mozilla::ipc::IPCResult RecvDeactivate();
MOZ_CAN_RUN_SCRIPT
virtual mozilla::ipc::IPCResult RecvMouseEvent(const nsString& aType,
const float& aX,
const float& aY,
@ -651,12 +652,14 @@ public:
bool aPreventDefault) const;
void SetTargetAPZC(uint64_t aInputBlockId,
const nsTArray<ScrollableLayerGuid>& aTargets) const;
MOZ_CAN_RUN_SCRIPT
mozilla::ipc::IPCResult RecvHandleTap(const layers::GeckoContentController::TapType& aType,
const LayoutDevicePoint& aPoint,
const Modifiers& aModifiers,
const ScrollableLayerGuid& aGuid,
const uint64_t& aInputBlockId) override;
MOZ_CAN_RUN_SCRIPT
mozilla::ipc::IPCResult
RecvNormalPriorityHandleTap(const layers::GeckoContentController::TapType& aType,
const LayoutDevicePoint& aPoint,

View File

@ -114,6 +114,7 @@ public:
/* Dispatch a mouse event with the given parameters.
* Return whether or not any listeners have called preventDefault on the event. */
MOZ_CAN_RUN_SCRIPT
static bool DispatchMouseEvent(const nsCOMPtr<nsIPresShell>& aPresShell,
const nsString& aType,
const CSSPoint& aPoint,

View File

@ -54,12 +54,14 @@ public:
Modifiers aModifiers,
const ScrollableLayerGuid& aGuid,
int32_t aClickCount);
MOZ_CAN_RUN_SCRIPT
void ProcessLongTap(const nsCOMPtr<nsIPresShell>& aUtils,
const CSSPoint& aPoint,
const CSSToLayoutDeviceScale& aScale,
Modifiers aModifiers,
const ScrollableLayerGuid& aGuid,
uint64_t aInputBlockId);
MOZ_CAN_RUN_SCRIPT
void ProcessLongTapUp(const nsCOMPtr<nsIPresShell>& aPresShell,
const CSSPoint& aPoint,
const CSSToLayoutDeviceScale& aScale,
@ -82,6 +84,7 @@ public:
private:
~APZEventState();
bool SendPendingTouchPreventedResponse(bool aPreventDefault);
MOZ_CAN_RUN_SCRIPT
bool FireContextmenuEvents(const nsCOMPtr<nsIPresShell>& aPresShell,
const CSSPoint& aPoint,
const CSSToLayoutDeviceScale& aScale,

View File

@ -49,6 +49,7 @@ public:
virtual void PostDelayedTask(already_AddRefed<Runnable> aTask, int aDelayMs) override;
virtual bool IsRepaintThread() override;
virtual void DispatchToRepaintThread(already_AddRefed<Runnable> aTask) override;
MOZ_CAN_RUN_SCRIPT
virtual void HandleTap(TapType aType,
const mozilla::LayoutDevicePoint& aPoint,
Modifiers aModifiers,

View File

@ -44,8 +44,10 @@ class AccessibleCaretEventHub::NoActionState
public:
const char* Name() const override { return "NoActionState"; }
MOZ_CAN_RUN_SCRIPT
nsEventStatus OnPress(AccessibleCaretEventHub* aContext,
const nsPoint& aPoint, int32_t aTouchId,
const nsPoint& aPoint,
int32_t aTouchId,
EventClassID aEventClass) override
{
nsEventStatus rv = nsEventStatus_eIgnore;
@ -63,30 +65,36 @@ public:
return rv;
}
MOZ_CAN_RUN_SCRIPT
void OnScrollStart(AccessibleCaretEventHub* aContext) override
{
aContext->mManager->OnScrollStart();
aContext->SetState(aContext->ScrollState());
}
MOZ_CAN_RUN_SCRIPT
void OnScrollPositionChanged(AccessibleCaretEventHub* aContext) override
{
aContext->mManager->OnScrollPositionChanged();
}
MOZ_CAN_RUN_SCRIPT
void OnSelectionChanged(AccessibleCaretEventHub* aContext,
nsIDOMDocument* aDoc, nsISelection* aSel,
nsIDOMDocument* aDoc,
nsISelection* aSel,
int16_t aReason) override
{
aContext->mManager->OnSelectionChanged(aDoc, aSel, aReason);
}
MOZ_CAN_RUN_SCRIPT
void OnBlur(AccessibleCaretEventHub* aContext,
bool aIsLeavingDocument) override
{
aContext->mManager->OnBlur();
}
MOZ_CAN_RUN_SCRIPT
void OnReflow(AccessibleCaretEventHub* aContext) override
{
aContext->mManager->OnReflow();
@ -108,6 +116,7 @@ class AccessibleCaretEventHub::PressCaretState
public:
const char* Name() const override { return "PressCaretState"; }
MOZ_CAN_RUN_SCRIPT
nsEventStatus OnMove(AccessibleCaretEventHub* aContext,
const nsPoint& aPoint) override
{
@ -120,6 +129,7 @@ public:
return nsEventStatus_eConsumeNoDefault;
}
MOZ_CAN_RUN_SCRIPT
nsEventStatus OnRelease(AccessibleCaretEventHub* aContext) override
{
aContext->mManager->ReleaseCaret();
@ -145,6 +155,7 @@ class AccessibleCaretEventHub::DragCaretState
public:
const char* Name() const override { return "DragCaretState"; }
MOZ_CAN_RUN_SCRIPT
nsEventStatus OnMove(AccessibleCaretEventHub* aContext,
const nsPoint& aPoint) override
{
@ -153,6 +164,7 @@ public:
return nsEventStatus_eConsumeNoDefault;
}
MOZ_CAN_RUN_SCRIPT
nsEventStatus OnRelease(AccessibleCaretEventHub* aContext) override
{
aContext->mManager->ReleaseCaret();
@ -188,6 +200,7 @@ public:
return nsEventStatus_eIgnore;
}
MOZ_CAN_RUN_SCRIPT
nsEventStatus OnLongTap(AccessibleCaretEventHub* aContext,
const nsPoint& aPoint) override
{
@ -196,12 +209,14 @@ public:
return aContext->GetState()->OnLongTap(aContext, aPoint);
}
MOZ_CAN_RUN_SCRIPT
void OnScrollStart(AccessibleCaretEventHub* aContext) override
{
aContext->mManager->OnScrollStart();
aContext->SetState(aContext->ScrollState());
}
MOZ_CAN_RUN_SCRIPT
void OnBlur(AccessibleCaretEventHub* aContext,
bool aIsLeavingDocument) override
{
@ -211,13 +226,16 @@ public:
}
}
MOZ_CAN_RUN_SCRIPT
void OnSelectionChanged(AccessibleCaretEventHub* aContext,
nsIDOMDocument* aDoc, nsISelection* aSel,
nsIDOMDocument* aDoc,
nsISelection* aSel,
int16_t aReason) override
{
aContext->mManager->OnSelectionChanged(aDoc, aSel, aReason);
}
MOZ_CAN_RUN_SCRIPT
void OnReflow(AccessibleCaretEventHub* aContext) override
{
aContext->mManager->OnReflow();
@ -243,17 +261,20 @@ class AccessibleCaretEventHub::ScrollState
public:
const char* Name() const override { return "ScrollState"; }
MOZ_CAN_RUN_SCRIPT
void OnScrollEnd(AccessibleCaretEventHub* aContext) override
{
aContext->mManager->OnScrollEnd();
aContext->SetState(aContext->NoActionState());
}
MOZ_CAN_RUN_SCRIPT
void OnScrollPositionChanged(AccessibleCaretEventHub* aContext) override
{
aContext->mManager->OnScrollPositionChanged();
}
MOZ_CAN_RUN_SCRIPT
void OnBlur(AccessibleCaretEventHub* aContext,
bool aIsLeavingDocument) override
{
@ -273,6 +294,7 @@ class AccessibleCaretEventHub::LongTapState
public:
const char* Name() const override { return "LongTapState"; }
MOZ_CAN_RUN_SCRIPT
nsEventStatus OnLongTap(AccessibleCaretEventHub* aContext,
const nsPoint& aPoint) override
{
@ -293,12 +315,14 @@ public:
return nsEventStatus_eIgnore;
}
MOZ_CAN_RUN_SCRIPT
void OnScrollStart(AccessibleCaretEventHub* aContext) override
{
aContext->mManager->OnScrollStart();
aContext->SetState(aContext->ScrollState());
}
MOZ_CAN_RUN_SCRIPT
void OnReflow(AccessibleCaretEventHub* aContext) override
{
aContext->mManager->OnReflow();

View File

@ -60,28 +60,46 @@ class WidgetTouchEvent;
// Please see the wiki page for more information.
// https://wiki.mozilla.org/AccessibleCaret
//
class AccessibleCaretEventHub : public nsIReflowObserver,
public nsIScrollObserver,
public nsISelectionListener,
public nsSupportsWeakReference
class AccessibleCaretEventHub
: public nsIReflowObserver
, public nsIScrollObserver
, public nsISelectionListener
, public nsSupportsWeakReference
{
public:
explicit AccessibleCaretEventHub(nsIPresShell* aPresShell);
void Init();
void Terminate();
MOZ_CAN_RUN_SCRIPT
nsEventStatus HandleEvent(WidgetEvent* aEvent);
// Call this function to notify the blur event happened.
MOZ_CAN_RUN_SCRIPT
void NotifyBlur(bool aIsLeavingDocument);
NS_DECL_ISUPPORTS
NS_DECL_NSIREFLOWOBSERVER
NS_DECL_NSISELECTIONLISTENER
// nsIReflowObserver
MOZ_CAN_RUN_SCRIPT
NS_IMETHOD Reflow(DOMHighResTimeStamp start,
DOMHighResTimeStamp end) final;
MOZ_CAN_RUN_SCRIPT
NS_IMETHOD ReflowInterruptible(DOMHighResTimeStamp start,
DOMHighResTimeStamp end) final;
// nsISelectionListener
MOZ_CAN_RUN_SCRIPT
NS_IMETHOD NotifySelectionChanged(nsIDOMDocument* doc,
nsISelection* sel,
int16_t reason) final;
// Override nsIScrollObserver methods.
MOZ_CAN_RUN_SCRIPT
virtual void ScrollPositionChanged() override;
MOZ_CAN_RUN_SCRIPT
virtual void AsyncPanZoomStarted() override;
MOZ_CAN_RUN_SCRIPT
virtual void AsyncPanZoomStopped() override;
// Base state
@ -112,8 +130,11 @@ protected:
void SetState(State* aState);
MOZ_CAN_RUN_SCRIPT
nsEventStatus HandleMouseEvent(WidgetMouseEvent* aEvent);
MOZ_CAN_RUN_SCRIPT
nsEventStatus HandleTouchEvent(WidgetTouchEvent* aEvent);
MOZ_CAN_RUN_SCRIPT
nsEventStatus HandleKeyboardEvent(WidgetKeyboardEvent* aEvent);
virtual nsPoint GetTouchEventPosition(WidgetTouchEvent* aEvent,
@ -124,10 +145,14 @@ protected:
void LaunchLongTapInjector();
void CancelLongTapInjector();
MOZ_CAN_RUN_SCRIPT_BOUNDARY
static void FireLongTap(nsITimer* aTimer, void* aAccessibleCaretEventHub);
void LaunchScrollEndInjector();
void CancelScrollEndInjector();
MOZ_CAN_RUN_SCRIPT_BOUNDARY
static void FireScrollEnd(nsITimer* aTimer, void* aAccessibleCaretEventHub);
// Member variables

View File

@ -548,18 +548,14 @@ AccessibleCaretManager::TapCaret(const nsPoint& aPoint)
nsresult
AccessibleCaretManager::SelectWordOrShortcut(const nsPoint& aPoint)
{
auto UpdateCaretsWithHapticFeedback = [this] {
UpdateCarets();
ProvideHapticFeedback();
};
// If the long-tap is landing on a pre-existing selection, don't replace
// it with a new one. Instead just return and let the context menu pop up
// on the pre-existing selection.
if (GetCaretMode() == CaretMode::Selection &&
GetSelection()->ContainsPoint(aPoint)) {
AC_LOG("%s: UpdateCarets() for current selection", __FUNCTION__);
UpdateCaretsWithHapticFeedback();
UpdateCarets();
ProvideHapticFeedback();
return NS_OK;
}
@ -607,7 +603,8 @@ AccessibleCaretManager::SelectWordOrShortcut(const nsPoint& aPoint)
}
// We need to update carets to get correct information before dispatching
// CaretStateChangedEvent.
UpdateCaretsWithHapticFeedback();
UpdateCarets();
ProvideHapticFeedback();
DispatchCaretStateChangedEvent(CaretChangedReason::Longpressonemptycontent);
return NS_OK;
}
@ -641,7 +638,8 @@ AccessibleCaretManager::SelectWordOrShortcut(const nsPoint& aPoint)
// Then try select a word under point.
nsresult rv = SelectWord(ptFrame, ptInFrame);
UpdateCaretsWithHapticFeedback();
UpdateCarets();
ProvideHapticFeedback();
return rv;
}

View File

@ -59,44 +59,57 @@ public:
// Press caret on the given point. Return NS_OK if the point is actually on
// one of the carets.
virtual nsresult PressCaret(const nsPoint& aPoint, EventClassID aEventClass);
MOZ_CAN_RUN_SCRIPT
virtual nsresult PressCaret(const nsPoint& aPoint,
EventClassID aEventClass);
// Drag caret to the given point. It's required to call PressCaret()
// beforehand.
MOZ_CAN_RUN_SCRIPT
virtual nsresult DragCaret(const nsPoint& aPoint);
// Release caret from he previous press action. It's required to call
// PressCaret() beforehand.
MOZ_CAN_RUN_SCRIPT
virtual nsresult ReleaseCaret();
// A quick single tap on caret on given point without dragging.
MOZ_CAN_RUN_SCRIPT
virtual nsresult TapCaret(const nsPoint& aPoint);
// Select a word or bring up paste shortcut (if Gaia is listening) under the
// given point.
MOZ_CAN_RUN_SCRIPT
virtual nsresult SelectWordOrShortcut(const nsPoint& aPoint);
// Handle scroll-start event.
MOZ_CAN_RUN_SCRIPT
virtual void OnScrollStart();
// Handle scroll-end event.
MOZ_CAN_RUN_SCRIPT
virtual void OnScrollEnd();
// Handle ScrollPositionChanged from nsIScrollObserver. This might be called
// at anytime, not necessary between OnScrollStart and OnScrollEnd.
MOZ_CAN_RUN_SCRIPT
virtual void OnScrollPositionChanged();
// Handle reflow event from nsIReflowObserver.
MOZ_CAN_RUN_SCRIPT
virtual void OnReflow();
// Handle blur event from nsFocusManager.
MOZ_CAN_RUN_SCRIPT
virtual void OnBlur();
// Handle NotifySelectionChanged event from nsISelectionListener.
MOZ_CAN_RUN_SCRIPT
virtual nsresult OnSelectionChanged(nsIDOMDocument* aDoc,
nsISelection* aSel,
int16_t aReason);
// Handle key event.
MOZ_CAN_RUN_SCRIPT
virtual void OnKeyboardEvent();
// The canvas frame holding the accessible caret anonymous content elements
@ -145,12 +158,18 @@ protected:
// Update carets based on current selection status. This function will flush
// layout, so caller must ensure the PresShell is still valid after calling
// this method.
void UpdateCarets(const UpdateCaretsHintSet& aHints = UpdateCaretsHint::Default);
MOZ_CAN_RUN_SCRIPT
void UpdateCarets(
const UpdateCaretsHintSet& aHints = UpdateCaretsHint::Default);
// Force hiding all carets regardless of the current selection status.
MOZ_CAN_RUN_SCRIPT
void HideCarets();
MOZ_CAN_RUN_SCRIPT
void UpdateCaretsForCursorMode(const UpdateCaretsHintSet& aHints);
MOZ_CAN_RUN_SCRIPT
void UpdateCaretsForSelectionMode(const UpdateCaretsHintSet& aHints);
// Provide haptic / touch feedback, primarily for select on longpress.
@ -205,7 +224,8 @@ protected:
// See the mRefCnt assertions in AccessibleCaretEventHub.
//
// Returns whether mPresShell we're holding is still valid.
MOZ_MUST_USE bool FlushLayout();
MOZ_MUST_USE MOZ_CAN_RUN_SCRIPT
bool FlushLayout();
dom::Element* GetEditingHostForFrame(nsIFrame* aFrame) const;
dom::Selection* GetSelection() const;
@ -261,6 +281,7 @@ protected:
// This function will flush layout, so caller must ensure the PresShell is
// still valid after calling this method.
MOZ_CAN_RUN_SCRIPT
virtual void DispatchCaretStateChangedEvent(dom::CaretChangedReason aReason);
// ---------------------------------------------------------------------------

View File

@ -6994,22 +6994,21 @@ PresShell::HandleEvent(nsIFrame* aFrame,
}
// Only capture mouse events and pointer events.
nsIContent* pointerCapturingContent =
nsCOMPtr<nsIContent> pointerCapturingContent =
PointerEventHandler::GetPointerCapturingContent(aEvent);
if (pointerCapturingContent) {
nsIFrame* pointerCapturingFrame =
pointerCapturingContent->GetPrimaryFrame();
frame = pointerCapturingContent->GetPrimaryFrame();
if (!pointerCapturingFrame) {
if (!frame) {
// Dispatch events to the capturing content even it's frame is
// destroyed.
PointerEventHandler::DispatchPointerFromMouseOrTouch(
this, nullptr, pointerCapturingContent, aEvent, false, aEventStatus,
nullptr);
this, nullptr, pointerCapturingContent, aEvent, false,
aEventStatus, nullptr);
PresShell* shell = GetShellForEventTarget(nullptr,
pointerCapturingContent);
RefPtr<PresShell> shell =
GetShellForEventTarget(nullptr, pointerCapturingContent);
if (!shell) {
// The capturing element could be changed when dispatch pointer
@ -7019,8 +7018,6 @@ PresShell::HandleEvent(nsIFrame* aFrame,
return shell->HandleEventWithTarget(aEvent, nullptr,
pointerCapturingContent,
aEventStatus, true);
} else {
frame = pointerCapturingFrame;
}
}
@ -7095,7 +7092,7 @@ PresShell::HandleEvent(nsIFrame* aFrame,
return NS_OK;
}
PresShell* shell = static_cast<PresShell*>(frame->PresShell());
RefPtr<PresShell> shell = static_cast<PresShell*>(frame->PresShell());
// Check if we have an active EventStateManager which isn't the
// EventStateManager of the current PresContext.
// If that is the case, and mouse is over some ancestor document,
@ -7198,7 +7195,7 @@ PresShell::HandleEvent(nsIFrame* aFrame,
touchEvent)) {
frame = newFrame;
frame->GetContentForEvent(aEvent, getter_AddRefs(targetElement));
shell = static_cast<PresShell*>(frame->PresContext()->PresShell());
shell = static_cast<PresShell*>(frame->PresShell());
}
} else if (PresShell* newShell = GetShellForTouchEvent(aEvent)) {
// Touch events (except touchstart) are dispatching to the captured
@ -7207,8 +7204,6 @@ PresShell::HandleEvent(nsIFrame* aFrame,
}
}
// Prevent deletion until we're done with event handling (bug 336582)
nsCOMPtr<nsIPresShell> kungFuDeathGrip(shell);
nsresult rv;
// Handle the event in the correct shell.

View File

@ -226,10 +226,10 @@ public:
void Paint(nsView* aViewToPaint, const nsRegion& aDirtyRegion,
uint32_t aFlags) override;
nsresult HandleEvent(nsIFrame* aFrame,
WidgetGUIEvent* aEvent,
bool aDontRetargetEvents,
nsEventStatus* aEventStatus) override;
MOZ_CAN_RUN_SCRIPT nsresult HandleEvent(nsIFrame* aFrame,
WidgetGUIEvent* aEvent,
bool aDontRetargetEvents,
nsEventStatus* aEventStatus) override;
nsresult HandleDOMEventWithTarget(nsIContent* aTargetContent,
WidgetEvent* aEvent,
nsEventStatus* aStatus) override;
@ -666,8 +666,8 @@ private:
already_AddRefed<nsIPresShell> GetParentPresShellForEventHandling();
nsIContent* GetCurrentEventContent();
nsIFrame* GetCurrentEventFrame();
nsresult RetargetEventToParent(WidgetGUIEvent* aEvent,
nsEventStatus* aEventStatus);
MOZ_CAN_RUN_SCRIPT nsresult
RetargetEventToParent(WidgetGUIEvent* aEvent, nsEventStatus* aEventStatus);
void PushCurrentEventInfo(nsIFrame* aFrame, nsIContent* aContent);
void PopCurrentEventInfo();
/**

View File

@ -195,6 +195,9 @@ public:
return Move(event);
}
MOZ_CAN_RUN_SCRIPT_BOUNDARY void TestAsyncPanZoomScroll();
MOZ_CAN_RUN_SCRIPT_BOUNDARY
void HandleEventAndCheckState(UniquePtr<WidgetEvent> aEvent,
MockAccessibleCaretEventHub::State* aExpectedState,
nsEventStatus aExpectedEventStatus)
@ -209,40 +212,48 @@ public:
EXPECT_EQ(mHub->GetState(), aExpectedState);
}
template <typename PressEventCreator, typename ReleaseEventCreator>
void TestPressReleaseOnNoCaret(PressEventCreator aPressEventCreator,
ReleaseEventCreator aReleaseEventCreator);
template <typename PressEventCreator, typename ReleaseEventCreator>
void TestPressReleaseOnCaret(PressEventCreator aPressEventCreator,
ReleaseEventCreator aReleaseEventCreator);
template <typename PressEventCreator, typename MoveEventCreator,
typename ReleaseEventCreator>
void TestPressMoveReleaseOnNoCaret(PressEventCreator aPressEventCreator,
MoveEventCreator aMoveEventCreator,
ReleaseEventCreator aReleaseEventCreator);
template <typename PressEventCreator, typename MoveEventCreator,
typename ReleaseEventCreator>
void TestPressMoveReleaseOnCaret(PressEventCreator aPressEventCreator,
MoveEventCreator aMoveEventCreator,
ReleaseEventCreator aReleaseEventCreator);
template <typename PressEventCreator, typename ReleaseEventCreator>
void TestLongTapWithSelectWordSuccessful(
template<typename PressEventCreator, typename ReleaseEventCreator>
MOZ_CAN_RUN_SCRIPT_BOUNDARY void TestPressReleaseOnNoCaret(
PressEventCreator aPressEventCreator,
ReleaseEventCreator aReleaseEventCreator);
template <typename PressEventCreator, typename ReleaseEventCreator>
void TestLongTapWithSelectWordFailed(
template<typename PressEventCreator, typename ReleaseEventCreator>
MOZ_CAN_RUN_SCRIPT_BOUNDARY void TestPressReleaseOnCaret(
PressEventCreator aPressEventCreator,
ReleaseEventCreator aReleaseEventCreator);
template <typename PressEventCreator, typename MoveEventCreator,
typename ReleaseEventCreator>
void TestEventDrivenAsyncPanZoomScroll(
PressEventCreator aPressEventCreator, MoveEventCreator aMoveEventCreator,
template<typename PressEventCreator,
typename MoveEventCreator,
typename ReleaseEventCreator>
MOZ_CAN_RUN_SCRIPT_BOUNDARY void TestPressMoveReleaseOnNoCaret(
PressEventCreator aPressEventCreator,
MoveEventCreator aMoveEventCreator,
ReleaseEventCreator aReleaseEventCreator);
template<typename PressEventCreator,
typename MoveEventCreator,
typename ReleaseEventCreator>
MOZ_CAN_RUN_SCRIPT_BOUNDARY void TestPressMoveReleaseOnCaret(
PressEventCreator aPressEventCreator,
MoveEventCreator aMoveEventCreator,
ReleaseEventCreator aReleaseEventCreator);
template<typename PressEventCreator, typename ReleaseEventCreator>
MOZ_CAN_RUN_SCRIPT_BOUNDARY void TestLongTapWithSelectWordSuccessful(
PressEventCreator aPressEventCreator,
ReleaseEventCreator aReleaseEventCreator);
template<typename PressEventCreator, typename ReleaseEventCreator>
MOZ_CAN_RUN_SCRIPT_BOUNDARY void TestLongTapWithSelectWordFailed(
PressEventCreator aPressEventCreator,
ReleaseEventCreator aReleaseEventCreator);
template<typename PressEventCreator,
typename MoveEventCreator,
typename ReleaseEventCreator>
MOZ_CAN_RUN_SCRIPT_BOUNDARY void TestEventDrivenAsyncPanZoomScroll(
PressEventCreator aPressEventCreator,
MoveEventCreator aMoveEventCreator,
ReleaseEventCreator aReleaseEventCreator);
// Member variables
@ -251,11 +262,13 @@ public:
}; // class AccessibleCaretEventHubTester
TEST_F(AccessibleCaretEventHubTester, TestMousePressReleaseOnNoCaret)
MOZ_CAN_RUN_SCRIPT
{
TestPressReleaseOnNoCaret(CreateMousePressEvent, CreateMouseReleaseEvent);
}
TEST_F(AccessibleCaretEventHubTester, TestTouchPressReleaseOnNoCaret)
MOZ_CAN_RUN_SCRIPT
{
TestPressReleaseOnNoCaret(CreateTouchStartEvent, CreateTouchEndEvent);
}
@ -283,11 +296,13 @@ AccessibleCaretEventHubTester::TestPressReleaseOnNoCaret(
}
TEST_F(AccessibleCaretEventHubTester, TestMousePressReleaseOnCaret)
MOZ_CAN_RUN_SCRIPT
{
TestPressReleaseOnCaret(CreateMousePressEvent, CreateMouseReleaseEvent);
}
TEST_F(AccessibleCaretEventHubTester, TestTouchPressReleaseOnCaret)
MOZ_CAN_RUN_SCRIPT
{
TestPressReleaseOnCaret(CreateTouchStartEvent, CreateTouchEndEvent);
}
@ -325,12 +340,14 @@ AccessibleCaretEventHubTester::TestPressReleaseOnCaret(
}
TEST_F(AccessibleCaretEventHubTester, TestMousePressMoveReleaseOnNoCaret)
MOZ_CAN_RUN_SCRIPT
{
TestPressMoveReleaseOnNoCaret(CreateMousePressEvent, CreateMouseMoveEvent,
CreateMouseReleaseEvent);
}
TEST_F(AccessibleCaretEventHubTester, TestTouchPressMoveReleaseOnNoCaret)
MOZ_CAN_RUN_SCRIPT
{
TestPressMoveReleaseOnNoCaret(CreateTouchStartEvent, CreateTouchMoveEvent,
CreateTouchEndEvent);
@ -379,12 +396,14 @@ AccessibleCaretEventHubTester::TestPressMoveReleaseOnNoCaret(
}
TEST_F(AccessibleCaretEventHubTester, TestMousePressMoveReleaseOnCaret)
MOZ_CAN_RUN_SCRIPT
{
TestPressMoveReleaseOnCaret(CreateMousePressEvent, CreateMouseMoveEvent,
CreateMouseReleaseEvent);
}
TEST_F(AccessibleCaretEventHubTester, TestTouchPressMoveReleaseOnCaret)
MOZ_CAN_RUN_SCRIPT
{
TestPressMoveReleaseOnCaret(CreateTouchStartEvent, CreateTouchMoveEvent,
CreateTouchEndEvent);
@ -446,6 +465,7 @@ AccessibleCaretEventHubTester::TestPressMoveReleaseOnCaret(
TEST_F(AccessibleCaretEventHubTester,
TestTouchStartMoveEndOnCaretWithTouchCancelIgnored)
MOZ_CAN_RUN_SCRIPT
{
nscoord x0 = 0, y0 = 0;
nscoord x1 = 100, y1 = 100;
@ -504,12 +524,14 @@ TEST_F(AccessibleCaretEventHubTester,
nsEventStatus_eIgnore);}
TEST_F(AccessibleCaretEventHubTester, TestMouseLongTapWithSelectWordSuccessful)
MOZ_CAN_RUN_SCRIPT
{
TestLongTapWithSelectWordSuccessful(CreateMousePressEvent,
CreateMouseReleaseEvent);
}
TEST_F(AccessibleCaretEventHubTester, TestTouchLongTapWithSelectWordSuccessful)
MOZ_CAN_RUN_SCRIPT
{
TestLongTapWithSelectWordSuccessful(CreateTouchStartEvent,
CreateTouchEndEvent);
@ -584,12 +606,14 @@ AccessibleCaretEventHubTester::TestLongTapWithSelectWordSuccessful(
}
TEST_F(AccessibleCaretEventHubTester, TestMouseLongTapWithSelectWordFailed)
MOZ_CAN_RUN_SCRIPT
{
TestLongTapWithSelectWordFailed(CreateMousePressEvent,
CreateMouseReleaseEvent);
}
TEST_F(AccessibleCaretEventHubTester, TestTouchLongTapWithSelectWordFailed)
MOZ_CAN_RUN_SCRIPT
{
TestLongTapWithSelectWordFailed(CreateTouchStartEvent,
CreateTouchEndEvent);
@ -625,12 +649,14 @@ AccessibleCaretEventHubTester::TestLongTapWithSelectWordFailed(
}
TEST_F(AccessibleCaretEventHubTester, TestTouchEventDrivenAsyncPanZoomScroll)
MOZ_CAN_RUN_SCRIPT
{
TestEventDrivenAsyncPanZoomScroll(CreateTouchStartEvent, CreateTouchMoveEvent,
CreateTouchEndEvent);
}
TEST_F(AccessibleCaretEventHubTester, TestMouseEventDrivenAsyncPanZoomScroll)
MOZ_CAN_RUN_SCRIPT
{
TestEventDrivenAsyncPanZoomScroll(CreateMousePressEvent, CreateMouseMoveEvent,
CreateMouseReleaseEvent);
@ -724,7 +750,13 @@ AccessibleCaretEventHubTester::TestEventDrivenAsyncPanZoomScroll(
nsEventStatus_eIgnore);
}
TEST_F(AccessibleCaretEventHubTester, TestAsyncPanZoomScroll)
TEST_F(AccessibleCaretEventHubTester, TestAsyncPanZoomScroll) MOZ_CAN_RUN_SCRIPT
{
TestAsyncPanZoomScroll();
}
void
AccessibleCaretEventHubTester::TestAsyncPanZoomScroll()
{
MockFunction<void(::std::string aCheckPointName)> check;
{
@ -769,6 +801,7 @@ TEST_F(AccessibleCaretEventHubTester, TestAsyncPanZoomScroll)
}
TEST_F(AccessibleCaretEventHubTester, TestAsyncPanZoomScrollStartedThenBlur)
MOZ_CAN_RUN_SCRIPT
{
{
InSequence dummy;
@ -789,6 +822,7 @@ TEST_F(AccessibleCaretEventHubTester, TestAsyncPanZoomScrollStartedThenBlur)
}
TEST_F(AccessibleCaretEventHubTester, TestAsyncPanZoomScrollEndedThenBlur)
MOZ_CAN_RUN_SCRIPT
{
{
InSequence dummy;

View File

@ -146,6 +146,7 @@ public:
}; // class AccessibleCaretManagerTester
TEST_F(AccessibleCaretManagerTester, TestUpdatesInSelectionMode)
MOZ_CAN_RUN_SCRIPT
{
EXPECT_CALL(mManager, GetCaretMode())
.WillRepeatedly(Return(CaretMode::Selection));
@ -167,6 +168,7 @@ TEST_F(AccessibleCaretManagerTester, TestUpdatesInSelectionMode)
}
TEST_F(AccessibleCaretManagerTester, TestSingleTapOnNonEmptyInput)
MOZ_CAN_RUN_SCRIPT
{
EXPECT_CALL(mManager, GetCaretMode())
.WillRepeatedly(Return(CaretMode::Cursor));
@ -237,6 +239,7 @@ TEST_F(AccessibleCaretManagerTester, TestSingleTapOnNonEmptyInput)
}
TEST_F(AccessibleCaretManagerTester, TestSingleTapOnEmptyInput)
MOZ_CAN_RUN_SCRIPT
{
EXPECT_CALL(mManager, GetCaretMode())
.WillRepeatedly(Return(CaretMode::Cursor));
@ -306,7 +309,7 @@ TEST_F(AccessibleCaretManagerTester, TestSingleTapOnEmptyInput)
EXPECT_EQ(FirstCaretAppearance(), Appearance::NormalNotShown);
}
TEST_F(AccessibleCaretManagerTester, TestTypingAtEndOfInput)
TEST_F(AccessibleCaretManagerTester, TestTypingAtEndOfInput) MOZ_CAN_RUN_SCRIPT
{
EXPECT_CALL(mManager, GetCaretMode())
.WillRepeatedly(Return(CaretMode::Cursor));
@ -349,6 +352,7 @@ TEST_F(AccessibleCaretManagerTester, TestTypingAtEndOfInput)
}
TEST_F(AccessibleCaretManagerTester, TestScrollInSelectionMode)
MOZ_CAN_RUN_SCRIPT
{
// Simulate caret hiding when scrolling.
AutoRestore<bool> savesCaretsAlwaysShowWhenScrolling(
@ -427,7 +431,9 @@ TEST_F(AccessibleCaretManagerTester, TestScrollInSelectionMode)
check.Call("scrollend2");
}
TEST_F(AccessibleCaretManagerTester, TestScrollInSelectionModeWithAlwaysTiltPref)
TEST_F(AccessibleCaretManagerTester,
TestScrollInSelectionModeWithAlwaysTiltPref)
MOZ_CAN_RUN_SCRIPT
{
// Simulate Firefox Android preference.
AutoRestore<bool> saveCaretsAlwaysTilt(
@ -533,6 +539,7 @@ TEST_F(AccessibleCaretManagerTester, TestScrollInSelectionModeWithAlwaysTiltPref
}
TEST_F(AccessibleCaretManagerTester, TestScrollInCursorModeWhenLogicallyVisible)
MOZ_CAN_RUN_SCRIPT
{
// Simulate caret hiding when scrolling.
AutoRestore<bool> savesCaretsAlwaysShowWhenScrolling(
@ -598,6 +605,7 @@ TEST_F(AccessibleCaretManagerTester, TestScrollInCursorModeWhenLogicallyVisible)
}
TEST_F(AccessibleCaretManagerTester, TestScrollInCursorModeWhenHidden)
MOZ_CAN_RUN_SCRIPT
{
// Simulate caret hiding when scrolling.
AutoRestore<bool> savesCaretsAlwaysShowWhenScrolling(
@ -657,6 +665,7 @@ TEST_F(AccessibleCaretManagerTester, TestScrollInCursorModeWhenHidden)
}
TEST_F(AccessibleCaretManagerTester, TestScrollInCursorModeOnEmptyContent)
MOZ_CAN_RUN_SCRIPT
{
// Simulate caret hiding when scrolling.
AutoRestore<bool> savesCaretsAlwaysShowWhenScrolling(
@ -733,6 +742,7 @@ TEST_F(AccessibleCaretManagerTester, TestScrollInCursorModeOnEmptyContent)
TEST_F(AccessibleCaretManagerTester,
TestScrollInCursorModeWithCaretShownWhenLongTappingOnEmptyContentPref)
MOZ_CAN_RUN_SCRIPT
{
// Simulate Firefox Android preference.
AutoRestore<bool> savesCaretShownWhenLongTappingOnEmptyContent(