document detection that works under ShadowDOMPolyfill; fix logging calls
test must run only after CustomElement document processing