| 1 |
"use strict"; |
| 2 |
var DOMImplementation = require('./DOMImplementation'); |
| 3 |
var EventTarget = require('./EventTarget'); |
| 4 |
var Location = require('./Location'); |
| 5 |
var utils = require('./utils'); |
| 6 |
|
| 7 |
module.exports = Window; |
| 8 |
|
| 9 |
function Window(document) { |
| 10 |
this.document = document || new DOMImplementation(null).createHTMLDocument(""); |
| 11 |
this.document._scripting_enabled = true; |
| 12 |
this.document.defaultView = this; |
| 13 |
this.location = new Location(this, this.document._address || 'about:blank'); |
| 14 |
} |
| 15 |
|
| 16 |
Window.prototype = Object.create(EventTarget.prototype, { |
| 17 |
console: { value: console }, |
| 18 |
history: { value: { |
| 19 |
back: utils.nyi, |
| 20 |
forward: utils.nyi, |
| 21 |
go: utils.nyi |
| 22 |
}}, |
| 23 |
navigator: { value: require("./NavigatorID") }, |
| 24 |
|
| 25 |
|
| 26 |
window: { get: function() { return this; }}, |
| 27 |
self: { get: function() { return this; }}, |
| 28 |
frames: { get: function() { return this; }}, |
| 29 |
|
| 30 |
|
| 31 |
parent: { get: function() { return this; }}, |
| 32 |
top: { get: function() { return this; }}, |
| 33 |
|
| 34 |
|
| 35 |
length: { value: 0 }, |
| 36 |
frameElement: { value: null }, |
| 37 |
opener: { value: null }, |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
onload: { |
| 44 |
get: function() { |
| 45 |
return this._getEventHandler("load"); |
| 46 |
}, |
| 47 |
set: function(v) { |
| 48 |
this._setEventHandler("load", v); |
| 49 |
} |
| 50 |
}, |
| 51 |
|
| 52 |
|
| 53 |
getComputedStyle: { value: function getComputedStyle(elt) { |
| 54 |
return elt.style; |
| 55 |
}} |
| 56 |
|
| 57 |
}); |
| 58 |
|
| 59 |
utils.expose(require('./WindowTimers'), Window); |
| 60 |
utils.expose(require('./impl'), Window); |