Indistinguishable particles in two dimensions can be characterized by anyonic quantum statistics more general than those of bosons or fermions. Such anyons emerge as quasiparticles in fractional quantum Hall states and certain frustrated quantum magnets. Quantum liquids of anyons exhibit degenerate ground states where the degeneracy depends on the topology of the underlying surface. Here we present a novel type of continuous quantum phase transition in such anyonic quantum liquids that is driven by quantum fluctuations of topology. The critical state connecting two anyonic liquids on surfaces with different topologies is reminiscent of the notion of a `quantum foam with fluctuations on all length scales. This exotic quantum phase transition arises in a microscopic model of interacting anyons for which we present an exact solution in a linear geometry. We introduce an intuitive physical picture of this model that unifies string nets and loop gases, and provide a simple description of topological quantum phases and their phase transitions.