(target, name) {
        if (name == "prototype")
          return beforeDefinition ? proto1 : proto2;
        return target[name];
      }
  });

  w.customElements.define("test-element", ElementWithDynamicPrototype);

  beforeDefinition = false;
  new ElementWithDynamicPrototype();
}, "Use NewTarget's prototype, not the one stored at definition time");

test_with_window(w => {
  // We have to not throw during define(), but throw during super()
  let throws = false;

  let err = { name: "prototype throws" 