Skip to content
This repository has been archived by the owner on Jan 4, 2019. It is now read-only.

Add support for missing events (fix indexedDB, etc) #629

Merged
merged 1 commit into from
Jul 6, 2018
Merged

Conversation

bsclifton
Copy link
Member

@bsclifton bsclifton commented Jul 5, 2018

Test plan

IndexedDB / AllowDatabase testing

  1. Visit https://raananw.github.io/WebWorkers-IndexedDB/
  2. Ensure your Cookie Control shields are set to Block 3rd Party Cookies
  3. Click the Run @ WebWorker button
  4. Scrollbar should go across the screen
  5. Toggle the Cookie Control shields setting to Block all cookies
  6. Click the Run @ WebWorker button
  7. Scrollbar should not move

local storage testing

  1. Visit https://mdn.github.io/dom-examples/web-storage/
  2. Ensure your Cookie Control shields are set to Block 3rd Party Cookies
  3. Pick a color from the Choose background color drop down
  4. Verify the background color of page changes
  5. Toggle the Cookie Control shields setting to Block all cookies
  6. Notice the background color reset back to red
  7. Try to change the color using the Choose background color
  8. Notice the background color is not changed
  9. Reload page
  10. Notice that background color wasn't persisted (it should still be red)

twitch.tv testing

  1. Visit https://www.twitch.tv/
  2. A stream should show on the front page
  • if an ad is shown, please wait until that is over. Ads worked fine before this change.
  • if "mature audience" warning is shown, click through to start stream
  1. Stream should be working (audio / video)

Details

Add support for missing events:

  • AllowDatabase
  • AllowDOMStorage
  • AllowIndexedDB

Fixes brave/browser-laptop#12463
Fixes brave/browser-laptop#14475

Possibly addresses brave/browser-laptop#10685

Auditors: @darkdh, @bridiver

@bsclifton bsclifton self-assigned this Jul 5, 2018
@bsclifton bsclifton requested review from bridiver and darkdh July 5, 2018 23:03
namespace {

const uint32_t kRenderFilteredMessageClasses[] = {
ChromeMsgStart, NetworkHintsMsgStart,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we only need ChromeMsgStart because we are not handling any NetworkHintsMsg_* messages

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

darkdh
darkdh previously approved these changes Jul 5, 2018
const base::string16& name,
const base::string16& display_name,
bool* allowed) {
*allowed = true;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these need to check cookie content settings or they will bypass blocking

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also OnAllowDOMStorage , OnRequestFileSystemAccess and OnAllowIndexedDB

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

DCHECK_CURRENTLY_ON(BrowserThread::IO);

Send(new ChromeViewMsg_RequestFileSystemAccessAsyncResponse(
render_frame_id, request_id, true));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @diracdeltas - this doesn't seem like the right thing to do here. There is a permission in Chrome for this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this code

DCHECK_CURRENTLY_ON(BrowserThread::IO);


ChromeViewHostMsg_RequestFileSystemAccessSync::WriteReplyParams(reply_msg,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also cc @diracdeltas same as below sync response

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this as I don't believe we need it

@darkdh darkdh requested a review from diracdeltas July 5, 2018 23:26
const GURL& top_origin_url,
const base::string16& name,
bool* allowed) {
*allowed = true;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should also check cookie content settings

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@diracdeltas
Copy link
Member

i don't understand this code very well but agree it generally needs to respect cookie blocking content settings. the setting for cookie blocking should be applied to all types of persistent local storage (including FileSystem API, indexdb, and DOM storage). you can find a test for this in browser-laptop test/fixtures/cookies.html

@bsclifton
Copy link
Member Author

Thanks for the review feedback- looking at this now...

@bsclifton
Copy link
Member Author

Ready for re-review! I added a test plan and also removed the request file system access code as I don't believe we need it (yet)

@bsclifton bsclifton changed the title Add support for missing events: Add support for missing events (fix indexedDB, etc) Jul 6, 2018
const base::string16& display_name,
bool* allowed) {
*allowed =
cookie_settings_->IsCookieAccessAllowed(origin_url, top_origin_url);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be using the HostContentSettingsMap. We don't use Chrome's CookieSettingsFactory or IsCookieAccessAllowed. HostContentSettingsMapFactory::GetForProfile(profile_)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same for all checks

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can update the code - but it does work as-is. Once I fetch the HostContentSettingsMap, what would I check?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

 ContentSetting GetContentSetting(
      const GURL& primary_url,
      const GURL& secondary_url,
      ContentSettingsType content_type,
      const std::string& resource_identifier) const;

Copy link
Collaborator

@bridiver bridiver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comments

@bsclifton
Copy link
Member Author

bsclifton commented Jul 6, 2018

ready for re-re-review

edit: SQUASHED!

- AllowDatabase
- AllowDOMStorage
- AllowIndexedDB

*Includes fixes from review feedback*

Fixes brave/browser-laptop#12463
Fixes brave/browser-laptop#14475

Possibly addresses brave/browser-laptop#10685
Copy link
Member

@darkdh darkdh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++

bool BraveRenderMessageFilter::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(BraveRenderMessageFilter, message)
IPC_MESSAGE_HANDLER(ChromeViewHostMsg_AllowDatabase, OnAllowDatabase)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's also an async version of these messages

@darkdh darkdh merged commit dedd937 into master Jul 6, 2018
darkdh added a commit that referenced this pull request Jul 6, 2018
Add support for missing events (fix indexedDB, etc)
@bsclifton bsclifton deleted the fix-indexeddb branch July 6, 2018 15:51
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants