nus-yam/ex-repair huggingface dataset:
Program: 184989
Project: 184989
Buggy source:
private Bitmap createScreenshot(WebView view){
  Picture thumbnail=view.capturePicture();
  Bitmap bm=Bitmap.createBitmap(getDesiredThumbnailWidth(this),getDesiredThumbnailHeight(this),Bitmap.Config.ARGB_4444);
  Canvas canvas=new Canvas(bm);
  int contentWidth=view.getContentWidth();
  if (contentWidth > 0) {
    float scaleFactor=(float)getDesiredThumbnailWidth(this) / (float)contentWidth;
    canvas.scale(scaleFactor,scaleFactor);
  }
  thumbnail.draw(canvas);
  return bm;
}

Fixed version (ground truth):
private Bitmap createScreenshot(WebView view){
  Picture thumbnail=view.capturePicture();
  Bitmap bm=Bitmap.createBitmap(getDesiredThumbnailWidth(this),getDesiredThumbnailHeight(this),Bitmap.Config.ARGB_4444);
  Canvas canvas=new Canvas(bm);
  int thumbnailWidth=thumbnail.getWidth();
  if (thumbnailWidth > 0) {
    float scaleFactor=(float)getDesiredThumbnailWidth(this) / (float)thumbnailWidth;
    canvas.scale(scaleFactor,scaleFactor);
  }
  thumbnail.draw(canvas);
  return bm;
}
Program: 184990
Project: 184990
Buggy source:
public void handleMessage(Message msg){
switch (msg.what) {
case FOCUS_NODE_HREF:
    String url=(String)msg.getData().get("String_Node_Str");
  if (url == null || url.length() == 0) {
    break;
  }
HashMap focusNodeMap=(HashMap)msg.obj;
WebView view=(WebView)focusNodeMap.get("String_Node_Str");
if (getTopWindow() != view) {
break;
}
switch (msg.arg1) {
case R.id.open_context_menu_id:
case R.id.view_image_context_menu_id:
loadURL(getTopWindow(),url);
break;
case R.id.open_newtab_context_menu_id:
final TabControl.Tab parent=mTabControl.getCurrentTab();
final TabControl.Tab newTab=openTab(url);
if (newTab != parent) {
parent.addChildTab(newTab);
}
break;
case R.id.bookmark_context_menu_id:
Intent intent=new Intent(BrowserActivity.this,AddBookmarkPage.class);
intent.putExtra("String_Node_Str",url);
startActivity(intent);
break;
case R.id.share_link_context_menu_id:
Browser.sendString(BrowserActivity.this,url,getText(R.string.choosertitle_sharevia).toString());
break;
case R.id.copy_link_context_menu_id:
copy(url);
break;
case R.id.save_link_context_menu_id:
case R.id.download_context_menu_id:
onDownloadStartNoStream(url,null,null,null,-1);
break;
}
break;
case LOAD_URL:
loadURL(getTopWindow(),(String)msg.obj);
break;
case STOP_LOAD:
stopLoading();
break;
case CANCEL_CREDS_REQUEST:
resumeAfterCredentials();
break;
case RELEASE_WAKELOCK:
if (mWakeLock.isHeld()) {
mWakeLock.release();
}
break;
}
}

Fixed version (ground truth):
public void handleMessage(Message msg){
switch (msg.what) {
case FOCUS_NODE_HREF:
{
      String url=(String)msg.getData().get("String_Node_Str");
      if (url == null || url.length() == 0) {
        break;
      }
      HashMap focusNodeMap=(HashMap)msg.obj;
      WebView view=(WebView)focusNodeMap.get("String_Node_Str");
      if (getTopWindow() != view) {
        break;
      }
switch (msg.arg1) {
case R.id.open_context_menu_id:
case R.id.view_image_context_menu_id:
        loadURL(getTopWindow(),url);
      break;
case R.id.open_newtab_context_menu_id:
    final TabControl.Tab parent=mTabControl.getCurrentTab();
  final TabControl.Tab newTab=openTab(url);
if (newTab != parent) {
  parent.addChildTab(newTab);
}
break;
case R.id.bookmark_context_menu_id:
Intent intent=new Intent(BrowserActivity.this,AddBookmarkPage.class);
intent.putExtra("String_Node_Str",url);
startActivity(intent);
break;
case R.id.share_link_context_menu_id:
Browser.sendString(BrowserActivity.this,url,getText(R.string.choosertitle_sharevia).toString());
break;
case R.id.copy_link_context_menu_id:
copy(url);
break;
case R.id.save_link_context_menu_id:
case R.id.download_context_menu_id:
onDownloadStartNoStream(url,null,null,null,-1);
break;
}
break;
}
case LOAD_URL:
loadURL(getTopWindow(),(String)msg.obj);
break;
case STOP_LOAD:
stopLoading();
break;
case CANCEL_CREDS_REQUEST:
resumeAfterCredentials();
break;
case RELEASE_WAKELOCK:
if (mWakeLock.isHeld()) {
mWakeLock.release();
}
break;
case UPDATE_BOOKMARK_THUMBNAIL:
WebView view=(WebView)msg.obj;
if (view != null) {
updateScreenshot(view);
}
break;
}
}
Program: 184991
Project: 184991
Buggy source:
@Override public void onProgressChanged(WebView view,int newProgress){
  mTitleBar.setProgress(newProgress);
  if (mFakeTitleBar != null) {
    mFakeTitleBar.setProgress(newProgress);
  }
  if (newProgress == 100) {
    CookieSyncManager.getInstance().sync();
    if (mInLoad) {
      mInLoad=false;
      updateInLoadMenuItems();
      if (!mOptionsMenuOpen || !mIconView) {
        hideFakeTitleBar();
      }
    }
    if (mNeedExtraScreenShot) {
      updateScreenshot(view);
      mNeedExtraScreenShot=false;
    }
  }
 else   if (!mInLoad) {
    mInLoad=true;
    updateInLoadMenuItems();
    if (!mOptionsMenuOpen || mIconView) {
      showFakeTitleBar();
    }
  }
}

Fixed version (ground truth):
@Override public void onProgressChanged(WebView view,int newProgress){
  mTitleBar.setProgress(newProgress);
  if (mFakeTitleBar != null) {
    mFakeTitleBar.setProgress(newProgress);
  }
  if (newProgress == 100) {
    CookieSyncManager.getInstance().sync();
    if (mInLoad) {
      mInLoad=false;
      updateInLoadMenuItems();
      if (!mOptionsMenuOpen || !mIconView) {
        hideFakeTitleBar();
      }
    }
  }
 else   if (!mInLoad) {
    mInLoad=true;
    updateInLoadMenuItems();
    if (!mOptionsMenuOpen || mIconView) {
      showFakeTitleBar();
    }
  }
}
Program: 184993
Project: 184993
Buggy source:
/** 
 * Show a dialog informing the user of the network error reported by WebCore.
 */
@Override public void onReceivedError(WebView view,int errorCode,String description,String failingUrl){
  if (errorCode != WebViewClient.ERROR_HOST_LOOKUP && errorCode != WebViewClient.ERROR_CONNECT && errorCode != WebViewClient.ERROR_BAD_URL && errorCode != WebViewClient.ERROR_UNSUPPORTED_SCHEME && errorCode != WebViewClient.ERROR_FILE) {
    queueError(errorCode,description);
  }
  Log.e(LOGTAG,"String_Node_Str" + errorCode + "String_Node_Str"+ failingUrl+ "String_Node_Str"+ description);
  mNeedExtraScreenShot=true;
  resetTitleAndRevertLockIcon();
}

Fixed version (ground truth):
/** 
 * Show a dialog informing the user of the network error reported by WebCore.
 */
@Override public void onReceivedError(WebView view,int errorCode,String description,String failingUrl){
  if (errorCode != WebViewClient.ERROR_HOST_LOOKUP && errorCode != WebViewClient.ERROR_CONNECT && errorCode != WebViewClient.ERROR_BAD_URL && errorCode != WebViewClient.ERROR_UNSUPPORTED_SCHEME && errorCode != WebViewClient.ERROR_FILE) {
    queueError(errorCode,description);
  }
  Log.e(LOGTAG,"String_Node_Str" + errorCode + "String_Node_Str"+ failingUrl+ "String_Node_Str"+ description);
  resetTitleAndRevertLockIcon();
}
Program: 184995
Project: 184995
Buggy source:
private Bitmap createScreenshot(WebView view){
  Picture thumbnail=view.capturePicture();
  Bitmap bm=Bitmap.createBitmap(getDesiredThumbnailWidth(this),getDesiredThumbnailHeight(this),Bitmap.Config.ARGB_4444);
  Canvas canvas=new Canvas(bm);
  int contentWidth=view.getContentWidth();
  if (contentWidth > 0) {
    float scaleFactor=(float)getDesiredThumbnailWidth(this) / (float)contentWidth;
    canvas.scale(scaleFactor,scaleFactor);
  }
  thumbnail.draw(canvas);
  return bm;
}

Fixed version (ground truth):
private Bitmap createScreenshot(WebView view){
  Picture thumbnail=view.capturePicture();
  Bitmap bm=Bitmap.createBitmap(getDesiredThumbnailWidth(this),getDesiredThumbnailHeight(this),Bitmap.Config.ARGB_4444);
  Canvas canvas=new Canvas(bm);
  int thumbnailWidth=thumbnail.getWidth();
  if (thumbnailWidth > 0) {
    float scaleFactor=(float)getDesiredThumbnailWidth(this) / (float)thumbnailWidth;
    canvas.scale(scaleFactor,scaleFactor);
  }
  thumbnail.draw(canvas);
  return bm;
}
Program: 184996
Project: 184996
Buggy source:
public void handleMessage(Message msg){
switch (msg.what) {
case FOCUS_NODE_HREF:
    String url=(String)msg.getData().get("String_Node_Str");
  if (url == null || url.length() == 0) {
    break;
  }
HashMap focusNodeMap=(HashMap)msg.obj;
WebView view=(WebView)focusNodeMap.get("String_Node_Str");
if (getTopWindow() != view) {
break;
}
switch (msg.arg1) {
case R.id.open_context_menu_id:
case R.id.view_image_context_menu_id:
loadURL(getTopWindow(),url);
break;
case R.id.open_newtab_context_menu_id:
final TabControl.Tab parent=mTabControl.getCurrentTab();
final TabControl.Tab newTab=openTab(url);
if (newTab != parent) {
parent.addChildTab(newTab);
}
break;
case R.id.bookmark_context_menu_id:
Intent intent=new Intent(BrowserActivity.this,AddBookmarkPage.class);
intent.putExtra("String_Node_Str",url);
startActivity(intent);
break;
case R.id.share_link_context_menu_id:
Browser.sendString(BrowserActivity.this,url,getText(R.string.choosertitle_sharevia).toString());
break;
case R.id.copy_link_context_menu_id:
copy(url);
break;
case R.id.save_link_context_menu_id:
case R.id.download_context_menu_id:
onDownloadStartNoStream(url,null,null,null,-1);
break;
}
break;
case LOAD_URL:
loadURL(getTopWindow(),(String)msg.obj);
break;
case STOP_LOAD:
stopLoading();
break;
case CANCEL_CREDS_REQUEST:
resumeAfterCredentials();
break;
case RELEASE_WAKELOCK:
if (mWakeLock.isHeld()) {
mWakeLock.release();
}
break;
}
}

Fixed version (ground truth):
public void handleMessage(Message msg){
switch (msg.what) {
case FOCUS_NODE_HREF:
{
      String url=(String)msg.getData().get("String_Node_Str");
      if (url == null || url.length() == 0) {
        break;
      }
      HashMap focusNodeMap=(HashMap)msg.obj;
      WebView view=(WebView)focusNodeMap.get("String_Node_Str");
      if (getTopWindow() != view) {
        break;
      }
switch (msg.arg1) {
case R.id.open_context_menu_id:
case R.id.view_image_context_menu_id:
        loadURL(getTopWindow(),url);
      break;
case R.id.open_newtab_context_menu_id:
    final TabControl.Tab parent=mTabControl.getCurrentTab();
  final TabControl.Tab newTab=openTab(url);
if (newTab != parent) {
  parent.addChildTab(newTab);
}
break;
case R.id.bookmark_context_menu_id:
Intent intent=new Intent(BrowserActivity.this,AddBookmarkPage.class);
intent.putExtra("String_Node_Str",url);
startActivity(intent);
break;
case R.id.share_link_context_menu_id:
Browser.sendString(BrowserActivity.this,url,getText(R.string.choosertitle_sharevia).toString());
break;
case R.id.copy_link_context_menu_id:
copy(url);
break;
case R.id.save_link_context_menu_id:
case R.id.download_context_menu_id:
onDownloadStartNoStream(url,null,null,null,-1);
break;
}
break;
}
case LOAD_URL:
loadURL(getTopWindow(),(String)msg.obj);
break;
case STOP_LOAD:
stopLoading();
break;
case CANCEL_CREDS_REQUEST:
resumeAfterCredentials();
break;
case RELEASE_WAKELOCK:
if (mWakeLock.isHeld()) {
mWakeLock.release();
}
break;
case UPDATE_BOOKMARK_THUMBNAIL:
WebView view=(WebView)msg.obj;
if (view != null) {
updateScreenshot(view);
}
break;
}
}
Program: 184997
Project: 184997
Buggy source:
private void scheduleOutOfSpaceNotification(){
  if (LOGV_ENABLED) {
    Log.v(LOGTAG,"String_Node_Str");
  }
  if (mContext == null) {
    return;
  }
  int icon=android.R.drawable.stat_sys_warning;
  CharSequence title=mContext.getString(R.string.webstorage_outofspace_notification_title);
  CharSequence text=mContext.getString(R.string.webstorage_outofspace_notification_text);
  long when=System.currentTimeMillis();
  Intent intent=new Intent(mContext,WebsiteSettingsActivity.class);
  PendingIntent contentIntent=PendingIntent.getActivity(mContext,0,intent,0);
  Notification notification=new Notification(icon,title,when);
  notification.setLatestEventInfo(mContext,title,text,contentIntent);
  notification.flags|=Notification.FLAG_AUTO_CANCEL;
  String ns=Context.NOTIFICATION_SERVICE;
  NotificationManager mgr=(NotificationManager)mContext.getSystemService(ns);
  if (mgr != null) {
    mgr.notify(OUT_OF_SPACE_ID,notification);
  }
}

Fixed version (ground truth):
private void scheduleOutOfSpaceNotification(){
  if (LOGV_ENABLED) {
    Log.v(LOGTAG,"String_Node_Str");
  }
  if (mContext == null) {
    return;
  }
  if ((mLastOutOfSpaceNotificationTime == -1) || (System.currentTimeMillis() - mLastOutOfSpaceNotificationTime > NOTIFICATION_INTERVAL)) {
    int icon=android.R.drawable.stat_sys_warning;
    CharSequence title=mContext.getString(R.string.webstorage_outofspace_notification_title);
    CharSequence text=mContext.getString(R.string.webstorage_outofspace_notification_text);
    long when=System.currentTimeMillis();
    Intent intent=new Intent(mContext,WebsiteSettingsActivity.class);
    PendingIntent contentIntent=PendingIntent.getActivity(mContext,0,intent,0);
    Notification notification=new Notification(icon,title,when);
    notification.setLatestEventInfo(mContext,title,text,contentIntent);
    notification.flags|=Notification.FLAG_AUTO_CANCEL;
    String ns=Context.NOTIFICATION_SERVICE;
    NotificationManager mgr=(NotificationManager)mContext.getSystemService(ns);
    if (mgr != null) {
      mLastOutOfSpaceNotificationTime=System.currentTimeMillis();
      mgr.notify(OUT_OF_SPACE_ID,notification);
    }
  }
}
Program: 184998
Project: 184998
Buggy source:
public void onClick(DialogInterface dlg,int which){
  WebStorage.getInstance().deleteAllData();
  GeolocationPermissions.getInstance().clearAll();
  mAdapter.askForOrigins();
  finish();
}

Fixed version (ground truth):
public void onClick(DialogInterface dlg,int which){
  WebStorage.getInstance().deleteAllData();
  GeolocationPermissions.getInstance().clearAll();
  WebStorageSizeManager.resetLastOutOfSpaceNotificationTime();
  mAdapter.askForOrigins();
  finish();
}
Program: 184999
Project: 184999
Buggy source:
@Override public boolean onOptionsItemSelected(MenuItem item){
switch (item.getItemId()) {
case R.id.website_settings_menu_clear_all:
    new AlertDialog.Builder(this).setTitle(R.string.website_settings_clear_all_dialog_title).setMessage(R.string.website_settings_clear_all_dialog_message).setPositiveButton(R.string.website_settings_clear_all_dialog_ok_button,new AlertDialog.OnClickListener(){
      public void onClick(      DialogInterface dlg,      int which){
        WebStorage.getInstance().deleteAllData();
        GeolocationPermissions.getInstance().clearAll();
        mAdapter.askForOrigins();
        finish();
      }
    }
).setNegativeButton(R.string.website_settings_clear_all_dialog_cancel_button,null).setIcon(android.R.drawable.ic_dialog_alert).show();
  return true;
}
return false;
}

Fixed version (ground truth):
@Override public boolean onOptionsItemSelected(MenuItem item){
switch (item.getItemId()) {
case R.id.website_settings_menu_clear_all:
    new AlertDialog.Builder(this).setTitle(R.string.website_settings_clear_all_dialog_title).setMessage(R.string.website_settings_clear_all_dialog_message).setPositiveButton(R.string.website_settings_clear_all_dialog_ok_button,new AlertDialog.OnClickListener(){
      public void onClick(      DialogInterface dlg,      int which){
        WebStorage.getInstance().deleteAllData();
        GeolocationPermissions.getInstance().clearAll();
        WebStorageSizeManager.resetLastOutOfSpaceNotificationTime();
        mAdapter.askForOrigins();
        finish();
      }
    }
).setNegativeButton(R.string.website_settings_clear_all_dialog_cancel_button,null).setIcon(android.R.drawable.ic_dialog_alert).show();
  return true;
}
return false;
}
Program: 185000
Project: 185000
Buggy source:
@Override protected void onDialogClosed(boolean positiveResult){
  super.onDialogClosed(positiveResult);
  if (positiveResult) {
    setEnabled(false);
    Context context=getContext();
    if (BrowserSettings.PREF_CLEAR_CACHE.equals(getKey())) {
      BrowserSettings.getInstance().clearCache(context);
      BrowserSettings.getInstance().clearDatabases(context);
    }
 else     if (BrowserSettings.PREF_CLEAR_COOKIES.equals(getKey())) {
      BrowserSettings.getInstance().clearCookies(context);
    }
 else     if (BrowserSettings.PREF_CLEAR_HISTORY.equals(getKey())) {
      BrowserSettings.getInstance().clearHistory(context);
    }
 else     if (BrowserSettings.PREF_CLEAR_FORM_DATA.equals(getKey())) {
      BrowserSettings.getInstance().clearFormData(context);
    }
 else     if (BrowserSettings.PREF_CLEAR_PASSWORDS.equals(getKey())) {
      BrowserSettings.getInstance().clearPasswords(context);
    }
 else     if (BrowserSettings.PREF_EXTRAS_RESET_DEFAULTS.equals(getKey())) {
      BrowserSettings.getInstance().resetDefaultPreferences(context);
      setEnabled(true);
    }
 else     if (BrowserSettings.PREF_CLEAR_LOCATION_ACCESS.equals(getKey())) {
      BrowserSettings.getInstance().clearLocationAccess(context);
    }
  }
}

Fixed version (ground truth):
@Override protected void onDialogClosed(boolean positiveResult){
  super.onDialogClosed(positiveResult);
  if (positiveResult) {
    setEnabled(false);
    Context context=getContext();
    if (BrowserSettings.PREF_CLEAR_CACHE.equals(getKey())) {
      BrowserSettings.getInstance().clearCache(context);
      BrowserSettings.getInstance().clearDatabases(context);
    }
 else     if (BrowserSettings.PREF_CLEAR_COOKIES.equals(getKey())) {
      BrowserSettings.getInstance().clearCookies(context);
    }
 else     if (BrowserSettings.PREF_CLEAR_HISTORY.equals(getKey())) {
      BrowserSettings.getInstance().clearHistory(context);
    }
 else     if (BrowserSettings.PREF_CLEAR_FORM_DATA.equals(getKey())) {
      BrowserSettings.getInstance().clearFormData(context);
    }
 else     if (BrowserSettings.PREF_CLEAR_PASSWORDS.equals(getKey())) {
      BrowserSettings.getInstance().clearPasswords(context);
    }
 else     if (BrowserSettings.PREF_EXTRAS_RESET_DEFAULTS.equals(getKey())) {
      BrowserSettings.getInstance().resetDefaultPreferences(context);
      setEnabled(true);
    }
 else     if (BrowserSettings.PREF_CLEAR_GEOLOCATION_ACCESS.equals(getKey())) {
      BrowserSettings.getInstance().clearLocationAccess(context);
    }
  }
}
Program: 185002
Project: 185002
Buggy source:
/** 
 * Switch tabs.  Called by the TitleBarSet when sliding the title bar results in changing tabs.
 */
void switchToTab(int index){
  TabControl.Tab tab=mTabControl.getTab(index);
  TabControl.Tab currentTab=mTabControl.getCurrentTab();
  if (tab == null || tab == currentTab) {
    return;
  }
  if (currentTab != null) {
    removeTabFromContentView(currentTab);
  }
  removeTabFromContentView(tab);
  mTabControl.setCurrentTab(tab);
  attachTabToContentView(tab);
}

Fixed version (ground truth):
/** 
 * Switch tabs.  Called by the TitleBarSet when sliding the title bar results in changing tabs.
 * @param index Index of the tab to change to, as defined bymTabControl.getTabIndex(Tab t).
 * @return boolean True if we successfully switched to a different tab.  Ifthe indexth tab is null, or if that tab is the same as the current one, return false.
 */
boolean switchToTab(int index){
  TabControl.Tab tab=mTabControl.getTab(index);
  TabControl.Tab currentTab=mTabControl.getCurrentTab();
  if (tab == null || tab == currentTab) {
    return false;
  }
  if (currentTab != null) {
    removeTabFromContentView(currentTab);
  }
  removeTabFromContentView(tab);
  mTabControl.setCurrentTab(tab);
  attachTabToContentView(tab);
  return true;
}
Program: 185003
Project: 185003
Buggy source:
void bookmarksOrHistoryPicker(boolean startWithHistory){
  WebView current=mTabControl.getCurrentWebView();
  if (current == null) {
    return;
  }
  Intent intent=new Intent(this,CombinedBookmarkHistoryActivity.class);
  String title=current.getTitle();
  String url=current.getUrl();
  if (null == url) {
    url=mLastEnteredUrl;
    if (null == url) {
      url=mSettings.getHomePage();
    }
  }
  if (title == null) {
    title=url;
  }
  intent.putExtra("String_Node_Str",title);
  intent.putExtra("String_Node_Str",url);
  intent.putExtra("String_Node_Str",mTabControl.getTabCount() >= TabControl.MAX_TABS);
  intent.putExtra("String_Node_Str",current.getTouchIconUrl());
  if (startWithHistory) {
    intent.putExtra(CombinedBookmarkHistoryActivity.STARTING_TAB,CombinedBookmarkHistoryActivity.HISTORY_TAB);
  }
  startActivityForResult(intent,COMBO_PAGE);
}

Fixed version (ground truth):
/** 
 * Open the Go page.
 * @param startWithHistory If true, open starting on the history tab.Otherwise, start with the bookmarks tab.
 * @param cancelGoPageMeansClose Set to true if this came from a new tab, orfrom the only tab, and canceling means to close the tab (and possibly the browser)
 */
void bookmarksOrHistoryPicker(boolean startWithHistory,boolean cancelGoPageMeansClose){
  WebView current=mTabControl.getCurrentWebView();
  if (current == null) {
    return;
  }
  Intent intent=new Intent(this,CombinedBookmarkHistoryActivity.class);
  String title=current.getTitle();
  String url=current.getUrl();
  if (null == url) {
    url=mLastEnteredUrl;
    if (null == url) {
      url=mSettings.getHomePage();
    }
  }
  if (title == null) {
    title=url;
  }
  intent.putExtra("String_Node_Str",title);
  intent.putExtra("String_Node_Str",url);
  intent.putExtra("String_Node_Str",mTabControl.getTabCount() >= TabControl.MAX_TABS);
  intent.putExtra("String_Node_Str",current.getTouchIconUrl());
  if (startWithHistory) {
    intent.putExtra(CombinedBookmarkHistoryActivity.STARTING_TAB,CombinedBookmarkHistoryActivity.HISTORY_TAB);
  }
  mCancelGoPageMeansClose=cancelGoPageMeansClose;
  startActivityForResult(intent,COMBO_PAGE);
}
Program: 185004
Project: 185004
Buggy source:
void closeCurrentWindow(){
  final int currentIndex=mTabControl.getCurrentIndex();
  final TabControl.Tab current=mTabControl.getCurrentTab();
  final TabControl.Tab parent=current.getParentTab();
  int indexToShow=-1;
  if (parent != null) {
    indexToShow=mTabControl.getTabIndex(parent);
  }
 else {
    indexToShow=mTabControl.getTabCount() - 1;
    if (currentIndex == indexToShow) {
      indexToShow--;
    }
  }
  switchToTab(indexToShow);
  closeTab(current);
}

Fixed version (ground truth):
void closeCurrentWindow(){
  final TabControl.Tab current=mTabControl.getCurrentTab();
  if (mTabControl.getTabCount() == 1) {
    TabControl.Tab newTab=openTabAndShow(BrowserActivity.EMPTY_URL_DATA,false,null);
    bookmarksOrHistoryPicker(false,true);
    closeTab(current);
    mTabControl.setCurrentTab(newTab);
    return;
  }
  final TabControl.Tab parent=current.getParentTab();
  int indexToShow=-1;
  if (parent != null) {
    indexToShow=mTabControl.getTabIndex(parent);
  }
 else {
    final int currentIndex=mTabControl.getCurrentIndex();
    indexToShow=currentIndex + 1;
    if (indexToShow > mTabControl.getTabCount() - 1) {
      indexToShow=currentIndex - 1;
    }
  }
  if (switchToTab(indexToShow)) {
    closeTab(current);
  }
}
Program: 185005
Project: 185005
Buggy source:
@Override protected void onActivityResult(int requestCode,int resultCode,Intent intent){
switch (requestCode) {
case COMBO_PAGE:
    if (resultCode == RESULT_OK && intent != null) {
      String data=intent.getAction();
      Bundle extras=intent.getExtras();
      if (extras != null && extras.getBoolean("String_Node_Str",false)) {
        final TabControl.Tab newTab=openTab(data);
        if (mSettings.openInBackground() && newTab != null) {
          mTabControl.populatePickerData(newTab);
          mTabControl.setCurrentTab(newTab);
          int newIndex=mTabControl.getCurrentIndex();
          if (CUSTOM_BROWSER_BAR) {
            mTitleBar.setCurrentTab(newIndex);
          }
        }
      }
 else {
        final TabControl.Tab currentTab=mTabControl.getCurrentTab();
        dismissSubWindow(currentTab);
        if (data != null && data.length() != 0) {
          getTopWindow().loadUrl(data);
        }
      }
    }
  break;
default :
break;
}
getTopWindow().requestFocus();
}

Fixed version (ground truth):
@Override protected void onActivityResult(int requestCode,int resultCode,Intent intent){
switch (requestCode) {
case COMBO_PAGE:
    if (resultCode == RESULT_OK && intent != null) {
      String data=intent.getAction();
      Bundle extras=intent.getExtras();
      if (extras != null && extras.getBoolean("String_Node_Str",false)) {
        final TabControl.Tab newTab=openTab(data);
        if (mSettings.openInBackground() && newTab != null) {
          mTabControl.populatePickerData(newTab);
          mTabControl.setCurrentTab(newTab);
          int newIndex=mTabControl.getCurrentIndex();
          if (CUSTOM_BROWSER_BAR) {
            mTitleBar.setCurrentTab(newIndex);
          }
        }
      }
 else {
        final TabControl.Tab currentTab=mTabControl.getCurrentTab();
        dismissSubWindow(currentTab);
        if (data != null && data.length() != 0) {
          getTopWindow().loadUrl(data);
        }
      }
    }
 else     if (resultCode == RESULT_CANCELED && mCancelGoPageMeansClose) {
      if (mTabControl.getTabCount() == 1) {
        finish();
        return;
      }
      closeCurrentWindow();
    }
  break;
default :
break;
}
mCancelGoPageMeansClose=false;
if (getTopWindow() != null) {
getTopWindow().requestFocus();
}
}
Program: 185007
Project: 185007
Buggy source:
public KeyTracker.State onKeyTracker(int keyCode,KeyEvent event,KeyTracker.Stage stage,int duration){
  WebView topWindow=getTopWindow();
  if (topWindow == null && mCustomView == null)   return KeyTracker.State.NOT_TRACKING;
  if (keyCode == KeyEvent.KEYCODE_BACK) {
    if (mCustomView != null) {
      mWebChromeClient.onHideCustomView();
      return KeyTracker.State.DONE_TRACKING;
    }
    if (stage == KeyTracker.Stage.LONG_REPEAT) {
      bookmarksOrHistoryPicker(true);
      return KeyTracker.State.DONE_TRACKING;
    }
 else     if (stage == KeyTracker.Stage.UP) {
      WebView subwindow=mTabControl.getCurrentSubWindow();
      if (subwindow != null) {
        if (subwindow.canGoBack()) {
          subwindow.goBack();
        }
 else {
          dismissSubWindow(mTabControl.getCurrentTab());
        }
      }
 else {
        goBackOnePageOrQuit();
      }
      return KeyTracker.State.DONE_TRACKING;
    }
    return KeyTracker.State.KEEP_TRACKING;
  }
  return KeyTracker.State.NOT_TRACKING;
}

Fixed version (ground truth):
public KeyTracker.State onKeyTracker(int keyCode,KeyEvent event,KeyTracker.Stage stage,int duration){
  WebView topWindow=getTopWindow();
  if (topWindow == null && mCustomView == null)   return KeyTracker.State.NOT_TRACKING;
  if (keyCode == KeyEvent.KEYCODE_BACK) {
    if (mCustomView != null) {
      mWebChromeClient.onHideCustomView();
      return KeyTracker.State.DONE_TRACKING;
    }
    if (stage == KeyTracker.Stage.LONG_REPEAT) {
      bookmarksOrHistoryPicker(true,false);
      return KeyTracker.State.DONE_TRACKING;
    }
 else     if (stage == KeyTracker.Stage.UP) {
      WebView subwindow=mTabControl.getCurrentSubWindow();
      if (subwindow != null) {
        if (subwindow.canGoBack()) {
          subwindow.goBack();
        }
 else {
          dismissSubWindow(mTabControl.getCurrentTab());
        }
      }
 else {
        goBackOnePageOrQuit();
      }
      return KeyTracker.State.DONE_TRACKING;
    }
    return KeyTracker.State.KEEP_TRACKING;
  }
  return KeyTracker.State.NOT_TRACKING;
}
Program: 185009
Project: 185009
Buggy source:
TabControl.Tab openTabAndShow(UrlData urlData,boolean closeOnExit,String appId){
  final boolean newTab=mTabControl.getTabCount() != TabControl.MAX_TABS;
  final TabControl.Tab currentTab=mTabControl.getCurrentTab();
  if (newTab) {
    final TabControl.Tab tab=mTabControl.createNewTab(closeOnExit,appId,urlData.mUrl);
    WebView webview=tab.getWebView();
    if (CUSTOM_BROWSER_BAR) {
      mTitleBar.addTab(webview,true);
    }
    removeTabFromContentView(currentTab);
    attachTabToContentView(tab);
    mTabControl.setCurrentTab(tab);
    if (urlData.isEmpty()) {
      bookmarksOrHistoryPicker(false);
    }
 else {
      urlData.loadIn(webview);
    }
    return tab;
  }
 else {
    dismissSubWindow(currentTab);
    if (!urlData.isEmpty()) {
      urlData.loadIn(currentTab.getWebView());
    }
 else {
      bookmarksOrHistoryPicker(false);
    }
  }
  return currentTab;
}

Fixed version (ground truth):
TabControl.Tab openTabAndShow(UrlData urlData,boolean closeOnExit,String appId){
  final boolean newTab=mTabControl.getTabCount() != TabControl.MAX_TABS;
  final TabControl.Tab currentTab=mTabControl.getCurrentTab();
  if (newTab) {
    final TabControl.Tab tab=mTabControl.createNewTab(closeOnExit,appId,urlData.mUrl);
    WebView webview=tab.getWebView();
    if (CUSTOM_BROWSER_BAR) {
      mTitleBar.addTab(webview,true);
    }
    removeTabFromContentView(currentTab);
    attachTabToContentView(tab);
    mTabControl.setCurrentTab(tab);
    if (!urlData.isEmpty()) {
      urlData.loadIn(webview);
    }
    return tab;
  }
 else {
    dismissSubWindow(currentTab);
    if (!urlData.isEmpty()) {
      urlData.loadIn(currentTab.getWebView());
    }
  }
  return currentTab;
}
Program: 185010
Project: 185010
Buggy source:
public void onClick(View v){
  ba.openTabAndShow(BrowserActivity.EMPTY_URL_DATA,false,null);
}

Fixed version (ground truth):
public void onClick(View v){
  ba.openTabAndShow(BrowserActivity.EMPTY_URL_DATA,false,null);
  ba.bookmarksOrHistoryPicker(false,true);
}
Program: 185011
Project: 185011
Buggy source:
/** 
 * Override from AdapterView.  Using simple OnClickListeners overrides the GestureDetector.OnGestureListener, so we handle it here.
 */
public boolean performItemClick(View view,int position,long id){
  if (!(view instanceof TitleBar)) {
    return super.performItemClick(view,position,id);
  }
  if (null == mLastTouchUp) {
    return false;
  }
  TitleBar titleBar=(TitleBar)view;
  if (titleBar != getTitleBarAt(position)) {
    return false;
  }
  if (titleBar.hitRightButton((int)mLastTouchUp.getX() - mScrollX,(int)mLastTouchUp.getY() - mScrollY)) {
    if (titleBar.isInLoad()) {
      WebView webView=titleBar.getWebView();
      if (null == webView) {
        return false;
      }
      webView.stopLoading();
    }
 else {
      mBrowserActivity.closeCurrentWindow();
    }
  }
 else {
    mBrowserActivity.bookmarksOrHistoryPicker(false);
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Override from AdapterView.  Using simple OnClickListeners overrides the GestureDetector.OnGestureListener, so we handle it here.
 */
public boolean performItemClick(View view,int position,long id){
  if (!(view instanceof TitleBar)) {
    return super.performItemClick(view,position,id);
  }
  if (null == mLastTouchUp) {
    return false;
  }
  TitleBar titleBar=(TitleBar)view;
  if (titleBar != getTitleBarAt(position)) {
    return false;
  }
  if (titleBar.hitRightButton((int)mLastTouchUp.getX() - mScrollX,(int)mLastTouchUp.getY() - mScrollY)) {
    if (titleBar.isInLoad()) {
      WebView webView=titleBar.getWebView();
      if (null == webView) {
        return false;
      }
      webView.stopLoading();
    }
 else {
      mBrowserActivity.closeCurrentWindow();
    }
  }
 else {
    mBrowserActivity.bookmarksOrHistoryPicker(false,false);
  }
  return true;
}
Program: 185012
Project: 185012
Buggy source:
/** 
 * Set the owning BrowserActivity.  Necessary so that we can call methods on it.
 */
void setBrowserActivity(final BrowserActivity ba){
  mBrowserActivity=ba;
  View.OnClickListener listener=new View.OnClickListener(){
    public void onClick(    View v){
      ba.openTabAndShow(BrowserActivity.EMPTY_URL_DATA,false,null);
    }
  }
;
  mNewButton.findViewById(R.id.button).setOnClickListener(listener);
}

Fixed version (ground truth):
/** 
 * Set the owning BrowserActivity.  Necessary so that we can call methods on it.
 */
void setBrowserActivity(final BrowserActivity ba){
  mBrowserActivity=ba;
  View.OnClickListener listener=new View.OnClickListener(){
    public void onClick(    View v){
      ba.openTabAndShow(BrowserActivity.EMPTY_URL_DATA,false,null);
      ba.bookmarksOrHistoryPicker(false,true);
    }
  }
;
  mNewButton.findViewById(R.id.button).setOnClickListener(listener);
}
Program: 185013
Project: 185013
Buggy source:
/** 
 * Switch tabs.  Called by the TitleBarSet when sliding the title bar results in changing tabs.
 */
void switchToTab(int index){
  TabControl.Tab tab=mTabControl.getTab(index);
  TabControl.Tab currentTab=mTabControl.getCurrentTab();
  if (tab == null || tab == currentTab) {
    return;
  }
  if (currentTab != null) {
    removeTabFromContentView(currentTab);
  }
  removeTabFromContentView(tab);
  mTabControl.setCurrentTab(tab);
  attachTabToContentView(tab);
}

Fixed version (ground truth):
/** 
 * Switch tabs.  Called by the TitleBarSet when sliding the title bar results in changing tabs.
 * @param index Index of the tab to change to, as defined bymTabControl.getTabIndex(Tab t).
 * @return boolean True if we successfully switched to a different tab.  Ifthe indexth tab is null, or if that tab is the same as the current one, return false.
 */
boolean switchToTab(int index){
  TabControl.Tab tab=mTabControl.getTab(index);
  TabControl.Tab currentTab=mTabControl.getCurrentTab();
  if (tab == null || tab == currentTab) {
    return false;
  }
  if (currentTab != null) {
    removeTabFromContentView(currentTab);
  }
  removeTabFromContentView(tab);
  mTabControl.setCurrentTab(tab);
  attachTabToContentView(tab);
  return true;
}
Program: 185014
Project: 185014
Buggy source:
void bookmarksOrHistoryPicker(boolean startWithHistory){
  WebView current=mTabControl.getCurrentWebView();
  if (current == null) {
    return;
  }
  Intent intent=new Intent(this,CombinedBookmarkHistoryActivity.class);
  String title=current.getTitle();
  String url=current.getUrl();
  if (null == url) {
    url=mLastEnteredUrl;
    if (null == url) {
      url=mSettings.getHomePage();
    }
  }
  if (title == null) {
    title=url;
  }
  intent.putExtra("String_Node_Str",title);
  intent.putExtra("String_Node_Str",url);
  intent.putExtra("String_Node_Str",mTabControl.getTabCount() >= TabControl.MAX_TABS);
  intent.putExtra("String_Node_Str",current.getTouchIconUrl());
  if (startWithHistory) {
    intent.putExtra(CombinedBookmarkHistoryActivity.STARTING_TAB,CombinedBookmarkHistoryActivity.HISTORY_TAB);
  }
  startActivityForResult(intent,COMBO_PAGE);
}

Fixed version (ground truth):
/** 
 * Open the Go page.
 * @param startWithHistory If true, open starting on the history tab.Otherwise, start with the bookmarks tab.
 * @param cancelGoPageMeansClose Set to true if this came from a new tab, orfrom the only tab, and canceling means to close the tab (and possibly the browser)
 */
void bookmarksOrHistoryPicker(boolean startWithHistory,boolean cancelGoPageMeansClose){
  WebView current=mTabControl.getCurrentWebView();
  if (current == null) {
    return;
  }
  Intent intent=new Intent(this,CombinedBookmarkHistoryActivity.class);
  String title=current.getTitle();
  String url=current.getUrl();
  if (null == url) {
    url=mLastEnteredUrl;
    if (null == url) {
      url=mSettings.getHomePage();
    }
  }
  if (title == null) {
    title=url;
  }
  intent.putExtra("String_Node_Str",title);
  intent.putExtra("String_Node_Str",url);
  intent.putExtra("String_Node_Str",mTabControl.getTabCount() >= TabControl.MAX_TABS);
  intent.putExtra("String_Node_Str",current.getTouchIconUrl());
  if (startWithHistory) {
    intent.putExtra(CombinedBookmarkHistoryActivity.STARTING_TAB,CombinedBookmarkHistoryActivity.HISTORY_TAB);
  }
  mCancelGoPageMeansClose=cancelGoPageMeansClose;
  startActivityForResult(intent,COMBO_PAGE);
}
Program: 185015
Project: 185015
Buggy source:
void closeCurrentWindow(){
  final int currentIndex=mTabControl.getCurrentIndex();
  final TabControl.Tab current=mTabControl.getCurrentTab();
  final TabControl.Tab parent=current.getParentTab();
  int indexToShow=-1;
  if (parent != null) {
    indexToShow=mTabControl.getTabIndex(parent);
  }
 else {
    indexToShow=mTabControl.getTabCount() - 1;
    if (currentIndex == indexToShow) {
      indexToShow--;
    }
  }
  switchToTab(indexToShow);
  closeTab(current);
}

Fixed version (ground truth):
void closeCurrentWindow(){
  final TabControl.Tab current=mTabControl.getCurrentTab();
  if (mTabControl.getTabCount() == 1) {
    TabControl.Tab newTab=openTabAndShow(BrowserActivity.EMPTY_URL_DATA,false,null);
    bookmarksOrHistoryPicker(false,true);
    closeTab(current);
    mTabControl.setCurrentTab(newTab);
    return;
  }
  final TabControl.Tab parent=current.getParentTab();
  int indexToShow=-1;
  if (parent != null) {
    indexToShow=mTabControl.getTabIndex(parent);
  }
 else {
    final int currentIndex=mTabControl.getCurrentIndex();
    indexToShow=currentIndex + 1;
    if (indexToShow > mTabControl.getTabCount() - 1) {
      indexToShow=currentIndex - 1;
    }
  }
  if (switchToTab(indexToShow)) {
    closeTab(current);
  }
}
Program: 185016
Project: 185016
Buggy source:
@Override protected void onActivityResult(int requestCode,int resultCode,Intent intent){
switch (requestCode) {
case COMBO_PAGE:
    if (resultCode == RESULT_OK && intent != null) {
      String data=intent.getAction();
      Bundle extras=intent.getExtras();
      if (extras != null && extras.getBoolean("String_Node_Str",false)) {
        final TabControl.Tab newTab=openTab(data);
        if (mSettings.openInBackground() && newTab != null) {
          mTabControl.populatePickerData(newTab);
          mTabControl.setCurrentTab(newTab);
          int newIndex=mTabControl.getCurrentIndex();
          if (CUSTOM_BROWSER_BAR) {
            mTitleBar.setCurrentTab(newIndex);
          }
        }
      }
 else {
        final TabControl.Tab currentTab=mTabControl.getCurrentTab();
        dismissSubWindow(currentTab);
        if (data != null && data.length() != 0) {
          getTopWindow().loadUrl(data);
        }
      }
    }
  break;
default :
break;
}
getTopWindow().requestFocus();
}

Fixed version (ground truth):
@Override protected void onActivityResult(int requestCode,int resultCode,Intent intent){
switch (requestCode) {
case COMBO_PAGE:
    if (resultCode == RESULT_OK && intent != null) {
      String data=intent.getAction();
      Bundle extras=intent.getExtras();
      if (extras != null && extras.getBoolean("String_Node_Str",false)) {
        final TabControl.Tab newTab=openTab(data);
        if (mSettings.openInBackground() && newTab != null) {
          mTabControl.populatePickerData(newTab);
          mTabControl.setCurrentTab(newTab);
          int newIndex=mTabControl.getCurrentIndex();
          if (CUSTOM_BROWSER_BAR) {
            mTitleBar.setCurrentTab(newIndex);
          }
        }
      }
 else {
        final TabControl.Tab currentTab=mTabControl.getCurrentTab();
        dismissSubWindow(currentTab);
        if (data != null && data.length() != 0) {
          getTopWindow().loadUrl(data);
        }
      }
    }
 else     if (resultCode == RESULT_CANCELED && mCancelGoPageMeansClose) {
      if (mTabControl.getTabCount() == 1) {
        finish();
        return;
      }
      closeCurrentWindow();
    }
  break;
default :
break;
}
mCancelGoPageMeansClose=false;
if (getTopWindow() != null) {
getTopWindow().requestFocus();
}
}
Program: 185018
Project: 185018
Buggy source:
public KeyTracker.State onKeyTracker(int keyCode,KeyEvent event,KeyTracker.Stage stage,int duration){
  WebView topWindow=getTopWindow();
  if (topWindow == null && mCustomView == null)   return KeyTracker.State.NOT_TRACKING;
  if (keyCode == KeyEvent.KEYCODE_BACK) {
    if (mCustomView != null) {
      mWebChromeClient.onHideCustomView();
      return KeyTracker.State.DONE_TRACKING;
    }
    if (stage == KeyTracker.Stage.LONG_REPEAT) {
      bookmarksOrHistoryPicker(true);
      return KeyTracker.State.DONE_TRACKING;
    }
 else     if (stage == KeyTracker.Stage.UP) {
      WebView subwindow=mTabControl.getCurrentSubWindow();
      if (subwindow != null) {
        if (subwindow.canGoBack()) {
          subwindow.goBack();
        }
 else {
          dismissSubWindow(mTabControl.getCurrentTab());
        }
      }
 else {
        goBackOnePageOrQuit();
      }
      return KeyTracker.State.DONE_TRACKING;
    }
    return KeyTracker.State.KEEP_TRACKING;
  }
  return KeyTracker.State.NOT_TRACKING;
}

Fixed version (ground truth):
public KeyTracker.State onKeyTracker(int keyCode,KeyEvent event,KeyTracker.Stage stage,int duration){
  WebView topWindow=getTopWindow();
  if (topWindow == null && mCustomView == null)   return KeyTracker.State.NOT_TRACKING;
  if (keyCode == KeyEvent.KEYCODE_BACK) {
    if (mCustomView != null) {
      mWebChromeClient.onHideCustomView();
      return KeyTracker.State.DONE_TRACKING;
    }
    if (stage == KeyTracker.Stage.LONG_REPEAT) {
      bookmarksOrHistoryPicker(true,false);
      return KeyTracker.State.DONE_TRACKING;
    }
 else     if (stage == KeyTracker.Stage.UP) {
      WebView subwindow=mTabControl.getCurrentSubWindow();
      if (subwindow != null) {
        if (subwindow.canGoBack()) {
          subwindow.goBack();
        }
 else {
          dismissSubWindow(mTabControl.getCurrentTab());
        }
      }
 else {
        goBackOnePageOrQuit();
      }
      return KeyTracker.State.DONE_TRACKING;
    }
    return KeyTracker.State.KEEP_TRACKING;
  }
  return KeyTracker.State.NOT_TRACKING;
}
Program: 185020
Project: 185020
Buggy source:
TabControl.Tab openTabAndShow(UrlData urlData,boolean closeOnExit,String appId){
  final boolean newTab=mTabControl.getTabCount() != TabControl.MAX_TABS;
  final TabControl.Tab currentTab=mTabControl.getCurrentTab();
  if (newTab) {
    final TabControl.Tab tab=mTabControl.createNewTab(closeOnExit,appId,urlData.mUrl);
    WebView webview=tab.getWebView();
    if (CUSTOM_BROWSER_BAR) {
      mTitleBar.addTab(webview,true);
    }
    removeTabFromContentView(currentTab);
    attachTabToContentView(tab);
    mTabControl.setCurrentTab(tab);
    if (urlData.isEmpty()) {
      bookmarksOrHistoryPicker(false);
    }
 else {
      urlData.loadIn(webview);
    }
    return tab;
  }
 else {
    dismissSubWindow(currentTab);
    if (!urlData.isEmpty()) {
      urlData.loadIn(currentTab.getWebView());
    }
 else {
      bookmarksOrHistoryPicker(false);
    }
  }
  return currentTab;
}

Fixed version (ground truth):
TabControl.Tab openTabAndShow(UrlData urlData,boolean closeOnExit,String appId){
  final boolean newTab=mTabControl.getTabCount() != TabControl.MAX_TABS;
  final TabControl.Tab currentTab=mTabControl.getCurrentTab();
  if (newTab) {
    final TabControl.Tab tab=mTabControl.createNewTab(closeOnExit,appId,urlData.mUrl);
    WebView webview=tab.getWebView();
    if (CUSTOM_BROWSER_BAR) {
      mTitleBar.addTab(webview,true);
    }
    removeTabFromContentView(currentTab);
    attachTabToContentView(tab);
    mTabControl.setCurrentTab(tab);
    if (!urlData.isEmpty()) {
      urlData.loadIn(webview);
    }
    return tab;
  }
 else {
    dismissSubWindow(currentTab);
    if (!urlData.isEmpty()) {
      urlData.loadIn(currentTab.getWebView());
    }
  }
  return currentTab;
}
Program: 185021
Project: 185021
Buggy source:
public void onClick(View v){
  ba.openTabAndShow(BrowserActivity.EMPTY_URL_DATA,false,null);
}

Fixed version (ground truth):
public void onClick(View v){
  ba.openTabAndShow(BrowserActivity.EMPTY_URL_DATA,false,null);
  ba.bookmarksOrHistoryPicker(false,true);
}
Program: 185022
Project: 185022
Buggy source:
/** 
 * Override from AdapterView.  Using simple OnClickListeners overrides the GestureDetector.OnGestureListener, so we handle it here.
 */
public boolean performItemClick(View view,int position,long id){
  if (!(view instanceof TitleBar)) {
    return super.performItemClick(view,position,id);
  }
  if (null == mLastTouchUp) {
    return false;
  }
  TitleBar titleBar=(TitleBar)view;
  if (titleBar != getTitleBarAt(position)) {
    return false;
  }
  if (titleBar.hitRightButton((int)mLastTouchUp.getX() - mScrollX,(int)mLastTouchUp.getY() - mScrollY)) {
    if (titleBar.isInLoad()) {
      WebView webView=titleBar.getWebView();
      if (null == webView) {
        return false;
      }
      webView.stopLoading();
    }
 else {
      mBrowserActivity.closeCurrentWindow();
    }
  }
 else {
    mBrowserActivity.bookmarksOrHistoryPicker(false);
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Override from AdapterView.  Using simple OnClickListeners overrides the GestureDetector.OnGestureListener, so we handle it here.
 */
public boolean performItemClick(View view,int position,long id){
  if (!(view instanceof TitleBar)) {
    return super.performItemClick(view,position,id);
  }
  if (null == mLastTouchUp) {
    return false;
  }
  TitleBar titleBar=(TitleBar)view;
  if (titleBar != getTitleBarAt(position)) {
    return false;
  }
  if (titleBar.hitRightButton((int)mLastTouchUp.getX() - mScrollX,(int)mLastTouchUp.getY() - mScrollY)) {
    if (titleBar.isInLoad()) {
      WebView webView=titleBar.getWebView();
      if (null == webView) {
        return false;
      }
      webView.stopLoading();
    }
 else {
      mBrowserActivity.closeCurrentWindow();
    }
  }
 else {
    mBrowserActivity.bookmarksOrHistoryPicker(false,false);
  }
  return true;
}
Program: 185023
Project: 185023
Buggy source:
/** 
 * Set the owning BrowserActivity.  Necessary so that we can call methods on it.
 */
void setBrowserActivity(final BrowserActivity ba){
  mBrowserActivity=ba;
  View.OnClickListener listener=new View.OnClickListener(){
    public void onClick(    View v){
      ba.openTabAndShow(BrowserActivity.EMPTY_URL_DATA,false,null);
    }
  }
;
  mNewButton.findViewById(R.id.button).setOnClickListener(listener);
}

Fixed version (ground truth):
/** 
 * Set the owning BrowserActivity.  Necessary so that we can call methods on it.
 */
void setBrowserActivity(final BrowserActivity ba){
  mBrowserActivity=ba;
  View.OnClickListener listener=new View.OnClickListener(){
    public void onClick(    View v){
      ba.openTabAndShow(BrowserActivity.EMPTY_URL_DATA,false,null);
      ba.bookmarksOrHistoryPicker(false,true);
    }
  }
;
  mNewButton.findViewById(R.id.button).setOnClickListener(listener);
}
Program: 185024
Project: 185024
Buggy source:
private void goBackOnePageOrQuit(){
  TabControl.Tab current=mTabControl.getCurrentTab();
  if (current == null) {
    moveTaskToBack(true);
  }
  WebView w=current.getWebView();
  if (w.canGoBack()) {
    w.goBack();
  }
 else {
    TabControl.Tab parent=current.getParentTab();
    if (parent != null) {
      switchTabs(mTabControl.getCurrentIndex(),mTabControl.getTabIndex(parent),true);
    }
 else {
      if (current.closeOnExit()) {
        if (mTabControl.getTabCount() == 1) {
          finish();
          return;
        }
        pauseWebView();
        removeTabFromContentView(current);
        mTabControl.removeTab(current);
      }
      moveTaskToBack(true);
    }
  }
}

Fixed version (ground truth):
private void goBackOnePageOrQuit(){
  TabControl.Tab current=mTabControl.getCurrentTab();
  if (current == null) {
    moveTaskToBack(true);
  }
  WebView w=current.getWebView();
  if (w.canGoBack()) {
    w.goBack();
  }
 else {
    TabControl.Tab parent=current.getParentTab();
    if (parent != null) {
      switchTabs(mTabControl.getCurrentIndex(),mTabControl.getTabIndex(parent),true);
    }
 else {
      if (current.closeOnExit()) {
        if (mTabControl.getTabCount() == 1) {
          finish();
          return;
        }
        boolean savedState=mActivityInPause;
        if (savedState) {
          Log.e(LOGTAG,"String_Node_Str" + "String_Node_Str");
        }
        mActivityInPause=true;
        pauseWebView();
        mActivityInPause=savedState;
        removeTabFromContentView(current);
        mTabControl.removeTab(current);
      }
      moveTaskToBack(true);
    }
  }
}