2018-08-27 00:33:39 +02:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
(function(){
|
|
|
|
"use strict";
|
|
|
|
|
2019-11-28 01:26:35 +01:00
|
|
|
let scope;
|
2018-08-27 00:33:39 +02:00
|
|
|
if ((typeof exports) !== "undefined"){
|
|
|
|
scope = exports;
|
|
|
|
}
|
|
|
|
else {
|
2019-03-12 22:24:23 +01:00
|
|
|
scope = require.register("./modifiedWindowAPI", {});
|
2018-08-27 00:33:39 +02:00
|
|
|
}
|
|
|
|
|
2019-12-10 15:07:22 +01:00
|
|
|
const {checkerWrapper, setGetterProperties, getStatusByFlag} = require("./modifiedAPIFunctions");
|
2018-08-27 00:33:39 +02:00
|
|
|
|
|
|
|
const windowNames = new WeakMap();
|
|
|
|
scope.changedGetters = [
|
|
|
|
{
|
|
|
|
objectGetters: [function(window){return window;}],
|
|
|
|
name: "opener",
|
|
|
|
getterGenerator: function(checker){
|
|
|
|
const temp = {
|
|
|
|
get opener(){
|
|
|
|
return checkerWrapper(checker, this, arguments, function(args, check){
|
2019-12-29 23:40:39 +01:00
|
|
|
const {notify, original} = check;
|
|
|
|
const originalOpener = original.call(this, ...args);
|
2018-08-27 00:33:39 +02:00
|
|
|
if (originalOpener !== null){
|
|
|
|
notify("fakedWindowReadout");
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
return Object.getOwnPropertyDescriptor(temp, "opener").get;
|
2019-08-16 17:34:16 +02:00
|
|
|
},
|
|
|
|
valueGenerator: function({original, notify}){
|
|
|
|
if (original !== null){
|
|
|
|
notify("fakedWindowReadout");
|
|
|
|
}
|
|
|
|
return null;
|
2018-08-27 00:33:39 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
objectGetters: [function(window){return window;}],
|
|
|
|
name: "name",
|
|
|
|
getterGenerator: function(checker){
|
|
|
|
const temp = {
|
|
|
|
get name(){
|
|
|
|
return checkerWrapper(checker, this, arguments, function(args, check){
|
2020-01-02 11:41:13 +01:00
|
|
|
const {notify, original, prefs} = check;
|
2019-12-29 23:40:39 +01:00
|
|
|
const originalName = original.call(this, ...args);
|
2020-01-02 11:41:13 +01:00
|
|
|
if (
|
|
|
|
this !== this.top &&
|
|
|
|
prefs("allowWindowNameInFrames", this.location)
|
|
|
|
){
|
|
|
|
return originalName;
|
|
|
|
}
|
2020-01-01 00:30:16 +01:00
|
|
|
const returnedName = windowNames.get(this) || "";
|
2018-08-27 00:33:39 +02:00
|
|
|
if (originalName !== returnedName){
|
|
|
|
notify("fakedWindowReadout");
|
|
|
|
}
|
|
|
|
return returnedName;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
return Object.getOwnPropertyDescriptor(temp, "name").get;
|
|
|
|
},
|
|
|
|
setterGenerator: function(window, original){
|
|
|
|
const temp = {
|
|
|
|
set name(name){
|
2019-12-29 23:40:39 +01:00
|
|
|
original.call(this, ...arguments);
|
2020-01-01 00:30:16 +01:00
|
|
|
windowNames.set(this, name);
|
2018-08-27 00:33:39 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
return Object.getOwnPropertyDescriptor(temp, "name").set;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2019-12-10 15:07:22 +01:00
|
|
|
setGetterProperties(scope.changedGetters, {
|
|
|
|
type: "readout",
|
|
|
|
getStatus: getStatusByFlag("protectWindow"),
|
|
|
|
api: "window"
|
2018-08-27 00:33:39 +02:00
|
|
|
});
|
|
|
|
}());
|