Index: extensions/renderer/resources/runtime_custom_bindings.js |
diff --git a/extensions/renderer/resources/runtime_custom_bindings.js b/extensions/renderer/resources/runtime_custom_bindings.js |
index 1f829d4deb11abfe83933bb9fc0ec94881e267f1..a0c4e4907d34c24ecf4da8d3dccacc9f90a14c27 100644 |
--- a/extensions/renderer/resources/runtime_custom_bindings.js |
+++ b/extensions/renderer/resources/runtime_custom_bindings.js |
@@ -11,7 +11,14 @@ var runtimeNatives = requireNative('runtime'); |
var process = requireNative('process'); |
var forEach = require('utils').forEach; |
-var backgroundPage = window; |
+var WINDOW = {}; |
Devlin
2016/04/13 19:46:32
Does anything else need to be done here?
lazyboy
2016/04/14 02:07:53
At this point there isn't much we can do, WINDOW i
|
+try { |
+ WINDOW = window; |
+} catch (e) { |
+ // Running in SW context. |
+} |
+ |
+var backgroundPage = WINDOW; |
var backgroundRequire = require; |
var contextType = process.GetContextType(); |
if (contextType == 'BLESSED_EXTENSION' || |
@@ -25,7 +32,7 @@ if (contextType == 'BLESSED_EXTENSION' || |
var GetModuleSystem = requireNative('v8_context').GetModuleSystem; |
backgroundRequire = GetModuleSystem(backgroundPage).require; |
} else { |
- backgroundPage = window; |
+ backgroundPage = WINDOW; |
} |
} |
} |
@@ -34,7 +41,7 @@ if (contextType == 'BLESSED_EXTENSION' || |
// background page so their FileEntry objects have the background page's context |
// as their own. This allows them to be used from other windows (including the |
// background page) after the original window is closed. |
-if (window == backgroundPage) { |
+if (WINDOW == backgroundPage) { |
var lastError = require('lastError'); |
var fileSystemNatives = requireNative('file_system_natives'); |
var GetIsolatedFileSystem = fileSystemNatives.GetIsolatedFileSystem; |