Changeset 75536 in webkit
- Timestamp:
- Jan 11, 2011 12:44:52 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 2 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r75534 r75536 1 2011-01-11 Dimitri Glazkov <dglazkov@chromium.org> 2 3 Reviewed by Eric Seidel. 4 5 REGRESSION(r71934) Can't type in search edit field on skin-one.com 6 https://bugs.webkit.org/show_bug.cgi?id=52195 7 8 Restored original (pre-71934) check in the test to ensure that 9 selectstart does not propagate outside of the shadow DOM. 10 11 Consolidated shadow-boundary-crossing-2.html into shadow-boundary-crossing.html. 12 13 * fast/events/shadow-boundary-crossing-2-expected.txt: Renamed to 14 shadow-boundary-crossing-expected.txt. 15 * fast/events/shadow-boundary-crossing-2.html: Renamed to 16 shadow-boundary-crossing.html. 17 * fast/events/shadow-boundary-crossing-expected.txt: Removed. 18 * fast/events/shadow-boundary-crossing.html: Removed after folding the 19 test into the new shadow-boundary-crossing.html. 20 1 21 2011-01-11 Zhenyao Mo <zmo@google.com> 2 22 -
trunk/LayoutTests/fast/events/shadow-boundary-crossing-expected.txt
r19681 r75536 1 Test for http://bugs.webkit.org/show_bug.cgi?id=12780 REGRESSION (r19341-r19385): Reproducible crash in "onselectstart" event.1 Tests to ensure that shadow DOM boundary is not crossed during event propagation. Can only run within DRT. 2 2 3 Result: PASS 3 See bug 46015 for details. 4 4 5 5 Mutation events should not propagate out of the shadow DOM: PASS 6 The selectstart event should not propagate out of the shadow DOM: PASS 7 Label should look beyond shadow boundary to detect if it encloses its associated element: PASS 8 Events for default event handler should not be retargeted: PASS 9 Other events should be retargeted: PASS 10 After event dispatch, the event object should not reveal shadow DOM: PASS 11 Focusing same shadow DOM element repeatedly should not trigger multiple focus/blur events: PASS -
trunk/LayoutTests/fast/events/shadow-boundary-crossing.html
r71934 r75536 1 1 <html> 2 2 <head> 3 <title></title> 4 <script type="text/javascript"> 5 var success; 6 var target; 3 <script> 7 4 8 function selectStart(event) 5 var logDiv; 6 7 function log(msg, success) 8 { 9 logDiv.appendChild(document.createElement('div')).textContent = msg + ': ' + (success ? 'PASS' : 'FAIL'); 10 } 11 12 function clickOn(element) 13 { 14 if (!window.eventSender) 15 return; 16 17 var x = element.offsetLeft + element.offsetWidth / 2; 18 var y = element.offsetTop + element.offsetHeight / 2; 19 eventSender.mouseMoveTo(x, y); 20 eventSender.mouseDown(); 21 eventSender.mouseUp(); 22 } 23 24 function clickOnLeftQuarterOf(element) 25 { 26 if (!window.eventSender) 27 return; 28 29 var x = element.offsetLeft + element.offsetWidth / 4; 30 var y = element.offsetTop + element.offsetHeight / 2; 31 eventSender.mouseMoveTo(x, y); 32 eventSender.mouseDown(); 33 eventSender.mouseUp(); 34 } 35 36 function leapForward() 37 { 38 if (!window.eventSender) 39 return; 40 41 eventSender.leapForward(1000); 42 } 43 44 var tests = { 45 mutationEventPropagation: function() 46 { 47 var textarea = document.body.appendChild(document.createElement('textarea')); 48 var mutationEventFired; 49 textarea.addEventListener('DOMSubtreeModified', function(e) 9 50 { 10 success = event.target == target; 51 mutationEventFired = true; 52 }, false); 53 textarea.value = 'test'; 54 // Trigger style recalc and sadly, the actual mutation of the textarea shadow DOM. 55 textarea.offsetHeight; 56 log('Mutation events should not propagate out of the shadow DOM', !mutationEventFired); 57 textarea.parentNode.removeChild(textarea); 58 }, 59 selectstartEventPropagation: function() 60 { 61 var textInput = document.body.appendChild(document.createElement('input')); 62 var selectstartEventFired = false; 63 document.selectstart = function() 64 { 65 selectstartEventFired = true; 11 66 } 67 clickOn(textInput); 68 log('The selectstart event should not propagate out of the shadow DOM', !selectstartEventFired); 69 textInput.parentNode.removeChild(textInput); 70 document.selectstart = null; 71 }, 72 labelSyntheticClick: function() 73 { 74 var count = 0; 75 var label = document.body.appendChild(document.createElement('label')); 76 var searchInput = label.appendChild(document.createElement('input')); 77 searchInput.setAttribute('type', 'search'); 78 searchInput.setAttribute('id', 'baz'); 79 label.setAttribute('for', 'baz'); 80 searchInput.addEventListener('click', function(e) 81 { 82 count++; 83 }, false); 84 clickOn(searchInput); 85 log("Label should look beyond shadow boundary to detect if it encloses its associated element", count == 1); 86 label.parentNode.removeChild(label); 87 }, 88 defaultEventRetargeting: function() 89 { 90 var count = 0; 91 var fileInput = document.body.appendChild(document.createElement('input')); 92 fileInput.setAttribute('type', 'file'); 93 var counter = function() 94 { 95 count++; 96 } 97 document.body.addEventListener('DOMActivate', counter, false); 98 clickOnLeftQuarterOf(fileInput); 99 log("Events for default event handler should not be retargeted", count == 1); 100 document.body.removeEventListener('DOMActivate', counter, false); 101 fileInput.parentNode.removeChild(fileInput); 102 }, 103 eventInProgress: function() 104 { 105 var textInput = document.body.appendChild(document.createElement('input')); 106 textInput.addEventListener('click', function(e) 107 { 108 log('Other events should be retargeted', e.target == textInput); 109 }, false); 110 clickOn(textInput); 111 textInput.parentNode.removeChild(textInput); 112 }, 113 finalEventObject: function() 114 { 115 var textInput = document.body.appendChild(document.createElement('input')); 116 var storedEvent; 117 textInput.addEventListener('click', function(e) 118 { 119 storedEvent = e; 120 }, false); 121 clickOn(textInput); 122 log('After event dispatch, the event object should not reveal shadow DOM', storedEvent && storedEvent.target == textInput); 123 textInput.parentNode.removeChild(textInput); 124 }, 125 focusEventPropagation: function() 126 { 127 var searchInput = document.body.appendChild(document.createElement('input')); 128 searchInput.setAttribute('type', 'search'); 129 var count = 0; 130 searchInput.addEventListener('focus', function(evt) 131 { 132 count++; 133 }); 134 clickOn(searchInput); 135 leapForward(); 136 clickOn(searchInput); 137 log('Focusing same shadow DOM element repeatedly should not trigger multiple focus/blur events', count == 1); 138 searchInput.parentNode.removeChild(searchInput); 139 } 140 }; 12 141 13 function test() 14 { 15 if (!window.layoutTestController) 16 return; 17 layoutTestController.dumpAsText(); 142 function runTest() 143 { 144 if (window.layoutTestController) 145 layoutTestController.dumpAsText(); 18 146 19 target = document.getElementById("target"); 20 var x = target.offsetLeft + target.offsetWidth / 2; 21 var y = target.offsetTop + target.offsetHeight / 2; 147 logDiv = document.getElementById('log'); 148 for(var testName in tests) { 149 tests[testName](); 150 } 151 } 22 152 23 eventSender.mouseMoveTo(x, y); 24 eventSender.mouseDown(); 25 eventSender.mouseUp(); 26 27 document.getElementById("result").innerText = !success ? "FAIL" : "PASS"; 28 } 29 30 addEventListener("selectstart", selectStart, true); 31 </script> 153 </script> 32 154 </head> 33 <body onload="test()"> 34 <p> 35 Test for <i><a href="http://bugs.webkit.org/show_bug.cgi?id=12780">http://bugs.webkit.org/show_bug.cgi?id=12780</a> 36 REGRESSION (r19341-r19385): Reproducible crash in "onselectstart" event</i>. 37 </p> 38 <p> 39 Result: <span id="result">cannot run interactively</span> 40 </p> 41 <input id="target"> 155 <body onload="runTest()"> 156 <p>Tests to ensure that shadow DOM boundary is not crossed during event propagation. Can only run within DRT. 157 <p>See <a href="https://bugs.webkit.org/show_bug.cgi?id=46015">bug 46015</a> for details. 158 <div id="log"></div> 42 159 </body> 43 160 </html> -
trunk/Source/WebCore/ChangeLog
r75535 r75536 1 2011-01-11 Dimitri Glazkov <dglazkov@chromium.org> 2 3 Reviewed by Eric Seidel. 4 5 REGRESSION(r71934) Can't type in search edit field on skin-one.com 6 https://bugs.webkit.org/show_bug.cgi?id=52195 7 8 Restored the original behavior, where the selectstart event is not 9 dispatched when selection changes inside of the shadow DOM. 10 11 * dom/Node.cpp: 12 (WebCore::determineDispatchBehavior): Moved EventDispatchBehavior-determining 13 logic into a helper function, also added a check to keep selectstart 14 events inside of the shadow DOM. 15 (WebCore::Node::dispatchGenericEvent): Changed to use the helper function. 16 1 17 2011-01-11 Viatcheslav Ostapenko <ostapenko.viatcheslav@nokia.com> 2 18 -
trunk/Source/WebCore/dom/Node.cpp
r75287 r75536 2612 2612 } 2613 2613 2614 static EventDispatchBehavior determineDispatchBehavior(Event* event) 2615 { 2616 // Per XBL 2.0 spec, mutation events should never cross shadow DOM boundary: 2617 // http://dev.w3.org/2006/xbl2/#event-flow-and-targeting-across-shadow-s 2618 if (event->isMutationEvent()) 2619 return StayInsideShadowDOM; 2620 2621 // WebKit never allowed selectstart event to cross the the shadow DOM boundary. 2622 // Changing this breaks existing sites. 2623 // See https://bugs.webkit.org/show_bug.cgi?id=52195 for details. 2624 if (event->type() == eventNames().selectstartEvent) 2625 return StayInsideShadowDOM; 2626 2627 return RetargetEvent; 2628 } 2629 2614 2630 bool Node::dispatchGenericEvent(PassRefPtr<Event> prpEvent) 2615 2631 { … … 2626 2642 RefPtr<EventTarget> originalTarget = event->target(); 2627 2643 Vector<EventContext> ancestors; 2628 getEventAncestors(ancestors, originalTarget.get(), event->isMutationEvent() ? StayInsideShadowDOM : RetargetEvent);2644 getEventAncestors(ancestors, originalTarget.get(), determineDispatchBehavior(event.get())); 2629 2645 2630 2646 WindowEventContext windowContext(event.get(), this, topEventContext(ancestors));
Note: See TracChangeset
for help on using the changeset viewer.