Since there was no response to this, here is the hack I ended up using, which should be pretty broadly-applicable to anyone. Presumably this shouldn't be necessary in the near future once Safari adds the document.fullscreenElement specified in the W3 standard.
In my case, the situation was that I had a fullscreen button, and I wanted the fullscreen button to become a "shrink" button when the site was in fullscreen (like YouTube videos). As part of this, I had already implemented the :fullscreen css selectors to turn my button into a "shrink" button whenever the site was fullscreen.
I realized that Safari respected the :-webkit-full-screen css pseudoclass. Therefore, it was quick work to check that my button's image was the "shrink" image (AFAIK you can't test for pseudo-classes directly), and, if it was, we must be fullscreen.
So:
CSS:
.fullscreen-button
background-image: fullscreen.png
/* these match if .fullscreen-button is inside a fullscreen body element
(comma-separated selectors don't seem to work here?) */
body:fullscreen .fullscreen-button
background-image: fullscreen-exit.png
body:-webkit-full-screen .fullscreen-button
background-image: fullscreen-exit.png
body:-moz-full-screen .fullscreen-button
background-image: fullscreen-exit.png
JS:
isFullscreen = function() {
// this doesn't yet exist in Safari
if (document.fullscreenElement
|| document.webkitFullscreenElement
|| document.mozFullScreenElement) {
return true;
}
// annoying hack to check Safari
return ~$(".fullscreen-button").css("background-image").indexOf("exit")
}
This hack should be useable by anyone. Even if you're not doing something like changing the background image of a button in fullscreen mode, you should always be able to make some trivial little css rule change to one element -- especially if it's something that won't actually be visible, like the background-color of an element that's invisible, or the font-size of an element that doesn't have any text -- and test for that in JavaScript.