2018-08-27 00:30:48 +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";
|
|
|
|
|
|
|
|
var scope;
|
|
|
|
if ((typeof exports) !== "undefined"){
|
|
|
|
scope = exports;
|
|
|
|
}
|
|
|
|
else {
|
2019-03-12 22:24:23 +01:00
|
|
|
scope = require.register("./modifiedHistoryAPI", {});
|
2018-08-27 00:30:48 +02:00
|
|
|
}
|
|
|
|
|
2018-10-23 08:26:23 +02:00
|
|
|
const {checkerWrapper} = require("./modifiedAPIFunctions");
|
2018-08-27 00:30:48 +02:00
|
|
|
|
|
|
|
scope.changedGetters = [
|
|
|
|
{
|
2018-09-20 22:46:45 +02:00
|
|
|
objectGetters: [function(window){return window.History && window.History.prototype;}],
|
2018-08-27 00:30:48 +02:00
|
|
|
name: "length",
|
|
|
|
getterGenerator: function(checker){
|
|
|
|
const temp = {
|
|
|
|
get length(){
|
|
|
|
return checkerWrapper(checker, this, arguments, function(args, check){
|
|
|
|
const {prefs, notify, window, original} = check;
|
|
|
|
const originalLength = original.apply(this, window.Array.from(args));
|
|
|
|
const threshold = prefs("historyLengthThreshold", window.location);
|
|
|
|
if (originalLength > threshold){
|
|
|
|
notify("fakedHistoryReadout");
|
|
|
|
return threshold;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return originalLength;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
return Object.getOwnPropertyDescriptor(temp, "length").get;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
function getStatus(obj, status){
|
2019-02-04 13:40:44 +01:00
|
|
|
status = Object.create(status);
|
|
|
|
status.active = true;
|
|
|
|
return status;
|
2018-08-27 00:30:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
scope.changedGetters.forEach(function(changedGetter){
|
|
|
|
changedGetter.type = "readout";
|
|
|
|
changedGetter.getStatus = getStatus;
|
|
|
|
changedGetter.api = "history";
|
|
|
|
});
|
|
|
|
}());
|