Preheat oven to 400°F. On a lightly floured surface, roll pastry to 10-inch square (trim the edges with a paring knife). Place pastry into an 8-inch square baking pan, folding corners to fit. Prick bottom of dough with a fork.
Heat a large skillet over medium-high heat. Add bacon; cook, stirring occasionally, until pieces start to brown, 4 to 5 minutes.
Add onions; cook, stirring occasionally, until bacon is crisp and onions are lightly browned, 5 to 7 minutes. With a slotted spoon, transfer mixture to a plate; let cool slightly, then scatter mixture over pastry shell.
In a small bowl, whisk eggs, cream, ¼ teaspoon salt, and ⅛ teaspoon pepper. Pour egg mixture into pastry shell. Sprinkle Gruyère over top.
Bake until filling is set and top is golden brown, about 40 minutes.
