Commit 5ca8f28f authored by wangmingming's avatar wangmingming

333

parent fd388530
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -3,7 +3,7 @@ let proxy = function (tt, name) { ...@@ -3,7 +3,7 @@ let proxy = function (tt, name) {
get(target, p, receiver) { get(target, p, receiver) {
let res = Reflect.get(target, p, receiver); let res = Reflect.get(target, p, receiver);
console.log(`${name} get`, p, typeof res) console.log(`${name} get`, p, typeof res)
if (!['_registeredHandlers', 'window', '_currentEvent', '_eventListenerss'].includes(p) && res && typeof res === 'object' && typeof p !== 'symbol') { if (!['_registeredHandlers', 'window', '_currentEvent', '_eventListenerss','JSON','Math','JSON'].includes(p) && res && typeof res === 'object' && typeof p !== 'symbol') {
return proxy(res, `${name}.${p}`) return proxy(res, `${name}.${p}`)
} }
return res; return res;
...@@ -274,7 +274,7 @@ function Window(options) { ...@@ -274,7 +274,7 @@ function Window(options) {
// } // }
// console.log(Reflect.get(target, '_cf_chl_ctx', receiver)) // console.log(Reflect.get(target, '_cf_chl_ctx', receiver))
if (!['_registeredHandlers', 'window', '_currentEvent', 'performance','debug','_eventListenerss','top'].includes(p) && res && typeof res === 'object' && typeof p !== 'symbol') { if (!['_registeredHandlers', 'window', '_currentEvent', 'performance','debug','_eventListenerss','top','JSON', 'Math'].includes(p) && res && typeof res === 'object' && typeof p !== 'symbol') {
return proxy(res, p) return proxy(res, p)
} }
return res; return res;
......
...@@ -274,6 +274,7 @@ exports.install = (globalObject, globalNames) => { ...@@ -274,6 +274,7 @@ exports.install = (globalObject, globalNames) => {
} }
get userAgent() { get userAgent() {
return window.fingerprint.navigator.userAgent;
const esValue = this !== null && this !== undefined ? this : globalObject; const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) { if (!exports.is(esValue)) {
......
...@@ -9,165 +9,245 @@ const ctorRegistrySymbol = utils.ctorRegistrySymbol; ...@@ -9,165 +9,245 @@ const ctorRegistrySymbol = utils.ctorRegistrySymbol;
const interfaceName = "Screen"; const interfaceName = "Screen";
exports.is = value => { exports.is = value => {
return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation; return utils.isObject(value) && utils.hasOwn(value, implSymbol) && value[implSymbol] instanceof Impl.implementation;
}; };
exports.isImpl = value => { exports.isImpl = value => {
return utils.isObject(value) && value instanceof Impl.implementation; return utils.isObject(value) && value instanceof Impl.implementation;
}; };
exports.convert = (value, { context = "The provided value" } = {}) => { exports.convert = (value, {context = "The provided value"} = {}) => {
if (exports.is(value)) { if (exports.is(value)) {
return utils.implForWrapper(value); return utils.implForWrapper(value);
} }
throw new TypeError(`${context} is not of type 'Screen'.`); throw new TypeError(`${context} is not of type 'Screen'.`);
}; };
function makeWrapper(globalObject) { function makeWrapper(globalObject) {
if (globalObject[ctorRegistrySymbol] === undefined) { if (globalObject[ctorRegistrySymbol] === undefined) {
throw new Error("Internal error: invalid global object"); throw new Error("Internal error: invalid global object");
} }
const ctor = globalObject[ctorRegistrySymbol]["Screen"]; const ctor = globalObject[ctorRegistrySymbol]["Screen"];
if (ctor === undefined) { if (ctor === undefined) {
throw new Error("Internal error: constructor Screen is not installed on the passed global object"); throw new Error("Internal error: constructor Screen is not installed on the passed global object");
} }
return Object.create(ctor.prototype); return Object.create(ctor.prototype);
} }
exports.create = (globalObject, constructorArgs, privateData) => { exports.create = (globalObject, constructorArgs, privateData) => {
const wrapper = makeWrapper(globalObject); const wrapper = makeWrapper(globalObject);
return exports.setup(wrapper, globalObject, constructorArgs, privateData); return exports.setup(wrapper, globalObject, constructorArgs, privateData);
}; };
exports.createImpl = (globalObject, constructorArgs, privateData) => { exports.createImpl = (globalObject, constructorArgs, privateData) => {
const wrapper = exports.create(globalObject, constructorArgs, privateData); const wrapper = exports.create(globalObject, constructorArgs, privateData);
return utils.implForWrapper(wrapper); return utils.implForWrapper(wrapper);
}; };
exports._internalSetup = (wrapper, globalObject) => {}; exports._internalSetup = (wrapper, globalObject) => {
};
exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => { exports.setup = (wrapper, globalObject, constructorArgs = [], privateData = {}) => {
privateData.wrapper = wrapper; privateData.wrapper = wrapper;
exports._internalSetup(wrapper, globalObject); exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, { Object.defineProperty(wrapper, implSymbol, {
value: new Impl.implementation(globalObject, constructorArgs, privateData), value: new Impl.implementation(globalObject, constructorArgs, privateData),
configurable: true configurable: true
}); });
wrapper[implSymbol][utils.wrapperSymbol] = wrapper; wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) { if (Impl.init) {
Impl.init(wrapper[implSymbol]); Impl.init(wrapper[implSymbol]);
} }
return wrapper; return wrapper;
}; };
exports.new = globalObject => { exports.new = globalObject => {
const wrapper = makeWrapper(globalObject); const wrapper = makeWrapper(globalObject);
exports._internalSetup(wrapper, globalObject); exports._internalSetup(wrapper, globalObject);
Object.defineProperty(wrapper, implSymbol, { Object.defineProperty(wrapper, implSymbol, {
value: Object.create(Impl.implementation.prototype), value: Object.create(Impl.implementation.prototype),
configurable: true configurable: true
}); });
wrapper[implSymbol][utils.wrapperSymbol] = wrapper; wrapper[implSymbol][utils.wrapperSymbol] = wrapper;
if (Impl.init) { if (Impl.init) {
Impl.init(wrapper[implSymbol]); Impl.init(wrapper[implSymbol]);
} }
return wrapper[implSymbol]; return wrapper[implSymbol];
}; };
const exposed = new Set(["Window"]); const exposed = new Set(["Window"]);
exports.install = (globalObject, globalNames) => { exports.install = (globalObject, globalNames) => {
if (!globalNames.some(globalName => exposed.has(globalName))) { if (!globalNames.some(globalName => exposed.has(globalName))) {
return; return;
}
class Screen {
constructor() {
throw new TypeError("Illegal constructor");
} }
get availWidth() { class Screen {
const esValue = this !== null && this !== undefined ? this : globalObject; constructor() {
throw new TypeError("Illegal constructor");
}
if (!exports.is(esValue)) { get availWidth() {
throw new TypeError("'get availWidth' called on an object that is not a valid instance of Screen."); return window.fingerprint.screen.availWidth;
}
return esValue[implSymbol]["availWidth"]; const esValue = this !== null && this !== undefined ? this : globalObject;
}
get availHeight() { if (!exports.is(esValue)) {
const esValue = this !== null && this !== undefined ? this : globalObject; throw new TypeError("'get availWidth' called on an object that is not a valid instance of Screen.");
}
if (!exports.is(esValue)) { return esValue[implSymbol]["availWidth"];
throw new TypeError("'get availHeight' called on an object that is not a valid instance of Screen."); }
}
return esValue[implSymbol]["availHeight"]; get availHeight() {
} return window.fingerprint.screen.availHeight;
get width() { const esValue = this !== null && this !== undefined ? this : globalObject;
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) { if (!exports.is(esValue)) {
throw new TypeError("'get width' called on an object that is not a valid instance of Screen."); throw new TypeError("'get availHeight' called on an object that is not a valid instance of Screen.");
} }
return esValue[implSymbol]["width"]; return esValue[implSymbol]["availHeight"];
} }
get height() { get width() {
const esValue = this !== null && this !== undefined ? this : globalObject; return window.fingerprint.screen.width;
if (!exports.is(esValue)) { const esValue = this !== null && this !== undefined ? this : globalObject;
throw new TypeError("'get height' called on an object that is not a valid instance of Screen.");
}
return esValue[implSymbol]["height"]; if (!exports.is(esValue)) {
} throw new TypeError("'get width' called on an object that is not a valid instance of Screen.");
}
get colorDepth() { return esValue[implSymbol]["width"];
const esValue = this !== null && this !== undefined ? this : globalObject; }
if (!exports.is(esValue)) { get height() {
throw new TypeError("'get colorDepth' called on an object that is not a valid instance of Screen."); return window.fingerprint.screen.height;
}
return esValue[implSymbol]["colorDepth"]; const esValue = this !== null && this !== undefined ? this : globalObject;
}
if (!exports.is(esValue)) {
throw new TypeError("'get height' called on an object that is not a valid instance of Screen.");
}
return esValue[implSymbol]["height"];
}
get colorDepth() {
return window.fingerprint.screen.colorDepth;
const esValue = this !== null && this !== undefined ? this : globalObject;
get pixelDepth() { if (!exports.is(esValue)) {
const esValue = this !== null && this !== undefined ? this : globalObject; throw new TypeError("'get colorDepth' called on an object that is not a valid instance of Screen.");
}
if (!exports.is(esValue)) { return esValue[implSymbol]["colorDepth"];
throw new TypeError("'get pixelDepth' called on an object that is not a valid instance of Screen."); }
}
return esValue[implSymbol]["pixelDepth"]; get pixelDepth() {
return window.fingerprint.screen.pixelDepth;
const esValue = this !== null && this !== undefined ? this : globalObject;
if (!exports.is(esValue)) {
throw new TypeError("'get pixelDepth' called on an object that is not a valid instance of Screen.");
}
return esValue[implSymbol]["pixelDepth"];
}
get availTop() {
return window.fingerprint.screen.availTop
}
get availLeft() {
return window.fingerprint.screen.availLeft
}
get innerHeight() {
return window.fingerprint.screen.innerHeight
}
get outerHeight() {
return window.fingerprint.screen.outerHeight
}
get outerWidth() {
return window.fingerprint.screen.outerWidth
}
get innerWidth() {
return window.fingerprint.screen.innerWidth
}
get screenX() {
return window.fingerprint.screen.screenX
}
get pageXOffset() {
return window.fingerprint.screen.pageXOffset
}
get pageYOffset() {
return window.fingerprint.screen.pageYOffset
}
get devicePixelRatio() {
return window.fingerprint.screen.devicePixelRatio
}
get clientWidth() {
return window.fingerprint.screen.clientWidth
}
get clientHeight() {
return window.fingerprint.screen.clientHeight
}
get hasHDR() {
return window.fingerprint.screen.hasHDR
}
}
Object.defineProperties(Screen.prototype, {
availWidth: {enumerable: true},
availHeight: {enumerable: true},
width: {enumerable: true},
height: {enumerable: true},
colorDepth: {enumerable: true},
pixelDepth: {enumerable: true},
availTop: {enumerable: true},
availLeft: {enumerable: true},
innerHeight: {enumerable: true},
outerHeight: {enumerable: true},
outerWidth: {enumerable: true},
innerWidth: {enumerable: true},
screenX: {enumerable: true},
pageXOffset: {enumerable: true},
pageYOffset: {enumerable: true},
devicePixelRatio: {enumerable: true},
clientWidth: {enumerable: true},
clientHeight: {enumerable: true},
hasHDR: {enumerable: true},
[Symbol.toStringTag]: {value: "Screen", configurable: true}
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
} }
} globalObject[ctorRegistrySymbol][interfaceName] = Screen;
Object.defineProperties(Screen.prototype, {
availWidth: { enumerable: true }, Object.defineProperty(globalObject, interfaceName, {
availHeight: { enumerable: true }, configurable: true,
width: { enumerable: true }, writable: true,
height: { enumerable: true }, value: Screen
colorDepth: { enumerable: true }, });
pixelDepth: { enumerable: true },
[Symbol.toStringTag]: { value: "Screen", configurable: true }
});
if (globalObject[ctorRegistrySymbol] === undefined) {
globalObject[ctorRegistrySymbol] = Object.create(null);
}
globalObject[ctorRegistrySymbol][interfaceName] = Screen;
Object.defineProperty(globalObject, interfaceName, {
configurable: true,
writable: true,
value: Screen
});
}; };
const Impl = require("../window/Screen-impl.js"); const Impl = require("../window/Screen-impl.js");
...@@ -13,6 +13,7 @@ class NavigatorImpl { ...@@ -13,6 +13,7 @@ class NavigatorImpl {
constructor(globalObject, args, privateData) { constructor(globalObject, args, privateData) {
this._globalObject = globalObject; this._globalObject = globalObject;
this.userAgent = privateData.userAgent; this.userAgent = privateData.userAgent;
// this.userAgent = window.fingerprint.navigator.userAgent;
this.languages = Object.freeze(["en-US", "en"]); this.languages = Object.freeze(["en-US", "en"]);
this.plugins = PluginArray.create(this._globalObject); this.plugins = PluginArray.create(this._globalObject);
this.mimeTypes = MimeTypeArray.create(this._globalObject); this.mimeTypes = MimeTypeArray.create(this._globalObject);
......
...@@ -2,36 +2,51 @@ ...@@ -2,36 +2,51 @@
exports.implementation = class NavigatorIDImpl { exports.implementation = class NavigatorIDImpl {
get appCodeName() { get appCodeName() {
return window.fingerprint.navigator.appCodeName
return "Mozilla"; return "Mozilla";
} }
get appName() { get appName() {
return window.fingerprint.navigator.appName
return "Netscape"; return "Netscape";
} }
get appVersion() { get appVersion() {
return window.fingerprint.navigator.appVersion
return "4.0"; return "4.0";
} }
get platform() { get platform() {
return window.fingerprint.navigator.platform
return ""; return "";
} }
get product() { get product() {
return window.fingerprint.navigator.product
return "Gecko"; return "Gecko";
} }
get productSub() { get productSub() {
return window.fingerprint.navigator.productSub
return "20030107"; return "20030107";
} }
// see Navigator constructor for userAgent // see Navigator constructor for userAgent
get vendor() { get vendor() {
return window.fingerprint.navigator.vendor
return "Apple Computer, Inc."; return "Apple Computer, Inc.";
} }
get vendorSub() { get vendorSub() {
return window.fingerprint.navigator.vendorSub
return ""; return "";
} }
}; };
...@@ -10,4 +10,11 @@ ScreenImpl.prototype.height = 0; ...@@ -10,4 +10,11 @@ ScreenImpl.prototype.height = 0;
ScreenImpl.prototype.colorDepth = 24; ScreenImpl.prototype.colorDepth = 24;
ScreenImpl.prototype.pixelDepth = 24; ScreenImpl.prototype.pixelDepth = 24;
// ScreenImpl.prototype.availWidth = window.fingerprint.screen.availWidth;
// ScreenImpl.prototype.availHeight = window.fingerprint.screen.availHeight;
// ScreenImpl.prototype.width = window.fingerprint.screen.width;
// ScreenImpl.prototype.height = window.fingerprint.screen.height;
// ScreenImpl.prototype.colorDepth = window.fingerprint.screen.colorDepth;
// ScreenImpl.prototype.pixelDepth = window.fingerprint.screen.pixelDepth;
exports.implementation = ScreenImpl; exports.implementation = ScreenImpl;
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment