Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Issue 120733003: Feature detection-friendly restrictions for packaged apps. (Closed)

Created:
7 years ago by pwnall-personal
Modified:
6 years, 11 months ago
CC:
chromium-reviews, chromium-apps-reviews_chromium.org, extensions-reviews_chromium.org, not at google - send to devlin, miket_OOO
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Visibility:
Public.

Description

Feature detection-friendly restrictions for packaged apps. Packaged apps do not have access to some features of the Web platform that are deprecated, or that do not make sense in the context of an app. Currently, accessing most of those features throws an error. This change makes thse features behave more like missing featurs on the Web platform. Whenever possible, accessing restricted features returns undefined and logs an error to the browser console. Features accessible via non-configurable ES5 properties (e.g. window.alert, document.write) either become no-ops or throw errors, on a case-by-case basis. Deprecated events have their "on*" properties return undefined (as opposed to null, for events with no handlers) to facilitate feature detection. Using addEventListener for these events used to throw an error, and now logs an error to the console and turns into a no-op, to mimic the behavior for undefined events as well as possible. This change aims to make JavaScript libraries written for browsers work in packaged apps as seamlessly as possible, while still providing useful warnings for developers. This creates a couple of warts: (1) properties are not removed, so the "in" operator will still see them, and (2) dispatchEvent will never deliver deprecated events, but it normally delives un-implemented events. BUG=330487 Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=243817

Patch Set 1 : #

Patch Set 2 : Updated broken test. #

Total comments: 12

Patch Set 3 : Addressed some feedback. #

Patch Set 4 : Addressed feedback. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+189 lines, -122 lines) Patch
M chrome/renderer/extensions/safe_builtins.cc View 1 chunk +2 lines, -1 line 0 comments Download
M chrome/renderer/resources/extensions/platform_app.js View 1 2 3 4 chunks +109 lines, -40 lines 0 comments Download
M chrome/test/data/extensions/platform_apps/disabled_window_properties/test.js View 1 2 chunks +5 lines, -19 lines 0 comments Download
M chrome/test/data/extensions/platform_apps/restrictions/main.js View 1 2 3 4 chunks +63 lines, -43 lines 0 comments Download
M chrome/test/data/extensions/platform_apps/restrictions/sandboxed_iframe.js View 1 chunk +8 lines, -9 lines 0 comments Download
M chrome/test/data/extensions/platform_apps/storage/test.js View 1 chunk +2 lines, -10 lines 0 comments Download

Messages

Total messages: 12 (0 generated)
pwnall-personal
Can you please take a look?
7 years ago (2013-12-23 22:13:59 UTC) #1
miket_OOO
Jeffrey, would you mind taking this one? I'm ambivalent about it and need a stronger ...
6 years, 11 months ago (2014-01-07 17:16:52 UTC) #2
pwnall-personal
On 2014/01/07 17:16:52, miket wrote: > Jeffrey, would you mind taking this one? I'm ambivalent ...
6 years, 11 months ago (2014-01-07 17:50:44 UTC) #3
Jeffrey Yasskin
+Ben too, who's worked on some poisoning for chrome.* APIs whose permissions aren't granted. The ...
6 years, 11 months ago (2014-01-07 18:11:15 UTC) #4
not at google - send to devlin
I agree with the proposal outlined in the CL description.
6 years, 11 months ago (2014-01-07 22:58:42 UTC) #5
Jeffrey Yasskin
https://codereview.chromium.org/120733003/diff/90001/chrome/renderer/resources/extensions/platform_app.js File chrome/renderer/resources/extensions/platform_app.js (right): https://codereview.chromium.org/120733003/diff/90001/chrome/renderer/resources/extensions/platform_app.js#newcode52 chrome/renderer/resources/extensions/platform_app.js:52: function disableMethods(object, objectName, methodNames, useThrowingStubs) { It seems like ...
6 years, 11 months ago (2014-01-08 22:49:17 UTC) #6
pwnall-personal
Thank you very much for the feedback, Jeffery! Can you please take another look? https://codereview.chromium.org/120733003/diff/90001/chrome/renderer/resources/extensions/platform_app.js ...
6 years, 11 months ago (2014-01-08 23:20:45 UTC) #7
pwnall-personal
On 2014/01/08 23:20:45, pwnall wrote: > Thank you very much for the feedback, Jeffery! Can ...
6 years, 11 months ago (2014-01-08 23:30:31 UTC) #8
Jeffrey Yasskin
lgtm with a couple comments, thanks! https://codereview.chromium.org/120733003/diff/90001/chrome/renderer/resources/extensions/platform_app.js File chrome/renderer/resources/extensions/platform_app.js (right): https://codereview.chromium.org/120733003/diff/90001/chrome/renderer/resources/extensions/platform_app.js#newcode52 chrome/renderer/resources/extensions/platform_app.js:52: function disableMethods(object, objectName, ...
6 years, 11 months ago (2014-01-09 00:44:19 UTC) #9
pwnall-personal
Thank you very much for the thorough feedback, Jeffrey! I'll send this to the CQ ...
6 years, 11 months ago (2014-01-09 05:47:25 UTC) #10
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/costan@gmail.com/120733003/540001
6 years, 11 months ago (2014-01-09 06:56:26 UTC) #11
commit-bot: I haz the power
6 years, 11 months ago (2014-01-09 08:32:12 UTC) #12
Message was sent while issue was closed.
Change committed as 243817

Powered by Google App Engine
This is Rietveld 408576698