Closed Bug 1020196 Opened 10 years ago Closed 5 years ago

Allow using IndexedDB in nested oop iframe

Categories

(Core :: Storage: IndexedDB, defect, P3)

defect

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: kanru, Unassigned)

References

(Blocks 1 open bug)

Details

(Whiteboard: [nested-oop][ft:conndevices])

Attachments

(1 file, 5 obsolete files)

Currently TabParent::RecvPIndexedDBConstructor

  if (!IndexedDatabaseManager::IsMainProcess()) {
    NS_RUNTIMEABORT("Not supported yet!");
  }

Do we really need the window in IDBFactory or QuotaManager? Could we move PIndexedDB to PContent?
Whiteboard: [nested-oop]
feature-b2g: --- → 2.1
Whiteboard: [nested-oop] → [nested-oop][FT:Stream3]
Blocks: 1033984
Assignee: nobody → swu
WIP patch that moved PIndexedDB from PBrowser to PContent.

TODO: permission check on the origin.
You should really talk to Ben Turner, this clashes with IndexedDB on PBackground work he's been doing.
Hey guys, unfortunately the new indexedDB stuff (on the 'jamun' project branch) is getting pretty close to landing... It will no longer be tied to PContent/PBrowser there.
Sorry Shian-Yow, I didn't realize you were working on this :(
This is why you really should talk to module owners/peers before you start writing large pieces of code.
(In reply to ben turner [:bent] (use the needinfo? flag!) from comment #4)
> Hey guys, unfortunately the new indexedDB stuff (on the 'jamun' project
> branch) is getting pretty close to landing... It will no longer be tied to
> PContent/PBrowser there.

Thanks for this info!
Is the understanding correct that once IndexedDB stuff moved from PContent/PBrowser to PBackground, we got IndexedDB working in nested OOP iframe?
Flags: needinfo?(bent.mozilla)
I talked to Ben about this when he came to Taipei last time. We didn't expect the new IndexedDB on PBackground to land so soon so we went ahead to move PIndexedDB from PBrowser to PContent.

From a quick grep of the new code, it seems TabChild is only used to do permission check as in the old code. Fortunately this is the hard part that this bug has to address. Move PIndexedDB from PBrowser to PContent was relatively easy so I think we didn't waste too much time on it.
(In reply to Shian-Yow Wu [:swu] (Away 8/7 ~ 8/8) from comment #8)
> Is the understanding correct that once IndexedDB stuff moved from
> PContent/PBrowser to PBackground, we got IndexedDB working in nested OOP
> iframe?

Correct, the 'jamun' branch should let indexedDB work from anywhere (though, I don't believe we have any kind of tests for the nested process scenario, so there could be bugs).
Flags: needinfo?(bent.mozilla)
(In reply to Kan-Ru Chen [:kanru] from comment #9)
> I talked to Ben about this when he came to Taipei last time. We didn't
> expect the new IndexedDB on PBackground to land so soon so we went ahead to
> move PIndexedDB from PBrowser to PContent.

Yeah, we're charging ahead quickly now. I guess the question is how soon you need this to work. If at all possible I would recommend waiting for 'jamun' to merge.
Comment on attachment 8464596 [details] [diff] [review]
Part 1: Allow PContent to create IndexedDB from a window.

I don't see where you're doing any security checks on the info passed in from the child here. We have to be able to prevent a child process from accessing data that belongs to another origin.
We plan to land it by the end of v2.1 sprint 3 (August 29).
Target Milestone: --- → 2.1 S3 (29aug)
Attached patch Part 1-1: Permission check. (obsolete) — Splinter Review
The patch adds permission check.

In mochitest test, the check is not enforeced because neither IsForBrowser() and IsForAppp() is true.  Need to find some way to test it.
The patch added permission check and I confirmed that the check works on mochitest with B2G emulator at least.

bent, could you help to review it?
Attachment #8464596 - Attachment is obsolete: true
Attachment #8474090 - Attachment is obsolete: true
Attachment #8476599 - Flags: review?(bent.mozilla)
Rebased.
Attachment #8464597 - Attachment is obsolete: true
Attachment #8476600 - Flags: review?(bent.mozilla)
The patch also depends on bug 1020157 to land.
Depends on: 1020157
Attachment #8476599 - Flags: review?(bent.mozilla)
Attachment #8476600 - Flags: review?(bent.mozilla)
feature-b2g: 2.1 → 2.2
Target Milestone: 2.1 S3 (29aug) → ---
No longer blocks: 1033984
Use feature-b2g:2.2? rather than just 2.2.
feature-b2g: 2.2 → 2.2?
Depends on: 1020172
feature-b2g: 2.2? → ---
Whiteboard: [nested-oop][FT:Stream3] → [nested-oop][ft:conndevices]
Tested with the new mochitest option "--nested" in bug 1038620, and all the IndexedDB cases in dom/indexedDB/test/ are passed.  Also tested with a gaia app to access IndexedDB by nested content process, and it's working properly.

But due to permission prompts for IndexedDB are being reworked a little still in bug 1083927, we'll need to test it again after it landed.  It's expected that the nested content process should fail with permission prompt when opening by |indexedDB.open("foo", { storage: "persistent" });| for explicit permanent storage requests.
Depends on: 1083927
In mochitest test cases for indexedDB, the case dom/indexedDB/test/test_persistenceType.html will open
the database with persistence storage type, and we expect that permission prompt is required.
However, due to MOZ_CHILD_PERMISSION is disabled, it won't actually run through the permission check procedures through child process.

The MOZ_CHILD_PERMISSIONS in http://dxr.mozilla.org/mozilla-central/source/configure.in#5705 is only enabled for B2G.  But it's not passed to indexedDB even when enabling it by removing the B2G check there.  Is this supposed to be an issue?
Flags: needinfo?(bent.mozilla)
Flags: needinfo?(Jan.Varga)
(In reply to Shian-Yow Wu [:swu] from comment #21)
> In mochitest test cases for indexedDB, the case
> dom/indexedDB/test/test_persistenceType.html will open
> the database with persistence storage type, and we expect that permission
> prompt is required.
> However, due to MOZ_CHILD_PERMISSION is disabled, it won't actually run
> through the permission check procedures through child process.
> 
> The MOZ_CHILD_PERMISSIONS in
> http://dxr.mozilla.org/mozilla-central/source/configure.in#5705 is only
> enabled for B2G.  But it's not passed to indexedDB even when enabling it by
> removing the B2G check there.  Is this supposed to be an issue?

I'm not sure I understand what you are asking...
I applied the patch from bug 1038620 and ran:
./mach mochitest-plain --e10s --nested dom/indexedDB/test/test_persistenceType.html
The test passed, but I know that we set the "indexedDB" permission for all the tests to avoid the prompt. So I also tested w/o the permission set. In that case I got:
Hit MOZ_CRASH(Figure out security checks for bridged content!) at /Users/varga/Sources/Mozilla/dom/ipc/TabParent.cpp:855
There's also a problem with running the test with just --e10s (w/o the permission set). In that case, browser UI doesn't launch the prompt at all.

So I don't see how this all relates to MOZ_CHILD_PERMISSION.
Flags: needinfo?(Jan.Varga)
(In reply to Jan Varga [:janv] from comment #22)
> I applied the patch from bug 1038620 and ran:
> ./mach mochitest-plain --e10s --nested
> dom/indexedDB/test/test_persistenceType.html
> The test passed, but I know that we set the "indexedDB" permission for all
> the tests to avoid the prompt.

This answers my question why the test was passed, which I earlier thought it was related
to MOZ_CHILD_PERMISSION.  Thank you!
Flags: needinfo?(bent.mozilla)
Attachment #8476599 - Attachment is obsolete: true
Attachment #8476600 - Attachment is obsolete: true
I am not actively working on this, unassign myself.
Assignee: swu → nobody
Priority: -- → P3
Blocks: fission
No longer blocks: nested-oop

I think this was mooted by the move to IndexedDB over PBackground many, many years ago. We still do have policy limitations on third-party iframes that might preclude IndexedDB running, but that's only a policy decision. If we're seeing weirdness related to fission, please file a new bug, although again, I'd expect it to be a privacy decision preventing use, not implementation.

Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: