Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions javascript/private/fragment.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,18 @@ def closure_fragment(

# Wrap the output in two functions. The outer function ensures the
# compiled fragment never pollutes the global scope by using its
# own scope on each invocation.
# own scope on each invocation. We must import window.navigator into
# this unique scope since Closure's goog.userAgent package assumes
# navigator and document are defined on goog.global. Normally, this
# would be window, but we are explicitly defining the fragment so that
# goog.global is _not_ window.
# See http://code.google.com/p/selenium/issues/detail?id=1333
wrapper = (
"function(){" +
"return (function(){%output%; return this._.apply(null,arguments);}).apply(" +
"window, arguments);}"
"return (function(){%output%; return this._.apply(null,arguments);}).apply({" +
"navigator:typeof window!='undefined'?window.navigator:null," +
"document:typeof window!='undefined'?window.document:null" +
"}, arguments);}"
)

browser_defs = {
Expand Down