From eae1cfc23ae083ee3880454f0e180a36eb2df90b Mon Sep 17 00:00:00 2001 From: mocsa <13969648+mocsa@users.noreply.github.com> Date: Sat, 4 Feb 2023 18:59:55 +0100 Subject: [PATCH 1/3] Make saveObject() work in unsecure contexts A solution for #416 . Calculates the UUID using getRandomValues() until randomUUID() is only available in secure contexts (HTTPS and localhost). --- client-side-js/injectUI5.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/client-side-js/injectUI5.js b/client-side-js/injectUI5.js index fc3d5de0..1c9e6d5a 100644 --- a/client-side-js/injectUI5.js +++ b/client-side-js/injectUI5.js @@ -35,7 +35,11 @@ async function clientSide_injectUI5(config, waitForUI5Timeout, browserInstance) * @returns uuid */ window.wdi5.saveObject = (object) => { - const uuid = crypto.randomUUID() + // This is a manual replacement for crypto.randomUUID() + // until it is only available in secure contexts. + // See https://github.com/WICG/uuid/issues/23 + const uuid = ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c => + ( c ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))).toString(16) ) window.wdi5.objectMap[uuid] = object return uuid } From 8025c914d73cee87e73a9fad76ccae059e693a30 Mon Sep 17 00:00:00 2001 From: mocsa <13969648+mocsa@users.noreply.github.com> Date: Fri, 10 Feb 2023 11:07:06 +0100 Subject: [PATCH 2/3] New test for using getObject() on an aggregation. --- examples/ui5-js-app/webapp/test/e2e/aggregation.test.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/examples/ui5-js-app/webapp/test/e2e/aggregation.test.js b/examples/ui5-js-app/webapp/test/e2e/aggregation.test.js index adf0a349..696ba22f 100644 --- a/examples/ui5-js-app/webapp/test/e2e/aggregation.test.js +++ b/examples/ui5-js-app/webapp/test/e2e/aggregation.test.js @@ -11,6 +11,15 @@ describe("ui5 aggregation retrieval", () => { browser.screenshot("aggregation") }) + it.only("check the getBinding of a table", async () => { + const mytable = await Other.getList() + const firstrow = await mytable.getItems(0) + const rowcontext = await firstrow.getBindingContext() + const myobject = await rowcontext.getObject() + + expect(myobject.FirstName).toEqual("Nancy") + }) + it("select controls of a sap.m.Page's content aggregation", async () => { // goal: assert that .getContent() and .getAggregation("items") work the same // including access via the fluent async api From af949ab4d848e648dfd3ce5936a91c196f44adb3 Mon Sep 17 00:00:00 2001 From: Volker Buzek Date: Thu, 23 Feb 2023 19:47:38 +0100 Subject: [PATCH 3/3] test: rm .only --- examples/ui5-js-app/webapp/test/e2e/aggregation.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/ui5-js-app/webapp/test/e2e/aggregation.test.js b/examples/ui5-js-app/webapp/test/e2e/aggregation.test.js index 696ba22f..fbef5cee 100644 --- a/examples/ui5-js-app/webapp/test/e2e/aggregation.test.js +++ b/examples/ui5-js-app/webapp/test/e2e/aggregation.test.js @@ -11,7 +11,7 @@ describe("ui5 aggregation retrieval", () => { browser.screenshot("aggregation") }) - it.only("check the getBinding of a table", async () => { + it("check the getBinding of a table", async () => { const mytable = await Other.getList() const firstrow = await mytable.getItems(0) const rowcontext = await firstrow.getBindingContext() @@ -19,7 +19,7 @@ describe("ui5 aggregation retrieval", () => { expect(myobject.FirstName).toEqual("Nancy") }) - + it("select controls of a sap.m.Page's content aggregation", async () => { // goal: assert that .getContent() and .getAggregation("items") work the same // including access via the fluent async api