Program: 54631
Project: 54631
Buggy source:
/** 
 * Test that   {@link Event#fireNativePreviewEvent(Event)} fires handlers inreverse order, and that the legacy EventPreview fires only if it is at the top of the stack.
 */
@SuppressWarnings("String_Node_Str") public void testFireNativePreviewEventReverseOrder(){
  final TestEventPreview preview0=new TestEventPreview(false);
  final TestEventPreview preview1=new TestEventPreview(false);
  final TestNativePreviewHandler handler0=new TestNativePreviewHandler(false,false){
    @Override public void onPreviewNativeEvent(    NativePreviewEvent event){
      super.onPreviewNativeEvent(event);
      preview0.assertIsFired(false);
      preview1.assertIsFired(true);
      assertFalse(event.isFirstHandler());
    }
  }
;
  final TestNativePreviewHandler handler1=new TestNativePreviewHandler(false,false){
    @Override public void onPreviewNativeEvent(    NativePreviewEvent event){
      super.onPreviewNativeEvent(event);
      handler0.assertIsFired(false);
      preview0.assertIsFired(false);
      preview1.assertIsFired(true);
      assertFalse(event.isFirstHandler());
    }
  }
;
  final TestNativePreviewHandler handler2=new TestNativePreviewHandler(false,false){
    @Override public void onPreviewNativeEvent(    NativePreviewEvent event){
      super.onPreviewNativeEvent(event);
      handler0.assertIsFired(false);
      handler1.assertIsFired(false);
      preview0.assertIsFired(false);
      preview1.assertIsFired(true);
      assertFalse(event.isFirstHandler());
    }
  }
;
  final TestNativePreviewHandler handler3=new TestNativePreviewHandler(false,false){
    @Override public void onPreviewNativeEvent(    NativePreviewEvent event){
      super.onPreviewNativeEvent(event);
      handler0.assertIsFired(false);
      handler1.assertIsFired(false);
      handler2.assertIsFired(false);
      preview0.assertIsFired(false);
      preview1.assertIsFired(true);
      assertFalse(event.isFirstHandler());
    }
  }
;
  DOM.addEventPreview(preview0);
  HandlerRegistration reg0=Event.addNativePreviewHandler(handler0);
  HandlerRegistration reg1=Event.addNativePreviewHandler(handler1);
  HandlerRegistration reg2=Event.addNativePreviewHandler(handler2);
  HandlerRegistration reg3=Event.addNativePreviewHandler(handler3);
  DOM.addEventPreview(preview1);
  assertTrue(DOM.previewEvent(null));
  handler0.assertIsFired(true);
  handler1.assertIsFired(true);
  handler2.assertIsFired(true);
  handler3.assertIsFired(true);
  preview0.assertIsFired(false);
  preview1.assertIsFired(true);
  reg0.removeHandler();
  reg1.removeHandler();
  reg2.removeHandler();
  reg3.removeHandler();
  DOM.removeEventPreview(preview0);
  DOM.removeEventPreview(preview1);
}

Fixed version (ground truth):
/** 
 * Test that   {@link Event#fireNativePreviewEvent(NativeEvent)} fires handlersin reverse order, and that the legacy EventPreview fires only if it is at the top of the stack.
 */
@SuppressWarnings("String_Node_Str") public void testFireNativePreviewEventReverseOrder(){
  final TestEventPreview preview0=new TestEventPreview(false);
  final TestEventPreview preview1=new TestEventPreview(false);
  final TestNativePreviewHandler handler0=new TestNativePreviewHandler(false,false){
    @Override public void onPreviewNativeEvent(    NativePreviewEvent event){
      super.onPreviewNativeEvent(event);
      preview0.assertIsFired(false);
      preview1.assertIsFired(true);
      assertFalse(event.isFirstHandler());
    }
  }
;
  final TestNativePreviewHandler handler1=new TestNativePreviewHandler(false,false){
    @Override public void onPreviewNativeEvent(    NativePreviewEvent event){
      super.onPreviewNativeEvent(event);
      handler0.assertIsFired(false);
      preview0.assertIsFired(false);
      preview1.assertIsFired(true);
      assertFalse(event.isFirstHandler());
    }
  }
;
  final TestNativePreviewHandler handler2=new TestNativePreviewHandler(false,false){
    @Override public void onPreviewNativeEvent(    NativePreviewEvent event){
      super.onPreviewNativeEvent(event);
      handler0.assertIsFired(false);
      handler1.assertIsFired(false);
      preview0.assertIsFired(false);
      preview1.assertIsFired(true);
      assertFalse(event.isFirstHandler());
    }
  }
;
  final TestNativePreviewHandler handler3=new TestNativePreviewHandler(false,false){
    @Override public void onPreviewNativeEvent(    NativePreviewEvent event){
      super.onPreviewNativeEvent(event);
      handler0.assertIsFired(false);
      handler1.assertIsFired(false);
      handler2.assertIsFired(false);
      preview0.assertIsFired(false);
      preview1.assertIsFired(true);
      assertFalse(event.isFirstHandler());
    }
  }
;
  DOM.addEventPreview(preview0);
  HandlerRegistration reg0=Event.addNativePreviewHandler(handler0);
  HandlerRegistration reg1=Event.addNativePreviewHandler(handler1);
  HandlerRegistration reg2=Event.addNativePreviewHandler(handler2);
  HandlerRegistration reg3=Event.addNativePreviewHandler(handler3);
  DOM.addEventPreview(preview1);
  assertTrue(DOM.previewEvent(null));
  handler0.assertIsFired(true);
  handler1.assertIsFired(true);
  handler2.assertIsFired(true);
  handler3.assertIsFired(true);
  preview0.assertIsFired(false);
  preview1.assertIsFired(true);
  reg0.removeHandler();
  reg1.removeHandler();
  reg2.removeHandler();
  reg3.removeHandler();
  DOM.removeEventPreview(preview0);
  DOM.removeEventPreview(preview1);
}