From 7842c730a4753e233a2721d887f566cff119844a Mon Sep 17 00:00:00 2001 From: Caleb James DeLisle Date: Mon, 18 Dec 2017 15:15:41 +0100 Subject: [PATCH] support for testing on safari --- www/common/boot2.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/www/common/boot2.js b/www/common/boot2.js index ec3b3d7db..ec1724eb2 100644 --- a/www/common/boot2.js +++ b/www/common/boot2.js @@ -22,6 +22,24 @@ define([ } var failStore = function () { + if (document.cookie.indexOf('test=') === 0) { + // We're testing in safari and safaridriver runs everything in a private window + // However, for our tests nothing lasts more than a single page load so we can + // stub the localStorage + + // This is shamelessly copy/pasted from sframe-boot2.js :( + var mkFakeStore = function () { + var fakeStorage = { + getItem: function (k) { return fakeStorage[k]; }, + setItem: function (k, v) { fakeStorage[k] = v; return v; }, + removeItem: function (k) { delete fakeStorage[k]; } + }; + return fakeStorage; + }; + window.__defineGetter__('localStorage', function () { return mkFakeStore(); }); + window.__defineGetter__('sessionStorage', function () { return mkFakeStore(); }); + return; + } console.error(new Error('wut')); require(['jquery'], function ($) { $.ajax({