A Revere man pleaded guilty Thursday to beating and inflicting life-threatening injuries on the 5-year-old son of his girlfriend, prosecutors said. A Suffolk Superior Court judge sentenced Joseph Testa, 30, to six to nine years in prison after he admitted to the charges of assault and battery on a child and reckless endangerment of a child, Suffolk District Attorney Daniel F. Conley’s office said. Testa was arrested in 2011 after witnesses saw him and the injured young boy sitting on a strip of grass next to Revere Beach Parkway, the statement said. Further investigation revealed that Testa had beaten the boy, causing cranial bleeding, the statement said. The boy, who underwent surgery at Massachusetts General Hospital following the beating, is making a full recovery, the district attorney’s office said.