A top adviser to Sen. John McCain said that a terrorist attack in the United States would be a political benefit to the presumptive Republican presidential nominee, a comment that was immediately disputed by the candidate and denounced by his Democratic rival.