Step 1Combine the onions and 2 tablespoons of the oil in a large skillet. Cook, covered, over medium heat until the onions soften, about 15 minutes. Stir to make sure the onions aren't scorching, replace the cover and reduce the heat to low. Continue cooking, stirring occasionally, until the onions are golden and sweet, about 45 minutes more. Remove from the heat and cool.
Step 2Cut the tomatoes in half vertically and then slice each half horizontally as thinly as you can. Arrange the sliced tomatoes on several jelly roll pans and sprinkle liberally with salt. Set the pans at a 5-inch slant and let the tomatoes give up their liquid for at least an hour.
Step 3Heat the oven to 400 degrees. Place a baking sheet in the oven to heat. Unfold the puff pastry sheets. Break the egg into a bowl and lightly beat with a fork. Use a pastry brush to paint a 1-inch strip of egg wash along one narrow side of one puff pastry sheet. Arrange the second sheet so it is overlapping just along the painted edge and press to seal. The puff pastry should be about 18 1/2 inches long by 9 1/2 inches wide.
Step 4Transfer the pastry to a baking sheet lined with parchment paper. Sprinkle the bread crumbs down the center, leaving a 2-inch wide border around the pastry sheet. Scatter the cooled cooked onions on top of the bread crumbs. (They are a seasoning only and will not make a uniform layer.) Place the tomato slices on paper towels and pat dry to remove excess moisture. (Reserve tomato water for another use.) Arrange the tomatoes down the center in overlapping slices and alternating colors on top of the onions. Drizzle the 2 teaspoons of oil over the top of the tomatoes. Scatter the pitted olives over the tomatoes and then the shaved pecorino over everything.
Step 5Fold the top and bottom edges of the puff pastry over to barely overlap the tomato filling. Cut out a 1-inch square from each of four corners so when you fold over the sides the corners will not be too thick. Brush the egg wash to seal the corners so they don't open during baking. Paint the borders with egg wash and place on the heated baking sheet. Bake until the pastry is puffed and dark brown, about 30 minutes.
Step 6Remove from the oven and scatter the torn basil leaves over the top. Let cool to room temperature before serving.