Search code examples
javascriptmacoswebkitosx-elcapitanoffice-js

Does embedded webkit browser in El Capitan support localstorage?


I have a Microsoft Word 2016 Add-in that (like all Office.js Add-ins) uses Apple's WebKit as the embedded browser.

(On Microsoft Word 2016 for Windows the browser is IE11 of all things).

On El Capitan my Add-in is throwing an error - which is nearly impossible to debug...at least given what I know. Specifically 10.11.6.

Everything works fine on Sierra.

I've traced the issue to, potentially, my use of localstorage to keep and reuse a couple of values...

Does Apple WebKit embedded support the use of localstorage? Maybe there's some sort of permission or initialization required?

Is there any way to troubleshoot embedded webkit? The solution works fine on Safari/Chrome etc.

Are there any other differences between webkit on El Capitan and Sierra?


Solution

  • Yes, WebKit (at least for 10.11.6) supports localstorage.

    I traced my problem to the use of 'const' while in 'use strict'...

    I was using a code snippet from Firebase/Google (for authentication across all my apps/websites) that declared a variable using “const”.

    In “use strict” this is not allowed in older versions of WebKit. It’s been fixed, which is why Sierra was okay (I guess).

    See https://bugs.webkit.org/show_bug.cgi?id=161464.

    But it threw an error on 10.11.6 and (I guess) earlier.

    Here is the crucial bit of info: how to turn on debugging for WebKit (when used as an embedded browser):

    Run the following command using terminal on your Mac:

    defaults write com.Microsoft.OsfWebHost WebKitDeveloperExtras -bool true