localStorage and 'file:' protocol not persistent, SQLite gives SECURITY_ERR

前端 未结 2 1302
渐次进展
渐次进展 2020-12-11 22:56

Introduction

I work with RapidWeaver — Mac OS X CMS application — and it uses no server environment. It has an editor and a preview mode. The preview mode is a Web

相关标签:
2条回答
  • Using the following solution: Implementing a WebView database quota delegate with a few modifications I was able to get it to work.

    The following delegate method worked for me (place in your webViewDelegate):

    - (void)webView:(WebView *)sender frame:(WebFrame *)frame exceededDatabaseQuotaForSecurityOrigin:(id) origin database:(NSString *)databaseIdentifier
    {
      static const unsigned long long defaultQuota = 5 * 1024 * 1024;
      if ([origin respondsToSelector: @selector(setQuota:)]) {
        [origin performSelector:@selector(setQuota:) withObject:[NSNumber numberWithLongLong: defaultQuota]];
      } else { 
        NSLog(@"could not increase quota for %@", defaultQuota); 
      }
    }
    

    By default the database is given 0 bytes, which results in the vague error message you get above. The above method is called after an attempt is made to create a database when there is not enough space. Note that this method is defined in WebUIDelegatePrivate.h ( http://opensource.apple.com/source/WebKit/WebKit-7533.16/mac/WebView/WebUIDelegatePrivate.h ) and using may preclude you from submitting your app to the mac app store.

    0 讨论(0)
  • 2020-12-11 23:27

    localStorage is a html5 mechanism to give scripts a bit more space than cookies. Safari supports it: https://developer.apple.com/library/archive/documentation/iPhone/Conceptual/SafariJSDatabaseGuide/Name-ValueStorage/Name-ValueStorage.html

    I don't know offhand what, if any, path restrictions it should have for file:/// based apps.

    Edit: looking into the path restrictions further, I see that what you got should work with Safari, FF recently fixed a bug that would keep it from working there: https://bugzilla.mozilla.org/show%5Fbug.cgi?id=507361

    0 讨论(0)
提交回复
热议问题