Diff
Modified: trunk/LayoutTests/ChangeLog (224605 => 224606)
--- trunk/LayoutTests/ChangeLog 2017-11-09 00:25:05 UTC (rev 224605)
+++ trunk/LayoutTests/ChangeLog 2017-11-09 00:36:15 UTC (rev 224606)
@@ -1,3 +1,22 @@
+2017-11-08 Joseph Pecoraro <pecor...@apple.com>
+
+ Web Inspector: Show Internal properties of PaymentRequest in Web Inspector Console
+ https://bugs.webkit.org/show_bug.cgi?id=179276
+
+ Reviewed by Andy Estes.
+
+ * TestExpectations:
+ * platform/mac-wk2/TestExpectations:
+ Pass test on platforms that support Payment Requests.
+
+ * http/tests/inspector/paymentrequest/payment-request-internal-properties.https-expected.txt: Added.
+ * http/tests/inspector/paymentrequest/payment-request-internal-properties.https.html: Added.
+ Test for internal properties on PaymentRequest instances.
+
+ * resources/ui-helper.js:
+ (window.UIHelper.withUserGesture):
+ Provide an easier way to simulate work inside of a user gesture.
+
2017-11-08 Ryan Haddad <ryanhad...@apple.com>
Mark many service worker tests as flaky on iOS.
Modified: trunk/LayoutTests/TestExpectations (224605 => 224606)
--- trunk/LayoutTests/TestExpectations 2017-11-09 00:25:05 UTC (rev 224605)
+++ trunk/LayoutTests/TestExpectations 2017-11-09 00:36:15 UTC (rev 224606)
@@ -200,6 +200,7 @@
# Payment Request is only enabled on Cocoa platforms.
http/tests/paymentrequest [ Skip ]
+http/tests/inspector/paymentrequest [ Skip ]
imported/w3c/web-platform-tests/payment-request [ Skip ]
imported/w3c/web-platform-tests/2dcontext/transformations/canvas_transformations_reset_001.html [ ImageOnlyFailure ]
Modified: trunk/LayoutTests/http/tests/inspector/network/resource-response-service-worker.html (224605 => 224606)
--- trunk/LayoutTests/http/tests/inspector/network/resource-response-service-worker.html 2017-11-09 00:25:05 UTC (rev 224605)
+++ trunk/LayoutTests/http/tests/inspector/network/resource-response-service-worker.html 2017-11-09 00:36:15 UTC (rev 224606)
@@ -16,7 +16,6 @@
function test()
{
- InspectorTest.debug();
let suite = InspectorTest.createAsyncSuite("Resource.ResponseSource.ServiceWorker");
function addTestCase({name, description, setup, _expression_, statusCode, responseSource}) {
Added: trunk/LayoutTests/http/tests/inspector/paymentrequest/payment-request-internal-properties.https-expected.txt (0 => 224606)
--- trunk/LayoutTests/http/tests/inspector/paymentrequest/payment-request-internal-properties.https-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/paymentrequest/payment-request-internal-properties.https-expected.txt 2017-11-09 00:36:15 UTC (rev 224606)
@@ -0,0 +1,168 @@
+Internal properties of a PaymentRequest.
+
+
+== Running test suite: RemoteObject.InternalProperties.PaymentRequest
+-- Running test case: RemoteObject.InternalProperties.PaymentRequest.Created.Large
+INTERNAL PROPERTY: state: "created"
+INTERNAL PROPERTY: details: {
+ "id": "<filtered>",
+ "total": {
+ "label": "Total",
+ "amount": {
+ "currency": "USD",
+ "value": "99.00",
+ "currencySystem": "<filtered>"
+ },
+ "pending": false
+ },
+ "displayItems": [
+ {
+ "label": "Item 1",
+ "amount": {
+ "currency": "USD",
+ "value": "90.00",
+ "currencySystem": "<filtered>"
+ },
+ "pending": false
+ },
+ {
+ "label": "Item 2",
+ "amount": {
+ "currency": "USD",
+ "value": "90.00",
+ "currencySystem": "<filtered>"
+ },
+ "pending": true
+ },
+ {
+ "label": "Item 3",
+ "amount": {
+ "currency": "USD",
+ "value": "9.00",
+ "currencySystem": "<filtered>"
+ },
+ "pending": false
+ }
+ ],
+ "shippingOptions": [
+ {
+ "id": "<filtered>",
+ "label": "Shipping Label 1",
+ "amount": {
+ "currency": "USD",
+ "value": "5.00",
+ "currencySystem": "<filtered>"
+ },
+ "selected": false
+ },
+ {
+ "id": "<filtered>",
+ "label": "Shipping Label 2",
+ "amount": {
+ "currency": "USD",
+ "value": "10.00",
+ "currencySystem": "<filtered>"
+ },
+ "selected": true
+ }
+ ],
+ "modifiers": [
+ {
+ "supportedMethods": "basic-card",
+ "total": {
+ "label": "Total",
+ "amount": {
+ "currency": "USD",
+ "value": "99.00",
+ "currencySystem": "<filtered>"
+ },
+ "pending": false
+ },
+ "additionalDisplayItems": [],
+ "data": null
+ }
+ ]
+}
+INTERNAL PROPERTY: options: {
+ "requestPayerName": false,
+ "requestPayerEmail": false,
+ "requestPayerPhone": false,
+ "requestShipping": false,
+ "shippingType": "shipping"
+}
+
+-- Running test case: RemoteObject.InternalProperties.PaymentRequest.Created
+INTERNAL PROPERTY: state: "created"
+INTERNAL PROPERTY: details: {
+ "id": "<filtered>",
+ "total": {
+ "label": "Total",
+ "amount": {
+ "currency": "USD",
+ "value": "9.99",
+ "currencySystem": "<filtered>"
+ },
+ "pending": false
+ },
+ "displayItems": [],
+ "shippingOptions": [],
+ "modifiers": []
+}
+INTERNAL PROPERTY: options: {
+ "requestPayerName": false,
+ "requestPayerEmail": false,
+ "requestPayerPhone": false,
+ "requestShipping": false,
+ "shippingType": "shipping"
+}
+
+-- Running test case: RemoteObject.InternalProperties.PaymentRequest.Initiated
+INTERNAL PROPERTY: state: "interactive"
+INTERNAL PROPERTY: details: {
+ "id": "<filtered>",
+ "total": {
+ "label": "Total",
+ "amount": {
+ "currency": "USD",
+ "value": "9.99",
+ "currencySystem": "<filtered>"
+ },
+ "pending": false
+ },
+ "displayItems": [],
+ "shippingOptions": [],
+ "modifiers": []
+}
+INTERNAL PROPERTY: options: {
+ "requestPayerName": false,
+ "requestPayerEmail": false,
+ "requestPayerPhone": false,
+ "requestShipping": false,
+ "shippingType": "shipping"
+}
+
+-- Running test case: RemoteObject.InternalProperties.PaymentRequest.Closed
+INTERNAL PROPERTY: state: "closed"
+INTERNAL PROPERTY: details: {
+ "id": "<filtered>",
+ "total": {
+ "label": "Total",
+ "amount": {
+ "currency": "USD",
+ "value": "9.99",
+ "currencySystem": "<filtered>"
+ },
+ "pending": false
+ },
+ "displayItems": [],
+ "shippingOptions": [],
+ "modifiers": []
+}
+INTERNAL PROPERTY: options: {
+ "requestPayerName": false,
+ "requestPayerEmail": false,
+ "requestPayerPhone": false,
+ "requestShipping": false,
+ "shippingType": "shipping"
+}
+
Added: trunk/LayoutTests/http/tests/inspector/paymentrequest/payment-request-internal-properties.https.html (0 => 224606)
--- trunk/LayoutTests/http/tests/inspector/paymentrequest/payment-request-internal-properties.https.html (rev 0)
+++ trunk/LayoutTests/http/tests/inspector/paymentrequest/payment-request-internal-properties.https.html 2017-11-09 00:36:15 UTC (rev 224606)
@@ -0,0 +1,179 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script src=""
+<script>
+const method = {
+ supportedMethods: "https://apple.com/apple-pay",
+ data: {
+ version: 2,
+ merchantIdentifier: "",
+ merchantCapabilities: ["supports3DS"],
+ supportedNetworks: ["visa", "masterCard"],
+ countryCode: "US",
+ },
+};
+
+const simpleDetails = {
+ total: {
+ label: "Total",
+ amount: {currency: "USD", value: "9.99"}
+ }
+};
+
+const largeDetails = {
+ total: {
+ label: "Total",
+ amount: {currency: "USD", value: "99.00"},
+ },
+ displayItems: [
+ {
+ label: "Item 1",
+ amount: {currency: "USD", value: "90.00"},
+ }, {
+ label: "Item 2",
+ amount: {currency: "USD", value: "90.00"},
+ pending: true,
+ }, {
+ label: "Item 3",
+ amount: {currency: "USD", value: "9.00"},
+ }
+ ],
+ shippingOptions: [
+ {
+ id: "shippingId1",
+ label: "Shipping Label 1",
+ amount: {currency: "USD", value: "5.00"},
+ selected: false,
+ }, {
+ id: "shippingId2",
+ label: "Shipping Label 2",
+ amount: {currency: "USD", value: "10.00"},
+ selected: true,
+ }
+ ],
+ modifiers: [
+ {
+ supportedMethods: "basic-card",
+ total: {
+ label: "Total",
+ amount: {currency: "USD", value: "99.00"},
+ },
+ }
+ ],
+};
+
+let currentRequest = null;
+function createPaymentRequest() {
+ if (currentRequest)
+ currentRequest.abort().catch(() => {});
+ currentRequest = new PaymentRequest([method], simpleDetails);
+ return currentRequest;
+}
+
+function triggerLargePaymentRequest() {
+ let request = new PaymentRequest([method], largeDetails);
+ Promise.resolve().then(() => { TestPage.dispatchEventToFrontend("Continue"); });
+ return request;
+}
+
+function triggerCreatedPaymentRequest() {
+ let request = createPaymentRequest();
+ Promise.resolve().then(() => { TestPage.dispatchEventToFrontend("Continue"); });
+ return request;
+}
+
+function triggerInitiatedPaymentRequest() {
+ let request = createPaymentRequest();
+ UIHelper.withUserGesture(async () => {
+ request.show().catch(() => {});
+ TestPage.dispatchEventToFrontend("Continue");
+ });
+ return request;
+}
+
+function triggerClosedPaymentRequest() {
+ let request = createPaymentRequest();
+ UIHelper.withUserGesture(async () => {
+ request.show().catch(() => {});
+ await request.abort();
+ TestPage.dispatchEventToFrontend("Continue");
+ });
+ return request;
+}
+
+// ----
+
+function test()
+{
+ async function propertyDescriptorString(propertyDescriptor) {
+ function inspectedPage_internalValue_JSON() {
+ return JSON.stringify(this, (key, value) => {
+ if (key === "id")
+ return "<filtered>";
+ if (key === "currencySystem")
+ return "<filtered>";
+ return value;
+ }, 2);
+ }
+
+ // Primitive. We have the value.
+ if (propertyDescriptor.value.type !== "object")
+ return propertyDescriptor.name + ": " + JSON.stringify(propertyDescriptor.value.description);
+
+ // Object. Stringify on the page.
+ let [jsonValue] = await promisify((cb) => { propertyDescriptor.value.callFunctionJSON(inspectedPage_internalValue_JSON, undefined, cb); });
+ return propertyDescriptor.name + ": " + jsonValue;
+ }
+
+ let suite = InspectorTest.createAsyncSuite("RemoteObject.InternalProperties.PaymentRequest");
+
+ function addTestCase({name, description, _expression_}) {
+ suite.addTestCase({
+ name, description,
+ async test() {
+ let [result] = await Promise.all([
+ InspectorTest.evaluateInPage(_expression_),
+ InspectorTest.awaitEvent("Continue"),
+ ]);
+ let remoteObject = WI.RemoteObject.fromPayload(result.result);
+ let [propertyDescriptors] = await promisify((cb) => { remoteObject.getAllPropertyDescriptors(cb); });
+ for (let propertyDescriptor of propertyDescriptors.reverse()) {
+ if (propertyDescriptor.isInternalProperty) {
+ let displayString = await propertyDescriptorString(propertyDescriptor);
+ InspectorTest.log("INTERNAL PROPERTY: " + displayString);
+ }
+ }
+ }
+ });
+ }
+
+ addTestCase({
+ name: "RemoteObject.InternalProperties.PaymentRequest.Created.Large",
+ _expression_: `triggerLargePaymentRequest()`,
+ });
+
+ addTestCase({
+ name: "RemoteObject.InternalProperties.PaymentRequest.Created",
+ _expression_: `triggerCreatedPaymentRequest()`,
+ });
+
+ addTestCase({
+ name: "RemoteObject.InternalProperties.PaymentRequest.Initiated",
+ _expression_: `triggerInitiatedPaymentRequest()`,
+ });
+
+ addTestCase({
+ name: "RemoteObject.InternalProperties.PaymentRequest.Closed",
+ _expression_: `triggerClosedPaymentRequest()`,
+ });
+
+ suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body _onload_="runTest()">
+<p>Internal properties of a PaymentRequest.</p>
+</body>
+</html>
Modified: trunk/LayoutTests/platform/mac-wk2/TestExpectations (224605 => 224606)
--- trunk/LayoutTests/platform/mac-wk2/TestExpectations 2017-11-09 00:25:05 UTC (rev 224605)
+++ trunk/LayoutTests/platform/mac-wk2/TestExpectations 2017-11-09 00:36:15 UTC (rev 224606)
@@ -26,6 +26,7 @@
fast/visual-viewport/rubberbanding-viewport-rects-header-footer.html [ Pass ]
[ Sierra+ ] http/tests/paymentrequest [ Pass ]
+[ Sierra+ ] http/tests/inspector/paymentrequest [ Pass ]
[ Sierra+ ] imported/w3c/web-platform-tests/payment-request [ Pass ]
webkit.org/b/178107 [ Sierra+ ] http/tests/paymentrequest/payment-request-abort-method.https.html [ Pass Failure ]
webkit.org/b/175611 imported/w3c/web-platform-tests/payment-request/allowpaymentrequest/allowpaymentrequest-attribute-cross-origin-bc-containers.https.html [ Skip ]
Modified: trunk/LayoutTests/resources/ui-helper.js (224605 => 224606)
--- trunk/LayoutTests/resources/ui-helper.js 2017-11-09 00:25:05 UTC (rev 224605)
+++ trunk/LayoutTests/resources/ui-helper.js 2017-11-09 00:36:15 UTC (rev 224606)
@@ -156,4 +156,9 @@
return promise.then(finish, finish);
}
+
+ static withUserGesture(callback)
+ {
+ internals.withUserGesture(callback);
+ }
}
Modified: trunk/Source/_javascript_Core/ChangeLog (224605 => 224606)
--- trunk/Source/_javascript_Core/ChangeLog 2017-11-09 00:25:05 UTC (rev 224605)
+++ trunk/Source/_javascript_Core/ChangeLog 2017-11-09 00:36:15 UTC (rev 224606)
@@ -1,3 +1,16 @@
+2017-11-08 Joseph Pecoraro <pecor...@apple.com>
+
+ Web Inspector: Show Internal properties of PaymentRequest in Web Inspector Console
+ https://bugs.webkit.org/show_bug.cgi?id=179276
+
+ Reviewed by Andy Estes.
+
+ * inspector/InjectedScriptHost.h:
+ * inspector/JSInjectedScriptHost.cpp:
+ (Inspector::JSInjectedScriptHost::getInternalProperties):
+ Call through to virtual implementation so that WebCore can provide custom
+ internal properties for Web / DOM objects.
+
2017-11-08 Saam Barati <sbar...@apple.com>
A JSFunction's ObjectAllocationProfile should watch the poly prototype watchpoint so it can clear its object allocation profile
Modified: trunk/Source/_javascript_Core/inspector/InjectedScriptHost.h (224605 => 224606)
--- trunk/Source/_javascript_Core/inspector/InjectedScriptHost.h 2017-11-09 00:25:05 UTC (rev 224605)
+++ trunk/Source/_javascript_Core/inspector/InjectedScriptHost.h 2017-11-09 00:36:15 UTC (rev 224606)
@@ -37,6 +37,7 @@
virtual ~InjectedScriptHost();
virtual JSC::JSValue subtype(JSC::ExecState*, JSC::JSValue) { return JSC::jsUndefined(); }
+ virtual JSC::JSValue getInternalProperties(JSC::VM&, JSC::ExecState*, JSC::JSValue) { return { }; }
virtual bool isHTMLAllCollection(JSC::VM&, JSC::JSValue) { return false; }
JSC::JSValue wrapper(JSC::ExecState*, JSC::JSGlobalObject*);
Modified: trunk/Source/_javascript_Core/inspector/JSInjectedScriptHost.cpp (224605 => 224606)
--- trunk/Source/_javascript_Core/inspector/JSInjectedScriptHost.cpp 2017-11-09 00:25:05 UTC (rev 224605)
+++ trunk/Source/_javascript_Core/inspector/JSInjectedScriptHost.cpp 2017-11-09 00:36:15 UTC (rev 224606)
@@ -272,6 +272,10 @@
auto scope = DECLARE_THROW_SCOPE(vm);
JSValue value = exec->uncheckedArgument(0);
+ JSValue internalProperties = impl().getInternalProperties(vm, exec, value);
+ if (internalProperties)
+ return internalProperties;
+
if (JSPromise* promise = jsDynamicCast<JSPromise*>(vm, value)) {
unsigned index = 0;
JSArray* array = constructEmptyArray(exec, nullptr);
Modified: trunk/Source/WebCore/ChangeLog (224605 => 224606)
--- trunk/Source/WebCore/ChangeLog 2017-11-09 00:25:05 UTC (rev 224605)
+++ trunk/Source/WebCore/ChangeLog 2017-11-09 00:36:15 UTC (rev 224606)
@@ -1,3 +1,27 @@
+2017-11-08 Joseph Pecoraro <pecor...@apple.com>
+
+ Web Inspector: Show Internal properties of PaymentRequest in Web Inspector Console
+ https://bugs.webkit.org/show_bug.cgi?id=179276
+
+ Reviewed by Andy Estes.
+
+ Test: http/tests/inspector/runtime/internal-properties-payment-request.https.html
+
+ * Modules/paymentrequest/PaymentRequest.h:
+ Expose access to internal state.
+
+ * inspector/WebInjectedScriptHost.h:
+ * inspector/WebInjectedScriptHost.cpp:
+ (WebCore::constructInternalProperty):
+ (WebCore::WebInjectedScriptHost::getInternalProperties):
+ Provide internal properties for a PaymentRequest.
+
+ * testing/Internals.cpp:
+ (WebCore::Internals::withUserGesture):
+ * testing/Internals.h:
+ * testing/Internals.idl:
+ Provide a simple way to run code inside of a user gesture.
+
2017-11-08 Ryosuke Niwa <rn...@webkit.org>
REGRESSION(r224534): Crash inside Document::updateStyleIfNeeded
Modified: trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.h (224605 => 224606)
--- trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.h 2017-11-09 00:25:05 UTC (rev 224605)
+++ trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.h 2017-11-09 00:36:15 UTC (rev 224606)
@@ -65,6 +65,14 @@
const String& shippingOption() const { return m_shippingOption; }
std::optional<PaymentShippingType> shippingType() const;
+ enum class State {
+ Created,
+ Interactive,
+ Closed,
+ };
+
+ State state() const { return m_state; }
+
const PaymentOptions& paymentOptions() const { return m_options; }
const PaymentDetailsInit& paymentDetails() const { return m_details; }
@@ -80,12 +88,6 @@
using RefCounted<PaymentRequest>::deref;
private:
- enum class State {
- Created,
- Interactive,
- Closed,
- };
-
struct Method {
MethodIdentifier identifier;
String serializedData;
Modified: trunk/Source/WebCore/html/VoidCallback.idl (224605 => 224606)
--- trunk/Source/WebCore/html/VoidCallback.idl 2017-11-09 00:25:05 UTC (rev 224605)
+++ trunk/Source/WebCore/html/VoidCallback.idl 2017-11-09 00:36:15 UTC (rev 224606)
@@ -20,7 +20,9 @@
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-callback VoidCallback = void ();
+[
+ ExportMacro=WEBCORE_EXPORT
+] callback VoidCallback = void ();
Modified: trunk/Source/WebCore/inspector/WebInjectedScriptHost.cpp (224605 => 224606)
--- trunk/Source/WebCore/inspector/WebInjectedScriptHost.cpp 2017-11-09 00:25:05 UTC (rev 224605)
+++ trunk/Source/WebCore/inspector/WebInjectedScriptHost.cpp 2017-11-09 00:36:15 UTC (rev 224606)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-2017 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -33,11 +33,18 @@
#include "JSNode.h"
#include "JSNodeList.h"
+#if ENABLE(PAYMENT_REQUEST)
+#include "JSPaymentRequest.h"
+#include "JSPaymentShippingType.h"
+#include "PaymentOptions.h"
+#include "PaymentRequest.h"
+#endif
namespace WebCore {
+
using namespace JSC;
-JSValue WebInjectedScriptHost::subtype(JSC::ExecState* exec, JSC::JSValue value)
+JSValue WebInjectedScriptHost::subtype(ExecState* exec, JSValue value)
{
VM& vm = exec->vm();
if (value.inherits(vm, JSNode::info()))
@@ -52,6 +59,129 @@
return jsUndefined();
}
+#if ENABLE(PAYMENT_REQUEST)
+static JSObject* constructInternalProperty(VM& vm, ExecState* exec, const String& name, JSValue value)
+{
+ auto* object = constructEmptyObject(exec);
+ object->putDirect(vm, Identifier::fromString(exec, "name"), jsString(exec, name));
+ object->putDirect(vm, Identifier::fromString(exec, "value"), value);
+ return object;
+}
+
+static JSObject* objectForPaymentOptions(VM& vm, ExecState* exec, const PaymentOptions& paymentOptions)
+{
+ auto* object = constructEmptyObject(exec);
+ object->putDirect(vm, Identifier::fromString(exec, "requestPayerName"), jsBoolean(paymentOptions.requestPayerName));
+ object->putDirect(vm, Identifier::fromString(exec, "requestPayerEmail"), jsBoolean(paymentOptions.requestPayerEmail));
+ object->putDirect(vm, Identifier::fromString(exec, "requestPayerPhone"), jsBoolean(paymentOptions.requestPayerPhone));
+ object->putDirect(vm, Identifier::fromString(exec, "requestShipping"), jsBoolean(paymentOptions.requestShipping));
+ object->putDirect(vm, Identifier::fromString(exec, "shippingType"), jsNontrivialString(exec, convertEnumerationToString(paymentOptions.shippingType)));
+ return object;
+}
+
+static JSObject* objectForPaymentCurrencyAmount(VM& vm, ExecState* exec, const PaymentCurrencyAmount& paymentCurrencyAmount)
+{
+ auto* object = constructEmptyObject(exec);
+ object->putDirect(vm, Identifier::fromString(exec, "currency"), jsString(exec, paymentCurrencyAmount.currency));
+ object->putDirect(vm, Identifier::fromString(exec, "value"), jsString(exec, paymentCurrencyAmount.value));
+ object->putDirect(vm, Identifier::fromString(exec, "currencySystem"), jsString(exec, paymentCurrencyAmount.currencySystem));
+ return object;
+}
+
+static JSObject* objectForPaymentItem(VM& vm, ExecState* exec, const PaymentItem& paymentItem)
+{
+ auto* object = constructEmptyObject(exec);
+ object->putDirect(vm, Identifier::fromString(exec, "label"), jsString(exec, paymentItem.label));
+ object->putDirect(vm, Identifier::fromString(exec, "amount"), objectForPaymentCurrencyAmount(vm, exec, paymentItem.amount));
+ object->putDirect(vm, Identifier::fromString(exec, "pending"), jsBoolean(paymentItem.pending));
+ return object;
+}
+
+static JSObject* objectForPaymentShippingOption(VM& vm, ExecState* exec, const PaymentShippingOption& paymentShippingOption)
+{
+ auto* object = constructEmptyObject(exec);
+ object->putDirect(vm, Identifier::fromString(exec, "id"), jsString(exec, paymentShippingOption.id));
+ object->putDirect(vm, Identifier::fromString(exec, "label"), jsString(exec, paymentShippingOption.label));
+ object->putDirect(vm, Identifier::fromString(exec, "amount"), objectForPaymentCurrencyAmount(vm, exec, paymentShippingOption.amount));
+ object->putDirect(vm, Identifier::fromString(exec, "selected"), jsBoolean(paymentShippingOption.selected));
+ return object;
+}
+
+static JSObject* objectForPaymentDetailsModifier(VM& vm, ExecState* exec, const PaymentDetailsModifier& modifier)
+{
+ auto* additionalDisplayItems = constructEmptyArray(exec, nullptr);
+ for (unsigned i = 0; i < modifier.additionalDisplayItems.size(); ++i)
+ additionalDisplayItems->putDirectIndex(exec, i, objectForPaymentItem(vm, exec, modifier.additionalDisplayItems[i]));
+
+ auto* object = constructEmptyObject(exec);
+ object->putDirect(vm, Identifier::fromString(exec, "supportedMethods"), jsString(exec, modifier.supportedMethods));
+ object->putDirect(vm, Identifier::fromString(exec, "total"), !modifier.total ? jsNull() : objectForPaymentItem(vm, exec, *modifier.total));
+ object->putDirect(vm, Identifier::fromString(exec, "additionalDisplayItems"), additionalDisplayItems);
+ object->putDirect(vm, Identifier::fromString(exec, "data"), !modifier.data ? jsNull() : modifier.data.get());
+ return object;
+}
+
+static JSObject* objectForPaymentDetails(VM& vm, ExecState* exec, const PaymentDetailsInit& paymentDetails)
+{
+ auto* displayItems = constructEmptyArray(exec, nullptr);
+ for (unsigned i = 0; i < paymentDetails.displayItems.size(); ++i)
+ displayItems->putDirectIndex(exec, i, objectForPaymentItem(vm, exec, paymentDetails.displayItems[i]));
+
+ auto* shippingOptions = constructEmptyArray(exec, nullptr);
+ for (unsigned i = 0; i < paymentDetails.shippingOptions.size(); ++i)
+ shippingOptions->putDirectIndex(exec, i, objectForPaymentShippingOption(vm, exec, paymentDetails.shippingOptions[i]));
+
+ auto* modifiers = constructEmptyArray(exec, nullptr);
+ for (unsigned i = 0; i < paymentDetails.modifiers.size(); ++i)
+ modifiers->putDirectIndex(exec, i, objectForPaymentDetailsModifier(vm, exec, paymentDetails.modifiers[i]));
+
+ auto* object = constructEmptyObject(exec);
+ object->putDirect(vm, Identifier::fromString(exec, "id"), jsString(exec, paymentDetails.id));
+ object->putDirect(vm, Identifier::fromString(exec, "total"), objectForPaymentItem(vm, exec, paymentDetails.total));
+ object->putDirect(vm, Identifier::fromString(exec, "displayItems"), displayItems);
+ object->putDirect(vm, Identifier::fromString(exec, "shippingOptions"), shippingOptions);
+ object->putDirect(vm, Identifier::fromString(exec, "modifiers"), modifiers);
+ return object;
+}
+
+static JSString* jsStringForPaymentRequestState(VM& vm, ExecState* exec, PaymentRequest::State state)
+{
+ switch (state) {
+ case PaymentRequest::State::Created:
+ return jsNontrivialString(exec, ASCIILiteral("created"));
+ case PaymentRequest::State::Interactive:
+ return jsNontrivialString(exec, ASCIILiteral("interactive"));
+ case PaymentRequest::State::Closed:
+ return jsNontrivialString(exec, ASCIILiteral("closed"));
+ }
+
+ ASSERT_NOT_REACHED();
+ return jsEmptyString(&vm);
+}
+#endif
+
+JSValue WebInjectedScriptHost::getInternalProperties(VM& vm, ExecState* exec, JSC::JSValue value)
+{
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+#if ENABLE(PAYMENT_REQUEST)
+ if (PaymentRequest* paymentRequest = JSPaymentRequest::toWrapped(vm, value)) {
+ unsigned index = 0;
+ auto* array = constructEmptyArray(exec, nullptr);
+ array->putDirectIndex(exec, index++, constructInternalProperty(vm, exec, ASCIILiteral("options"), objectForPaymentOptions(vm, exec, paymentRequest->paymentOptions())));
+ array->putDirectIndex(exec, index++, constructInternalProperty(vm, exec, ASCIILiteral("details"), objectForPaymentDetails(vm, exec, paymentRequest->paymentDetails())));
+ array->putDirectIndex(exec, index++, constructInternalProperty(vm, exec, ASCIILiteral("state"), jsStringForPaymentRequestState(vm, exec, paymentRequest->state())));
+ RETURN_IF_EXCEPTION(scope, { });
+ return array;
+ }
+#else
+ UNUSED_PARAM(exec);
+ UNUSED_PARAM(value);
+#endif
+
+ return { };
+}
+
bool WebInjectedScriptHost::isHTMLAllCollection(JSC::VM& vm, JSC::JSValue value)
{
return value.inherits(vm, JSHTMLAllCollection::info());
Modified: trunk/Source/WebCore/inspector/WebInjectedScriptHost.h (224605 => 224606)
--- trunk/Source/WebCore/inspector/WebInjectedScriptHost.h 2017-11-09 00:25:05 UTC (rev 224605)
+++ trunk/Source/WebCore/inspector/WebInjectedScriptHost.h 2017-11-09 00:36:15 UTC (rev 224606)
@@ -34,6 +34,7 @@
static Ref<WebInjectedScriptHost> create() { return adoptRef(*new WebInjectedScriptHost); }
JSC::JSValue subtype(JSC::ExecState*, JSC::JSValue) override;
+ JSC::JSValue getInternalProperties(JSC::VM&, JSC::ExecState*, JSC::JSValue) override;
bool isHTMLAllCollection(JSC::VM&, JSC::JSValue) override;
};
Modified: trunk/Source/WebCore/testing/Internals.cpp (224605 => 224606)
--- trunk/Source/WebCore/testing/Internals.cpp 2017-11-09 00:25:05 UTC (rev 224605)
+++ trunk/Source/WebCore/testing/Internals.cpp 2017-11-09 00:36:15 UTC (rev 224606)
@@ -148,6 +148,7 @@
#include "UserGestureIndicator.h"
#include "UserMediaController.h"
#include "ViewportArguments.h"
+#include "VoidCallback.h"
#include "WebCoreJSClientData.h"
#if ENABLE(WEBGL)
#include "WebGLRenderingContext.h"
@@ -3897,6 +3898,12 @@
return UserGestureIndicator::processingUserGesture();
}
+void Internals::withUserGesture(RefPtr<VoidCallback>&& callback)
+{
+ UserGestureIndicator gestureIndicator(ProcessingUserGesture, contextDocument());
+ callback->handleEvent();
+}
+
double Internals::lastHandledUserGestureTimestamp()
{
Document* document = contextDocument();
Modified: trunk/Source/WebCore/testing/Internals.h (224605 => 224606)
--- trunk/Source/WebCore/testing/Internals.h 2017-11-09 00:25:05 UTC (rev 224605)
+++ trunk/Source/WebCore/testing/Internals.h 2017-11-09 00:36:15 UTC (rev 224606)
@@ -76,9 +76,9 @@
class MockPaymentCoordinator;
class NodeList;
class Page;
+class RTCPeerConnection;
class Range;
class RenderedDocumentMarker;
-class RTCPeerConnection;
class SVGSVGElement;
class SerializedScriptValue;
class SourceBuffer;
@@ -86,6 +86,7 @@
class StyleSheet;
class TimeRanges;
class TypeConversions;
+class VoidCallback;
class WebGLRenderingContext;
class XMLHttpRequest;
@@ -558,6 +559,8 @@
bool isProcessingUserGesture();
double lastHandledUserGestureTimestamp();
+ void withUserGesture(RefPtr<VoidCallback>&&);
+
RefPtr<GCObservation> observeGC(JSC::JSValue);
enum class UserInterfaceLayoutDirection { LTR, RTL };
Modified: trunk/Source/WebCore/testing/Internals.idl (224605 => 224606)
--- trunk/Source/WebCore/testing/Internals.idl 2017-11-09 00:25:05 UTC (rev 224605)
+++ trunk/Source/WebCore/testing/Internals.idl 2017-11-09 00:36:15 UTC (rev 224606)
@@ -513,6 +513,8 @@
boolean isProcessingUserGesture();
double lastHandledUserGestureTimestamp();
+ void withUserGesture(VoidCallback callback);
+
GCObservation? observeGC(any observed);
void setUserInterfaceLayoutDirection(UserInterfaceLayoutDirection userInterfaceLayoutDirection);
Modified: trunk/Source/WebInspectorUI/ChangeLog (224605 => 224606)
--- trunk/Source/WebInspectorUI/ChangeLog 2017-11-09 00:25:05 UTC (rev 224605)
+++ trunk/Source/WebInspectorUI/ChangeLog 2017-11-09 00:36:15 UTC (rev 224606)
@@ -1,3 +1,18 @@
+2017-11-08 Joseph Pecoraro <pecor...@apple.com>
+
+ Web Inspector: Show Internal properties of PaymentRequest in Web Inspector Console
+ https://bugs.webkit.org/show_bug.cgi?id=179276
+
+ Reviewed by Andy Estes.
+
+ * UserInterface/Test.html:
+ * UserInterface/Test/FrontendTestHarness.js:
+ (FrontendTestHarness.prototype.evaluateInPage):
+ * UserInterface/Test/TestUtilities.js: Added.
+ (promisify):
+ Make async tests a little easier to work with by providing promises
+ in some cases that would normally take a callback.
+
2017-11-08 Brian Burg <bb...@apple.com>
Web Inspector: fix incorrect curly quote orientation in a UIString
Modified: trunk/Source/WebInspectorUI/UserInterface/Test/FrontendTestHarness.js (224605 => 224606)
--- trunk/Source/WebInspectorUI/UserInterface/Test/FrontendTestHarness.js 2017-11-09 00:25:05 UTC (rev 224605)
+++ trunk/Source/WebInspectorUI/UserInterface/Test/FrontendTestHarness.js 2017-11-09 00:36:15 UTC (rev 224606)
@@ -86,7 +86,10 @@
return;
}
- RuntimeAgent.evaluate.invoke({_expression_, objectGroup: "test", includeCommandLineAPI: false}, callback);
+ if (typeof callback === "function")
+ RuntimeAgent.evaluate.invoke({_expression_, objectGroup: "test", includeCommandLineAPI: false}, callback);
+ else
+ return RuntimeAgent.evaluate.invoke({_expression_, objectGroup: "test", includeCommandLineAPI: false});
}
debug()
Added: trunk/Source/WebInspectorUI/UserInterface/Test/TestUtilities.js (0 => 224606)
--- trunk/Source/WebInspectorUI/UserInterface/Test/TestUtilities.js (rev 0)
+++ trunk/Source/WebInspectorUI/UserInterface/Test/TestUtilities.js 2017-11-09 00:36:15 UTC (rev 224606)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+//
+// This can be used to get a promise for any function that takes a callback.
+//
+// For example:
+//
+// object.getValues(arg1, arg2, (callbackArg1, callbackArg2) => {
+// ...
+// });
+//
+// Can be promisified like so:
+//
+// promisify((cb) => { object.getValues(arg1, arg2, cb); }).then([callbackArg1, callbackArg2]) {
+// ...
+// });
+//
+// Or more naturally with await:
+//
+// let [callbackArg1, callbackArg2] = await promisify((cb) => { object.getValues(arg1, arg2, cb); });
+//
+
+function promisify(func) {
+ return new Promise((resolve, reject) => {
+ try {
+ func((...args) => { resolve(args); });
+ } catch (e) {
+ reject(e);
+ }
+ });
+}
Modified: trunk/Source/WebInspectorUI/UserInterface/Test.html (224605 => 224606)
--- trunk/Source/WebInspectorUI/UserInterface/Test.html 2017-11-09 00:25:05 UTC (rev 224605)
+++ trunk/Source/WebInspectorUI/UserInterface/Test.html 2017-11-09 00:36:15 UTC (rev 224606)
@@ -48,6 +48,7 @@
<script src=""
<script src=""
<script src=""
+ <script src=""
<script src=""
<script src=""