Bug 153783 - Modern IDB: Make sure IndexedDB works from file:// url documents by default
Summary: Modern IDB: Make sure IndexedDB works from file:// url documents by default
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: Safari 9
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Brady Eidson
URL:
Keywords:
Depends on:
Blocks: 149117
  Show dependency treegraph
 
Reported: 2016-02-01 20:26 PST by Darryl Pogue
Modified: 2016-07-25 14:39 PDT (History)
2 users (show)

See Also:


Attachments
Test Case to be served from file:/// (567 bytes, text/html)
2016-02-01 20:26 PST, Darryl Pogue
no flags Details
Patch (7.22 KB, patch)
2016-07-25 14:13 PDT, Brady Eidson
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Darryl Pogue 2016-02-01 20:26:44 PST
Created attachment 270465 [details]
Test Case to be served from file:///

Calling indexedDB.open from a file:/// URL results in an InvalidAccessError being thrown. With the removal of WebSQL, this means that local applications served via file:/// URLs have no access to data storage beyond localStorage.

The attached test file should print "Success".
In Webkit, it prints "Error: InvalidAccessError".
Comment 1 Brady Eidson 2016-02-01 22:08:02 PST
(In reply to comment #0)
> Created attachment 270465 [details]
> Test Case to be served from file:///
> 
> Calling indexedDB.open from a file:/// URL results in an InvalidAccessError
> being thrown. 

Yup, WebIDBFactoryBackend::open fails to make a database identifier for the file: opening origin and top origin.

This is because Safari ramps up the (don't)AllowFileAccessFromFileURLs restriction on file: url documents.

> With the removal of WebSQL, this means that local applications
> served via file:/// URLs have no access to data storage beyond localStorage.

WebSQL has most certainly not been removed... works great in my testing, both http and file URLs.

Why do you think WebSQL has been removed?
Comment 2 Brady Eidson 2016-02-01 22:17:07 PST
(In reply to comment #1)
> (In reply to comment #0)
> > Created attachment 270465 [details]
> > Test Case to be served from file:///
> > 
> > Calling indexedDB.open from a file:/// URL results in an InvalidAccessError
> > being thrown. 
> 
> Yup, WebIDBFactoryBackend::open fails to make a database identifier for the
> file: opening origin and top origin.
> 
> This is because Safari ramps up the (don't)AllowFileAccessFromFileURLs
> restriction on file: url documents.

It's actually the default in WebKit. NM!
Comment 3 Brady Eidson 2016-02-01 22:17:50 PST
This should work in Safari for devs. Once Modern IDB gets its WK2 support (soon!), we'll make sure it works there by default.
Comment 4 Darryl Pogue 2016-02-01 23:00:03 PST
(In reply to comment #1)
> (In reply to comment #0) 
> > With the removal of WebSQL, this means that local applications
> > served via file:/// URLs have no access to data storage beyond localStorage.
> 
> WebSQL has most certainly not been removed... works great in my testing,
> both http and file URLs.
> 
> Why do you think WebSQL has been removed?

I believe WebSQL is not available in WKWebView on iOS (regardless of origin)
Comment 5 Brady Eidson 2016-02-02 09:02:56 PST
(In reply to comment #4)
> (In reply to comment #1)
> > (In reply to comment #0) 
> > > With the removal of WebSQL, this means that local applications
> > > served via file:/// URLs have no access to data storage beyond localStorage.
> > 
> > WebSQL has most certainly not been removed... works great in my testing,
> > both http and file URLs.
> > 
> > Why do you think WebSQL has been removed?
> 
> I believe WebSQL is not available in WKWebView on iOS (regardless of origin)

Aha, nothing in the bug report suggested you were talking iOS!

WebSQL not working in WKWebView on iOS is a completely separate issue and will be resolved separately.

Could you file a separate bug for that? I know we have a radar but piling on the dupe count from bugzilla will help.
Comment 6 Brady Eidson 2016-07-25 14:09:37 PDT
As of https://trac.webkit.org/changeset/203695 this works.

I'll be making API test changes to make sure it continues working.
Comment 7 Brady Eidson 2016-07-25 14:13:09 PDT
Created attachment 284523 [details]
Patch
Comment 8 WebKit Commit Bot 2016-07-25 14:39:47 PDT
Comment on attachment 284523 [details]
Patch

Clearing flags on attachment: 284523

Committed r203700: <http://trac.webkit.org/changeset/203700>
Comment 9 WebKit Commit Bot 2016-07-25 14:39:50 PDT
All reviewed patches have been landed.  Closing bug.