Per the GL spec, glUseProgram can take 0 as an argument just like glBindTexture to indicate that the current program should be unbound. If you try this today in WebKit (or Chromium), however, you'll get an exception. The issue is that the check on useProgram and the code inside the Mac implementation of useProgram do not check for this case like bindTexture does.
bindTexture is handled right in the two places that matter (the WebGLRenderingContext and the GraphicsContext3D implementation):
if (texture && texture->context() != this)
::glBindTexture(target, texture ? (GLuint) texture->object() : 0);
useProgram is not handled right - the check at the top of it is copy pasted from other program-related calls, which don't allow null.
if (!program || program->context() != this)
So, trivial fix:
if (program && program->context() != this)
::glUseProgram(program ? (GLuint) program->object() : 0);
Still figuring out how to attach patches and stuff, but it should be easy enough without the 2 line diff :)
The issue was fixed in https://bugs.webkit.org/show_bug.cgi?id=34508. Closing the bug.