|
|
DescriptionAccept any string for currency code in PaymentRequest.
BUG=636723, 640847
Committed: https://crrev.com/25156023212b2fa380ccb48b2597549119003ec2
Cr-Commit-Position: refs/heads/master@{#415831}
Patch Set 1 #Patch Set 2 : Test #Patch Set 3 : Ellipsize #Patch Set 4 : Ellipsize after 6 #Patch Set 5 : Added tests #Patch Set 6 : Fixed 640847 #
Total comments: 23
Patch Set 7 : minus java changes #Patch Set 8 : Fixed issues #Patch Set 9 : Added browser side validation #
Total comments: 6
Patch Set 10 : StringBuilder #Patch Set 11 : Allow null as per spec #Messages
Total messages: 58 (30 generated)
Patchset #2 (id:20001) has been deleted
sanjoy.pal@samsung.com changed reviewers: + rouslan@chromium.org
PTAL.
Patchset #5 (id:100001) has been deleted
Description was changed from ========== Accept any string for currency code in PaymentRequest. BUG=636723 ========== to ========== Accept any string for currency code in PaymentRequest. BUG=636723, 640847 ==========
Good start! https://codereview.chromium.org/2271113002/diff/140001/chrome/android/java/sr... File chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestSection.java (right): https://codereview.chromium.org/2271113002/diff/140001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestSection.java:532: private static final String ELLIPSIS = "..."; Use the unicode ellipsis character: http://www.fileformat.info/info/unicode/char/2026/index.htm https://codereview.chromium.org/2271113002/diff/140001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestSection.java:610: if (currency.length() > MAX_CURRENCY_CHARS) { All currency formatting should happen in CurrencyStringFormatter.java. https://codereview.chromium.org/2271113002/diff/140001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestSection.java:611: currency = currency.substring(0, MAX_CURRENCY_CHARS) + ELLIPSIS; currency = currency.substring(0, MAX_CURRENCY_CHARS - 1) + ELLIPSIS; That way a 7 character currency is truncated into 5 characters + ellipsis. (If you have enough space to show 6 characters + ellipsis, then might as well just show the full 7 characters.) https://codereview.chromium.org/2271113002/diff/140001/chrome/android/junit/s... File chrome/android/junit/src/org/chromium/chrome/browser/payments/CurrencyStringFormatterTest.java (left): https://codereview.chromium.org/2271113002/diff/140001/chrome/android/junit/s... chrome/android/junit/src/org/chromium/chrome/browser/payments/CurrencyStringFormatterTest.java:78: {"55.00", "USDr", "en-US", null, ExpectedValidity.INVALID_AMOUNT_CURRENCY_CODE}, Once you move currency truncation into CurrenycStringFormatter, please add a few test cases that check the truncation logic. https://codereview.chromium.org/2271113002/diff/140001/third_party/WebKit/Sou... File third_party/WebKit/Source/modules/payments/PaymentCurrencyAmount.idl (right): https://codereview.chromium.org/2271113002/diff/140001/third_party/WebKit/Sou... third_party/WebKit/Source/modules/payments/PaymentCurrencyAmount.idl:10: [TreatNullAs=NullString] required DOMString currency; Let's not allow nulls. At least an empty string should be specified. https://codereview.chromium.org/2271113002/diff/140001/third_party/WebKit/Sou... File third_party/WebKit/Source/modules/payments/PaymentsValidators.cpp (right): https://codereview.chromium.org/2271113002/diff/140001/third_party/WebKit/Sou... third_party/WebKit/Source/modules/payments/PaymentsValidators.cpp:21: *optionalErrorMessage = "The currency code is too long"; "The currency code should be at most 2048 characters long" https://codereview.chromium.org/2271113002/diff/140001/third_party/WebKit/Sou... File third_party/WebKit/Source/modules/payments/PaymentsValidators.h (right): https://codereview.chromium.org/2271113002/diff/140001/third_party/WebKit/Sou... third_party/WebKit/Source/modules/payments/PaymentsValidators.h:20: // however any string is considered valid. Returns false if currency |code| is too long ( greater than 2048). No space after ( https://codereview.chromium.org/2271113002/diff/140001/third_party/WebKit/Sou... File third_party/WebKit/Source/modules/payments/PaymentsValidatorsTest.cpp (right): https://codereview.chromium.org/2271113002/diff/140001/third_party/WebKit/Sou... third_party/WebKit/Source/modules/payments/PaymentsValidatorsTest.cpp:38: for (int i = 0; i < 2049; i++) i < 2048 https://codereview.chromium.org/2271113002/diff/140001/third_party/WebKit/Sou... third_party/WebKit/Source/modules/payments/PaymentsValidatorsTest.cpp:47: for (int i = 0; i < 2050; i++) i < 2049
haraken@chromium.org changed reviewers: + haraken@chromium.org
https://codereview.chromium.org/2271113002/diff/140001/third_party/WebKit/Sou... File third_party/WebKit/Source/modules/payments/PaymentCurrencyAmount.idl (right): https://codereview.chromium.org/2271113002/diff/140001/third_party/WebKit/Sou... third_party/WebKit/Source/modules/payments/PaymentCurrencyAmount.idl:10: [TreatNullAs=NullString] required DOMString currency; On 2016/08/25 16:47:38, rouslan wrote: > Let's not allow nulls. At least an empty string should be specified. Right, [TreatNullAs] must be accompanied with EmptyString per the spec: https://www.w3.org/TR/WebIDL/#TreatNullAs
PTAL. https://codereview.chromium.org/2271113002/diff/140001/chrome/android/java/sr... File chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestSection.java (right): https://codereview.chromium.org/2271113002/diff/140001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestSection.java:532: private static final String ELLIPSIS = "..."; On 2016/08/25 16:47:38, rouslan wrote: > Use the unicode ellipsis character: > http://www.fileformat.info/info/unicode/char/2026/index.htm If it is ok, I'll do the application related changes as a follow up patch? https://codereview.chromium.org/2271113002/diff/140001/chrome/android/junit/s... File chrome/android/junit/src/org/chromium/chrome/browser/payments/CurrencyStringFormatterTest.java (left): https://codereview.chromium.org/2271113002/diff/140001/chrome/android/junit/s... chrome/android/junit/src/org/chromium/chrome/browser/payments/CurrencyStringFormatterTest.java:78: {"55.00", "USDr", "en-US", null, ExpectedValidity.INVALID_AMOUNT_CURRENCY_CODE}, On 2016/08/25 16:47:38, rouslan wrote: > Once you move currency truncation into CurrenycStringFormatter, please add a few > test cases that check the truncation logic. If it is ok, I'll do the application related changes as a follow up patch? https://codereview.chromium.org/2271113002/diff/140001/third_party/WebKit/Sou... File third_party/WebKit/Source/modules/payments/PaymentCurrencyAmount.idl (right): https://codereview.chromium.org/2271113002/diff/140001/third_party/WebKit/Sou... third_party/WebKit/Source/modules/payments/PaymentCurrencyAmount.idl:10: [TreatNullAs=NullString] required DOMString currency; On 2016/08/26 01:20:05, haraken wrote: > On 2016/08/25 16:47:38, rouslan wrote: > > Let's not allow nulls. At least an empty string should be specified. > > Right, [TreatNullAs] must be accompanied with EmptyString per the spec: > > https://www.w3.org/TR/WebIDL/#TreatNullAs ['Null currency code should throw', null, function() { new PaymentRequest([{'supportedMethods': ['foo']}], buildDetails(detailNames[i], {'currency': null})) }], For this test case, the value of |item.amount().currency()| in [1] is coming as "null", so its not throwing any exception. [1] https://cs.chromium.org/chromium/src/third_party/WebKit/Source/modules/paymen... https://codereview.chromium.org/2271113002/diff/140001/third_party/WebKit/Sou... File third_party/WebKit/Source/modules/payments/PaymentsValidators.cpp (right): https://codereview.chromium.org/2271113002/diff/140001/third_party/WebKit/Sou... third_party/WebKit/Source/modules/payments/PaymentsValidators.cpp:21: *optionalErrorMessage = "The currency code is too long"; On 2016/08/25 16:47:38, rouslan wrote: > "The currency code should be at most 2048 characters long" Done. https://codereview.chromium.org/2271113002/diff/140001/third_party/WebKit/Sou... File third_party/WebKit/Source/modules/payments/PaymentsValidators.h (right): https://codereview.chromium.org/2271113002/diff/140001/third_party/WebKit/Sou... third_party/WebKit/Source/modules/payments/PaymentsValidators.h:20: // however any string is considered valid. Returns false if currency |code| is too long ( greater than 2048). On 2016/08/25 16:47:38, rouslan wrote: > No space after ( Done. https://codereview.chromium.org/2271113002/diff/140001/third_party/WebKit/Sou... File third_party/WebKit/Source/modules/payments/PaymentsValidatorsTest.cpp (right): https://codereview.chromium.org/2271113002/diff/140001/third_party/WebKit/Sou... third_party/WebKit/Source/modules/payments/PaymentsValidatorsTest.cpp:38: for (int i = 0; i < 2049; i++) On 2016/08/25 16:47:38, rouslan wrote: > i < 2048 One extra space for '\0'. strlen() does not include '\0'. https://codereview.chromium.org/2271113002/diff/140001/third_party/WebKit/Sou... third_party/WebKit/Source/modules/payments/PaymentsValidatorsTest.cpp:47: for (int i = 0; i < 2050; i++) On 2016/08/25 16:47:38, rouslan wrote: > i < 2049 Same reason.
https://codereview.chromium.org/2271113002/diff/140001/chrome/android/java/sr... File chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestSection.java (right): https://codereview.chromium.org/2271113002/diff/140001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestSection.java:532: private static final String ELLIPSIS = "..."; On 2016/08/26 07:20:26, pals wrote: > On 2016/08/25 16:47:38, rouslan wrote: > > Use the unicode ellipsis character: > > http://www.fileformat.info/info/unicode/char/2026/index.htm > > If it is ok, I'll do the application related changes as a follow up patch? OK. Since Samsung does not use Chromium's UI (as far as I know), you don't have to modify the UI code aside from making it compile and making sure that all tests pass. I can take care of making it look good. https://codereview.chromium.org/2271113002/diff/140001/chrome/android/junit/s... File chrome/android/junit/src/org/chromium/chrome/browser/payments/CurrencyStringFormatterTest.java (left): https://codereview.chromium.org/2271113002/diff/140001/chrome/android/junit/s... chrome/android/junit/src/org/chromium/chrome/browser/payments/CurrencyStringFormatterTest.java:78: {"55.00", "USDr", "en-US", null, ExpectedValidity.INVALID_AMOUNT_CURRENCY_CODE}, On 2016/08/26 07:20:26, pals wrote: > On 2016/08/25 16:47:38, rouslan wrote: > > Once you move currency truncation into CurrenycStringFormatter, please add a > few > > test cases that check the truncation logic. > > If it is ok, I'll do the application related changes as a follow up patch? OK https://codereview.chromium.org/2271113002/diff/140001/third_party/WebKit/Sou... File third_party/WebKit/Source/modules/payments/PaymentCurrencyAmount.idl (right): https://codereview.chromium.org/2271113002/diff/140001/third_party/WebKit/Sou... third_party/WebKit/Source/modules/payments/PaymentCurrencyAmount.idl:10: [TreatNullAs=NullString] required DOMString currency; OK https://codereview.chromium.org/2271113002/diff/140001/third_party/WebKit/Sou... File third_party/WebKit/Source/modules/payments/PaymentsValidatorsTest.cpp (right): https://codereview.chromium.org/2271113002/diff/140001/third_party/WebKit/Sou... third_party/WebKit/Source/modules/payments/PaymentsValidatorsTest.cpp:38: for (int i = 0; i < 2049; i++) On 2016/08/26 07:20:26, pals wrote: > On 2016/08/25 16:47:38, rouslan wrote: > > i < 2048 > > One extra space for '\0'. strlen() does not include '\0'. In the current state, the last value if "i" is "2048". The last operation of the for-loop is longString[2048] = 'a'; However, on the next line you overwrite this value immediately: longString[2048] = '\0'; It's not a matter of efficiency, but it's strange to write to the same location twice in a row.
PTAL. I'm working on the UI related changes here https://codereview.chromium.org/2281913002/ https://codereview.chromium.org/2271113002/diff/140001/chrome/android/java/sr... File chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestSection.java (right): https://codereview.chromium.org/2271113002/diff/140001/chrome/android/java/sr... chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestSection.java:532: private static final String ELLIPSIS = "..."; On 2016/08/26 17:01:37, rouslan wrote: > On 2016/08/26 07:20:26, pals wrote: > > On 2016/08/25 16:47:38, rouslan wrote: > > > Use the unicode ellipsis character: > > > http://www.fileformat.info/info/unicode/char/2026/index.htm > > > > If it is ok, I'll do the application related changes as a follow up patch? > > OK. Since Samsung does not use Chromium's UI (as far as I know), you don't have > to modify the UI code aside from making it compile and making sure that all > tests pass. I can take care of making it look good. I'm working on it here https://codereview.chromium.org/2281913002/. https://codereview.chromium.org/2271113002/diff/140001/third_party/WebKit/Sou... File third_party/WebKit/Source/modules/payments/PaymentsValidatorsTest.cpp (right): https://codereview.chromium.org/2271113002/diff/140001/third_party/WebKit/Sou... third_party/WebKit/Source/modules/payments/PaymentsValidatorsTest.cpp:38: for (int i = 0; i < 2049; i++) On 2016/08/26 17:01:37, rouslan wrote: > On 2016/08/26 07:20:26, pals wrote: > > On 2016/08/25 16:47:38, rouslan wrote: > > > i < 2048 > > > > One extra space for '\0'. strlen() does not include '\0'. > > In the current state, the last value if "i" is "2048". The last operation of the > for-loop is > > longString[2048] = 'a'; > > However, on the next line you overwrite this value immediately: > > longString[2048] = '\0'; > > It's not a matter of efficiency, but it's strange to write to the same location > twice in a row. I'm sorry. You are correct. Rectified the issue.
The CQ bit was checked by sanjoy.pal@samsung.com to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
rouslan@chromium.org changed reviewers: + tsepez@chromium.org
1) Please update the comment in mojom interface definition: https://cs.chromium.org/chromium/src/third_party/WebKit/public/platform/modul... +tsepez to review mojom. 2) Please remove the browser-side currency code pattern validation in Java in this patch: https://cs.chromium.org/chromium/src/chrome/android/java/src/org/chromium/chr... It's OK to delay UI changes to the next patch, but validation in both renderer and browser should all happen in the same patch.
The CQ bit was checked by sanjoy.pal@samsung.com to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: linux_android_rel_ng on master.tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/linux_androi...)
Updated the browser side validation code as well. PTAL.
You're very close :-) https://codereview.chromium.org/2271113002/diff/200001/chrome/android/junit/s... File chrome/android/junit/src/org/chromium/chrome/browser/payments/CurrencyStringFormatterTest.java (right): https://codereview.chromium.org/2271113002/diff/200001/chrome/android/junit/s... chrome/android/junit/src/org/chromium/chrome/browser/payments/CurrencyStringFormatterTest.java:106: private static String longString2048() { This creates 2049 objects. Use https://docs.oracle.com/javase/7/docs/api/java/lang/StringBuilder.html instead, please. https://codereview.chromium.org/2271113002/diff/200001/chrome/android/junit/s... chrome/android/junit/src/org/chromium/chrome/browser/payments/CurrencyStringFormatterTest.java:114: private static String longString2049() { Ditto. https://codereview.chromium.org/2271113002/diff/200001/third_party/WebKit/pub... File third_party/WebKit/public/platform/modules/payments/payment_request.mojom (right): https://codereview.chromium.org/2271113002/diff/200001/third_party/WebKit/pub... third_party/WebKit/public/platform/modules/payments/payment_request.mojom:41: // considered valid. "any string of at most 2048 characters"
Ok, my only concern is whether we inject this string back into an HTML context at any place; when checking for [A-Z]{3}, we reject stray punctuation like <, eg. currency code could now be "<script>" etc.
On 2016/08/29 16:42:02, Tom Sepez wrote: > Ok, my only concern is whether we inject this string back into an HTML context > at any place; when checking for [A-Z]{3}, we reject stray punctuation like <, > eg. currency code could now be "<script>" etc. We don't inject this string into HTML anywhere.
> > We don't inject this string into HTML anywhere. Ok, LGTM.
The CQ bit was checked by sanjoy.pal@samsung.com to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
Please take another look. https://codereview.chromium.org/2271113002/diff/200001/chrome/android/junit/s... File chrome/android/junit/src/org/chromium/chrome/browser/payments/CurrencyStringFormatterTest.java (right): https://codereview.chromium.org/2271113002/diff/200001/chrome/android/junit/s... chrome/android/junit/src/org/chromium/chrome/browser/payments/CurrencyStringFormatterTest.java:106: private static String longString2048() { On 2016/08/29 14:23:40, rouslan wrote: > This creates 2049 objects. Use > https://docs.oracle.com/javase/7/docs/api/java/lang/StringBuilder.html instead, > please. Done. https://codereview.chromium.org/2271113002/diff/200001/chrome/android/junit/s... chrome/android/junit/src/org/chromium/chrome/browser/payments/CurrencyStringFormatterTest.java:114: private static String longString2049() { On 2016/08/29 14:23:40, rouslan wrote: > Ditto. Done. https://codereview.chromium.org/2271113002/diff/200001/third_party/WebKit/pub... File third_party/WebKit/public/platform/modules/payments/payment_request.mojom (right): https://codereview.chromium.org/2271113002/diff/200001/third_party/WebKit/pub... third_party/WebKit/public/platform/modules/payments/payment_request.mojom:41: // considered valid. On 2016/08/29 14:23:40, rouslan wrote: > "any string of at most 2048 characters" Done.
haraken@chromium.org changed reviewers: + bashi@chromium.org, yukishiino@chromium.org
Sorry about the late reply... > https://codereview.chromium.org/2271113002/diff/140001/third_party/WebKit/Sou... > File third_party/WebKit/Source/modules/payments/PaymentCurrencyAmount.idl > (right): > > https://codereview.chromium.org/2271113002/diff/140001/third_party/WebKit/Sou... > third_party/WebKit/Source/modules/payments/PaymentCurrencyAmount.idl:10: > [TreatNullAs=NullString] required DOMString currency; > On 2016/08/26 01:20:05, haraken wrote: > > On 2016/08/25 16:47:38, rouslan wrote: > > > Let's not allow nulls. At least an empty string should be specified. > > > > Right, [TreatNullAs] must be accompanied with EmptyString per the spec: > > > > https://www.w3.org/TR/WebIDL/#TreatNullAs > > ['Null currency code should throw', null, function() { > new PaymentRequest([{'supportedMethods': ['foo']}], > buildDetails(detailNames[i], {'currency': null})) > }], > > For this test case, the value of |item.amount().currency()| in [1] is coming as > "null", so its not throwing any exception. > > [1] > https://cs.chromium.org/chromium/src/third_party/WebKit/Source/modules/paymen... > I think that's an expected behavior. null is normally converted to "null" for a non-nullable DOMString. Maybe you want to use 'DOMString?' instead? [TreatNullAs=NullString] is deprecated, so we shouldn't use it. +bashi +yukishiino would be more familiar with this.
On 2016/08/30 09:38:27, haraken wrote: > Sorry about the late reply... > > > > https://codereview.chromium.org/2271113002/diff/140001/third_party/WebKit/Sou... > > File third_party/WebKit/Source/modules/payments/PaymentCurrencyAmount.idl > > (right): > > > > > https://codereview.chromium.org/2271113002/diff/140001/third_party/WebKit/Sou... > > third_party/WebKit/Source/modules/payments/PaymentCurrencyAmount.idl:10: > > [TreatNullAs=NullString] required DOMString currency; > > On 2016/08/26 01:20:05, haraken wrote: > > > On 2016/08/25 16:47:38, rouslan wrote: > > > > Let's not allow nulls. At least an empty string should be specified. > > > > > > Right, [TreatNullAs] must be accompanied with EmptyString per the spec: > > > > > > https://www.w3.org/TR/WebIDL/#TreatNullAs > > > > ['Null currency code should throw', null, function() { > > new PaymentRequest([{'supportedMethods': ['foo']}], > > buildDetails(detailNames[i], {'currency': null})) > > }], > > > > For this test case, the value of |item.amount().currency()| in [1] is coming > as > > "null", so its not throwing any exception. > > > > [1] > > > https://cs.chromium.org/chromium/src/third_party/WebKit/Source/modules/paymen... > > > > I think that's an expected behavior. null is normally converted to "null" for a > non-nullable DOMString. Maybe you want to use 'DOMString?' instead? > > [TreatNullAs=NullString] is deprecated, so we shouldn't use it. > > +bashi +yukishiino would be more familiar with this. [TreatNullAs=EmptyString] is defined in Web IDL, so you shouldn't use it unless the spec specifies. Otherwise, it's spec violation. Also, Payment spec specifies that required DOMString currency; so you shouldn't use 'DOMString?' (nullable DOMString), either. Following Web IDL and Payment spec, |null| should be converted to ToString(null), which is "null". See https://tc39.github.io/ecma262/#sec-tostring
On 2016/08/30 10:23:50, Yuki wrote: > On 2016/08/30 09:38:27, haraken wrote: > > Sorry about the late reply... > > > > > > > > https://codereview.chromium.org/2271113002/diff/140001/third_party/WebKit/Sou... > > > File third_party/WebKit/Source/modules/payments/PaymentCurrencyAmount.idl > > > (right): > > > > > > > > > https://codereview.chromium.org/2271113002/diff/140001/third_party/WebKit/Sou... > > > third_party/WebKit/Source/modules/payments/PaymentCurrencyAmount.idl:10: > > > [TreatNullAs=NullString] required DOMString currency; > > > On 2016/08/26 01:20:05, haraken wrote: > > > > On 2016/08/25 16:47:38, rouslan wrote: > > > > > Let's not allow nulls. At least an empty string should be specified. > > > > > > > > Right, [TreatNullAs] must be accompanied with EmptyString per the spec: > > > > > > > > https://www.w3.org/TR/WebIDL/#TreatNullAs > > > > > > ['Null currency code should throw', null, function() { > > > new PaymentRequest([{'supportedMethods': ['foo']}], > > > buildDetails(detailNames[i], {'currency': null})) > > > }], > > > > > > For this test case, the value of |item.amount().currency()| in [1] is coming > > as > > > "null", so its not throwing any exception. > > > > > > [1] > > > > > > https://cs.chromium.org/chromium/src/third_party/WebKit/Source/modules/paymen... > > > > > > > I think that's an expected behavior. null is normally converted to "null" for > a > > non-nullable DOMString. Maybe you want to use 'DOMString?' instead? > > > > [TreatNullAs=NullString] is deprecated, so we shouldn't use it. > > > > +bashi +yukishiino would be more familiar with this. > > [TreatNullAs=EmptyString] is defined in Web IDL, so you shouldn't use it unless > the spec specifies. Otherwise, it's spec violation. > > Also, Payment spec specifies that > required DOMString currency; > so you shouldn't use 'DOMString?' (nullable DOMString), either. > > Following Web IDL and Payment spec, |null| should be converted to > ToString(null), which is "null". > See https://tc39.github.io/ecma262/#sec-tostring We don't want to allow { currency: null }. So, we should check for "null" and throw an exception instead of changing the IDL file. Is that correct?
On 2016/08/30 13:20:04, pals wrote: > On 2016/08/30 10:23:50, Yuki wrote: > > On 2016/08/30 09:38:27, haraken wrote: > > > Sorry about the late reply... > > > > > > > > > > > > > https://codereview.chromium.org/2271113002/diff/140001/third_party/WebKit/Sou... > > > > File third_party/WebKit/Source/modules/payments/PaymentCurrencyAmount.idl > > > > (right): > > > > > > > > > > > > > > https://codereview.chromium.org/2271113002/diff/140001/third_party/WebKit/Sou... > > > > third_party/WebKit/Source/modules/payments/PaymentCurrencyAmount.idl:10: > > > > [TreatNullAs=NullString] required DOMString currency; > > > > On 2016/08/26 01:20:05, haraken wrote: > > > > > On 2016/08/25 16:47:38, rouslan wrote: > > > > > > Let's not allow nulls. At least an empty string should be specified. > > > > > > > > > > Right, [TreatNullAs] must be accompanied with EmptyString per the spec: > > > > > > > > > > https://www.w3.org/TR/WebIDL/#TreatNullAs > > > > > > > > ['Null currency code should throw', null, function() { > > > > new PaymentRequest([{'supportedMethods': ['foo']}], > > > > buildDetails(detailNames[i], {'currency': null})) > > > > }], > > > > > > > > For this test case, the value of |item.amount().currency()| in [1] is > coming > > > as > > > > "null", so its not throwing any exception. > > > > > > > > [1] > > > > > > > > > > https://cs.chromium.org/chromium/src/third_party/WebKit/Source/modules/paymen... > > > > > > > > > > I think that's an expected behavior. null is normally converted to "null" > for > > a > > > non-nullable DOMString. Maybe you want to use 'DOMString?' instead? > > > > > > [TreatNullAs=NullString] is deprecated, so we shouldn't use it. > > > > > > +bashi +yukishiino would be more familiar with this. > > > > [TreatNullAs=EmptyString] is defined in Web IDL, so you shouldn't use it > unless > > the spec specifies. Otherwise, it's spec violation. > > > > Also, Payment spec specifies that > > required DOMString currency; > > so you shouldn't use 'DOMString?' (nullable DOMString), either. > > > > Following Web IDL and Payment spec, |null| should be converted to > > ToString(null), which is "null". > > See https://tc39.github.io/ecma262/#sec-tostring > > We don't want to allow { currency: null }. So, we should check for "null" and > throw an exception instead of changing the IDL file. Is that correct? Why do you not want to allow { currency: null }? As yukishiino@ mentioned, per the spec it should be allowed.
On 2016/08/30 14:18:00, haraken wrote: > On 2016/08/30 13:20:04, pals wrote: > > On 2016/08/30 10:23:50, Yuki wrote: > > > On 2016/08/30 09:38:27, haraken wrote: > > > > Sorry about the late reply... > > > > > > > > > > > > > > > > > > > https://codereview.chromium.org/2271113002/diff/140001/third_party/WebKit/Sou... > > > > > File > third_party/WebKit/Source/modules/payments/PaymentCurrencyAmount.idl > > > > > (right): > > > > > > > > > > > > > > > > > > > > https://codereview.chromium.org/2271113002/diff/140001/third_party/WebKit/Sou... > > > > > third_party/WebKit/Source/modules/payments/PaymentCurrencyAmount.idl:10: > > > > > [TreatNullAs=NullString] required DOMString currency; > > > > > On 2016/08/26 01:20:05, haraken wrote: > > > > > > On 2016/08/25 16:47:38, rouslan wrote: > > > > > > > Let's not allow nulls. At least an empty string should be specified. > > > > > > > > > > > > Right, [TreatNullAs] must be accompanied with EmptyString per the > spec: > > > > > > > > > > > > https://www.w3.org/TR/WebIDL/#TreatNullAs > > > > > > > > > > ['Null currency code should throw', null, function() { > > > > > new PaymentRequest([{'supportedMethods': ['foo']}], > > > > > buildDetails(detailNames[i], {'currency': null})) > > > > > }], > > > > > > > > > > For this test case, the value of |item.amount().currency()| in [1] is > > coming > > > > as > > > > > "null", so its not throwing any exception. > > > > > > > > > > [1] > > > > > > > > > > > > > > > https://cs.chromium.org/chromium/src/third_party/WebKit/Source/modules/paymen... > > > > > > > > > > > > > I think that's an expected behavior. null is normally converted to "null" > > for > > > a > > > > non-nullable DOMString. Maybe you want to use 'DOMString?' instead? > > > > > > > > [TreatNullAs=NullString] is deprecated, so we shouldn't use it. > > > > > > > > +bashi +yukishiino would be more familiar with this. > > > > > > [TreatNullAs=EmptyString] is defined in Web IDL, so you shouldn't use it > > unless > > > the spec specifies. Otherwise, it's spec violation. > > > > > > Also, Payment spec specifies that > > > required DOMString currency; > > > so you shouldn't use 'DOMString?' (nullable DOMString), either. > > > > > > Following Web IDL and Payment spec, |null| should be converted to > > > ToString(null), which is "null". > > > See https://tc39.github.io/ecma262/#sec-tostring > > > > We don't want to allow { currency: null }. So, we should check for "null" and > > throw an exception instead of changing the IDL file. Is that correct? > > Why do you not want to allow { currency: null }? As yukishiino@ mentioned, per > the spec it should be allowed. Alright, let's follow the spec exactly. Please remove [TreatNullAs...].
Done. Please review.
The CQ bit was checked by sanjoy.pal@samsung.com to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
LGTM on my side.
lgtm
The CQ bit was checked by sanjoy.pal@samsung.com
The patchset sent to the CQ was uploaded after l-g-t-m from tsepez@chromium.org Link to the patchset: https://codereview.chromium.org/2271113002/#ps240001 (title: "Allow null as per spec")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: chromium_presubmit on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/chromium_presub...)
sanjoy.pal@samsung.com changed reviewers: + dfalcantara@chromium.org
+dfalcantara@ for CurrencyStringFormatterTest.java. PTAL.
That file lgtm
The CQ bit was checked by sanjoy.pal@samsung.com
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Message was sent while issue was closed.
Description was changed from ========== Accept any string for currency code in PaymentRequest. BUG=636723, 640847 ========== to ========== Accept any string for currency code in PaymentRequest. BUG=636723, 640847 ==========
Message was sent while issue was closed.
Committed patchset #11 (id:240001)
Message was sent while issue was closed.
Description was changed from ========== Accept any string for currency code in PaymentRequest. BUG=636723, 640847 ========== to ========== Accept any string for currency code in PaymentRequest. BUG=636723, 640847 Committed: https://crrev.com/25156023212b2fa380ccb48b2597549119003ec2 Cr-Commit-Position: refs/heads/master@{#415831} ==========
Message was sent while issue was closed.
Patchset 11 (id:??) landed as https://crrev.com/25156023212b2fa380ccb48b2597549119003ec2 Cr-Commit-Position: refs/heads/master@{#415831} |