Heat 1 tablespoon oil in a heavy skillet over moderate heat until hot but not smoking, then cook mustard seeds, stirring, until they pop and are 1 shade darker, about 2 minutes. Transfer oil with seeds to a large bowl.
Simmer vinegar and sugar in a small saucepan, stirring, until sugar is dissolved, then cool 5 minutes.
Heat remaining 2 tablespoons oil in cleaned skillet over moderately high heat until hot but not smoking, then cook onion, stirring, until golden brown, 8 to 10 minutes. Remove from heat and stir in vinegar, then add to mustard oil in large bowl.
Have ready a large bowl of ice and cold water.
Cook beans in a pot of boiling salted water until crisp-tender, about 5 minutes. Drain in a colander and plunge into ice water to stop cooking, then drain well.
Toss beans with vinaigrette and salt and pepper, to taste. Serve at room temperature or chilled.