OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "bindings/core/v8/ScriptController.h" |
| 6 #include "core/layout/LayoutTestHelper.h" |
| 7 #include "platform/testing/HistogramTester.h" |
| 8 |
| 9 namespace blink { |
| 10 |
| 11 enum PassiveForcedListenerResultType { |
| 12 PreventDefaultNotCalled, |
| 13 DocumentLevelTouchPreventDefaultCalled |
| 14 }; |
| 15 |
| 16 class EventTargetTest : public RenderingTest { |
| 17 public: |
| 18 EventTargetTest() {} |
| 19 ~EventTargetTest() {} |
| 20 }; |
| 21 |
| 22 TEST_F(EventTargetTest, PreventDefaultNotCalled) |
| 23 { |
| 24 document().settings()->setScriptEnabled(true); |
| 25 HistogramTester histogramTester; |
| 26 document().frame()->script().executeScriptInMainWorld( |
| 27 "window.addEventListener('touchstart', function(e) {}, {});" |
| 28 "window.dispatchEvent(new TouchEvent('touchstart', {cancelable: false}))
;"); |
| 29 |
| 30 histogramTester.expectTotalCount( |
| 31 "Event.PassiveForcedEventDispatchCancelled", 1); |
| 32 histogramTester.expectUniqueSample( |
| 33 "Event.PassiveForcedEventDispatchCancelled", PreventDefaultNotCalled, 1)
; |
| 34 } |
| 35 |
| 36 TEST_F(EventTargetTest, PreventDefaultCalled) |
| 37 { |
| 38 document().settings()->setScriptEnabled(true); |
| 39 HistogramTester histogramTester; |
| 40 document().frame()->script().executeScriptInMainWorld( |
| 41 "window.addEventListener('touchstart', function(e) {e.preventDefault();}
, {});" |
| 42 "window.dispatchEvent(new TouchEvent('touchstart', {cancelable: false}))
;"); |
| 43 |
| 44 histogramTester.expectTotalCount( |
| 45 "Event.PassiveForcedEventDispatchCancelled", 1); |
| 46 histogramTester.expectUniqueSample( |
| 47 "Event.PassiveForcedEventDispatchCancelled", DocumentLevelTouchPreventDe
faultCalled, 1); |
| 48 } |
| 49 |
| 50 } // namespace blink |
OLD | NEW |