@elliemae/ssf-host 2.28.6 → 2.29.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/guest.js +5 -5
- package/dist/cjs/host.js +180 -151
- package/dist/cjs/tests/utils.js +8 -0
- package/dist/cjs/utils.js +1 -1
- package/dist/esm/guest.js +5 -5
- package/dist/esm/host.js +180 -151
- package/dist/esm/tests/utils.js +8 -0
- package/dist/esm/utils.js +1 -1
- package/dist/public/callchain-host.html +1 -1
- package/dist/public/callchain-intermediate.html +1 -1
- package/dist/public/e2e-host.html +1 -1
- package/dist/public/e2e-index.html +1 -1
- package/dist/public/index.html +1 -1
- package/dist/public/js/emuiSsfHost.4b00d8e6203361c7da33.js +3 -0
- package/dist/public/js/emuiSsfHost.4b00d8e6203361c7da33.js.br +0 -0
- package/dist/public/js/emuiSsfHost.4b00d8e6203361c7da33.js.gz +0 -0
- package/dist/public/js/emuiSsfHost.4b00d8e6203361c7da33.js.map +1 -0
- package/dist/public/popup-focus-host.html +1 -1
- package/dist/public/utils.js +1 -1
- package/dist/public/utils.js.br +0 -0
- package/dist/public/utils.js.gz +0 -0
- package/dist/public/utils.js.map +1 -1
- package/dist/public/v1-guest-v2-host.html +1 -1
- package/dist/public/v2-host-v1-guest.html +1 -1
- package/dist/types/lib/guest.d.ts +2 -2
- package/dist/types/lib/host.d.ts +4 -4
- package/dist/types/lib/ihost.d.ts +3 -3
- package/dist/types/lib/tests/scriptingObjects/analytics.d.ts +1 -1
- package/dist/types/lib/tests/scriptingObjects/appEvents.d.ts +2 -2
- package/dist/types/lib/tests/scriptingObjects/appObjects.d.ts +3 -3
- package/dist/types/lib/tests/scriptingObjects/appraisalServiceModule.d.ts +1 -1
- package/dist/types/lib/tests/scriptingObjects/creditServiceModule.d.ts +1 -1
- package/dist/types/lib/tests/server.d.ts +1 -1
- package/dist/types/lib/tests/utils.d.ts +21 -3
- package/dist/types/lib/utils.d.ts +2 -2
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.br +0 -0
- package/dist/umd/index.js.gz +0 -0
- package/dist/umd/index.js.map +1 -1
- package/dist/umd/utils.js +1 -1
- package/dist/umd/utils.js.br +0 -0
- package/dist/umd/utils.js.gz +0 -0
- package/dist/umd/utils.js.map +1 -1
- package/package.json +8 -8
- package/dist/public/js/emuiSsfHost.13ebecc9684f2da752d9.js +0 -3
- package/dist/public/js/emuiSsfHost.13ebecc9684f2da752d9.js.br +0 -0
- package/dist/public/js/emuiSsfHost.13ebecc9684f2da752d9.js.gz +0 -0
- package/dist/public/js/emuiSsfHost.13ebecc9684f2da752d9.js.map +0 -1
package/dist/esm/host.js
CHANGED
|
@@ -26,7 +26,6 @@ const SANDBOX_DEFAULT = [
|
|
|
26
26
|
IFrameSandboxValues.AllowSameOrigin
|
|
27
27
|
];
|
|
28
28
|
class SSFHost {
|
|
29
|
-
/* eslint-enable indent */
|
|
30
29
|
/**
|
|
31
30
|
* unique identifier for the host
|
|
32
31
|
*/
|
|
@@ -46,7 +45,6 @@ class SSFHost {
|
|
|
46
45
|
/**
|
|
47
46
|
* reference to the analytics object
|
|
48
47
|
*/
|
|
49
|
-
#analyticsObj;
|
|
50
48
|
/**
|
|
51
49
|
* list of guests
|
|
52
50
|
*/
|
|
@@ -102,31 +100,16 @@ class SSFHost {
|
|
|
102
100
|
*/
|
|
103
101
|
constructor(hostId, option) {
|
|
104
102
|
this.hostId = hostId;
|
|
105
|
-
|
|
106
|
-
if (!option?.analyticsObj) throw new Error("Analytics object is required");
|
|
103
|
+
this.#validateHostOptions(option);
|
|
107
104
|
this.#logger = option.logger;
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
enabled: option?.measurePerformance,
|
|
112
|
-
samplingRatio: option?.performanceSamplingRatio,
|
|
113
|
-
onError: (msg) => this.#logger.debug(msg)
|
|
114
|
-
};
|
|
115
|
-
this.#perfTracker = new PerformanceTracker({
|
|
116
|
-
...perfOpts,
|
|
117
|
-
dedupWindowMs: option?.performanceDedupWindowMs
|
|
118
|
-
});
|
|
119
|
-
this.#guestPerfTracker = new PerformanceTracker({
|
|
120
|
-
...perfOpts,
|
|
121
|
-
dedupWindowMs: 0
|
|
122
|
-
});
|
|
105
|
+
const trackers = this.#createPerfTrackers(option);
|
|
106
|
+
this.#perfTracker = trackers.perfTracker;
|
|
107
|
+
this.#guestPerfTracker = trackers.guestPerfTracker;
|
|
123
108
|
this.#correlationId = uuidv4();
|
|
124
109
|
this.#remoting = new Remoting(this.#logger, this.#correlationId);
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
this.#
|
|
128
|
-
this.#onGuestEventSubscribe = option?.onGuestEventSubscribe || null;
|
|
129
|
-
this.#onGuestEventUnsubscribe = option?.onGuestEventUnsubscribe || null;
|
|
110
|
+
this.#readyStateCallback = option.readyStateCallback ?? null;
|
|
111
|
+
this.#onGuestEventSubscribe = option.onGuestEventSubscribe ?? null;
|
|
112
|
+
this.#onGuestEventUnsubscribe = option.onGuestEventUnsubscribe ?? null;
|
|
130
113
|
this.#soManager = new ScriptingObjectManager();
|
|
131
114
|
this.#remoting.initialize(window);
|
|
132
115
|
this.#connect();
|
|
@@ -135,14 +118,31 @@ class SSFHost {
|
|
|
135
118
|
`host is initialized. hostId: ${this.hostId}, correlationId: ${this.#correlationId}`
|
|
136
119
|
);
|
|
137
120
|
}
|
|
138
|
-
#
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
121
|
+
#validateHostOptions(option) {
|
|
122
|
+
if (!option?.logger) throw new Error("Logger is required");
|
|
123
|
+
if (!option?.analyticsObj) throw new Error("Analytics object is required");
|
|
124
|
+
if (option.readyStateCallback && typeof option.readyStateCallback !== "function") {
|
|
125
|
+
throw new Error("readyStateCallback must be a function");
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
#createPerfTrackers(option) {
|
|
129
|
+
const perfOpts = {
|
|
130
|
+
analyticsObj: option.analyticsObj,
|
|
131
|
+
enabled: option.measurePerformance,
|
|
132
|
+
samplingRatio: option.performanceSamplingRatio,
|
|
133
|
+
onError: (msg) => this.#logger.debug(msg)
|
|
134
|
+
};
|
|
135
|
+
return {
|
|
136
|
+
perfTracker: new PerformanceTracker({
|
|
137
|
+
...perfOpts,
|
|
138
|
+
dedupWindowMs: option.performanceDedupWindowMs
|
|
139
|
+
}),
|
|
140
|
+
guestPerfTracker: new PerformanceTracker({
|
|
141
|
+
...perfOpts,
|
|
142
|
+
dedupWindowMs: 0
|
|
143
|
+
})
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
146
|
#closeAllPopupGuests = () => {
|
|
147
147
|
const popupIds = Array.from(this.#guests.values()).filter((guest) => guest.openMode === OpenMode.Popup).map((guest) => guest.id);
|
|
148
148
|
popupIds.forEach((id) => this.unloadGuest(id));
|
|
@@ -164,10 +164,7 @@ class SSFHost {
|
|
|
164
164
|
* @param value javascript object
|
|
165
165
|
* @returns true if the object is a scripting object
|
|
166
166
|
*/
|
|
167
|
-
#isScriptingObject = (value) =>
|
|
168
|
-
// eslint-disable-next-line no-underscore-dangle, @typescript-eslint/no-unsafe-member-access
|
|
169
|
-
typeof value?._toJSON === "function"
|
|
170
|
-
);
|
|
167
|
+
#isScriptingObject = (value) => typeof value === "object" && value !== null && "_toJSON" in value && typeof value._toJSON === "function";
|
|
171
168
|
#encodeResponse = (val, guest) => {
|
|
172
169
|
if (this.#isScriptingObject(val)) {
|
|
173
170
|
if (!this.#soManager.has(
|
|
@@ -182,15 +179,6 @@ class SSFHost {
|
|
|
182
179
|
}
|
|
183
180
|
return { type: "value", value: val };
|
|
184
181
|
};
|
|
185
|
-
#encodeException = (ex) => {
|
|
186
|
-
if (typeof ex === "string") {
|
|
187
|
-
return ex;
|
|
188
|
-
}
|
|
189
|
-
if (ex instanceof Error) {
|
|
190
|
-
return ex.message;
|
|
191
|
-
}
|
|
192
|
-
return "An unexpected error occurred in the host application";
|
|
193
|
-
};
|
|
194
182
|
#dispatchConfigEvent = (guest) => {
|
|
195
183
|
if (guest.ready) {
|
|
196
184
|
this.#remoting.send({
|
|
@@ -235,7 +223,7 @@ class SSFHost {
|
|
|
235
223
|
enumerable: true,
|
|
236
224
|
writable: true
|
|
237
225
|
});
|
|
238
|
-
resolve(func
|
|
226
|
+
resolve(Reflect.apply(func, obj, functionParams));
|
|
239
227
|
});
|
|
240
228
|
};
|
|
241
229
|
#handleGuestReadyComplete = ({
|
|
@@ -642,12 +630,7 @@ class SSFHost {
|
|
|
642
630
|
* @param value
|
|
643
631
|
* @returns
|
|
644
632
|
*/
|
|
645
|
-
#isProxyEvent = (value) =>
|
|
646
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
647
|
-
value instanceof ProxyEvent || // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
648
|
-
typeof value?.subscribe === "function"
|
|
649
|
-
);
|
|
650
|
-
// support v1 scripting objects
|
|
633
|
+
#isProxyEvent = (value) => value instanceof ProxyEvent || typeof value === "object" && value !== null && "subscribe" in value && typeof value.subscribe === "function";
|
|
651
634
|
/**
|
|
652
635
|
* Register pre-rendered guest application to host
|
|
653
636
|
* @param {AttachParam} param - parameters for attaching the guest
|
|
@@ -716,6 +699,25 @@ class SSFHost {
|
|
|
716
699
|
const popupUrl = handshakeToken ? `${url}#hs=${handshakeToken}` : url;
|
|
717
700
|
return { popupUrl, handshakeToken, trusted };
|
|
718
701
|
};
|
|
702
|
+
#focusExistingPopupGuest = (guest, url, title) => {
|
|
703
|
+
if (guest.window.closed) return;
|
|
704
|
+
if (isTrustedDomain(url)) {
|
|
705
|
+
window.open("", title);
|
|
706
|
+
} else {
|
|
707
|
+
guest.window.focus();
|
|
708
|
+
}
|
|
709
|
+
};
|
|
710
|
+
#scheduleGuestLifecycleCallback = (callback, guestId, label) => {
|
|
711
|
+
setTimeout(() => {
|
|
712
|
+
try {
|
|
713
|
+
callback?.(guestId);
|
|
714
|
+
} catch (error) {
|
|
715
|
+
this.#logger.debug(
|
|
716
|
+
`Error occurred in ${label} for guest with id '${guestId}': ${error.message}`
|
|
717
|
+
);
|
|
718
|
+
}
|
|
719
|
+
}, 0);
|
|
720
|
+
};
|
|
719
721
|
#openPopupGuest = (param) => {
|
|
720
722
|
const {
|
|
721
723
|
url,
|
|
@@ -734,13 +736,7 @@ class SSFHost {
|
|
|
734
736
|
} = popupWindowFeatures;
|
|
735
737
|
let guest = this.#getGuestForUrl(url);
|
|
736
738
|
if (guest) {
|
|
737
|
-
|
|
738
|
-
if (isTrustedDomain(url)) {
|
|
739
|
-
window.open("", title);
|
|
740
|
-
} else {
|
|
741
|
-
guest.window.focus();
|
|
742
|
-
}
|
|
743
|
-
}
|
|
739
|
+
this.#focusExistingPopupGuest(guest, url, title);
|
|
744
740
|
} else {
|
|
745
741
|
const windowFeatures = Object.entries({ width, height, top, left }).filter(([, v]) => v).map(([k, v]) => `${k}=${v}`).join(",");
|
|
746
742
|
const { popupUrl, handshakeToken, trusted } = this.#buildPopupUrl(url);
|
|
@@ -750,27 +746,10 @@ class SSFHost {
|
|
|
750
746
|
`popup, ${windowFeatures}`
|
|
751
747
|
);
|
|
752
748
|
if (!guestWindow) {
|
|
753
|
-
|
|
754
|
-
try {
|
|
755
|
-
onError?.(guestId);
|
|
756
|
-
} catch (error) {
|
|
757
|
-
this.#logger.debug(
|
|
758
|
-
`Error occurred in onError for guest with id '${guestId}': ${error.message}`
|
|
759
|
-
);
|
|
760
|
-
}
|
|
761
|
-
}, 0);
|
|
749
|
+
this.#scheduleGuestLifecycleCallback(onError, guestId, "onError");
|
|
762
750
|
throw new Error("Failed to open guest application in popup window");
|
|
763
|
-
} else {
|
|
764
|
-
setTimeout(() => {
|
|
765
|
-
try {
|
|
766
|
-
onLoad?.(guestId);
|
|
767
|
-
} catch (error) {
|
|
768
|
-
this.#logger.debug(
|
|
769
|
-
`Error occurred in onLoad for guest with id '${guestId}': ${error.message}`
|
|
770
|
-
);
|
|
771
|
-
}
|
|
772
|
-
}, 0);
|
|
773
751
|
}
|
|
752
|
+
this.#scheduleGuestLifecycleCallback(onLoad, guestId, "onLoad");
|
|
774
753
|
if (!trusted) {
|
|
775
754
|
guestWindow.opener = null;
|
|
776
755
|
}
|
|
@@ -787,53 +766,28 @@ class SSFHost {
|
|
|
787
766
|
}
|
|
788
767
|
return guest;
|
|
789
768
|
};
|
|
790
|
-
#
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
fitToContent = false,
|
|
804
|
-
disableSandbox = false,
|
|
805
|
-
sandboxValues = [],
|
|
806
|
-
customSandboxValues = [],
|
|
807
|
-
style = "",
|
|
808
|
-
permissionPolicy = ""
|
|
809
|
-
} = options;
|
|
810
|
-
if (!title) throw new Error("title is required");
|
|
811
|
-
if (fitToContent) this.#subscribeToGuestResizeEvent();
|
|
769
|
+
#createEmbedGuestFrame = ({
|
|
770
|
+
targetElementDocument,
|
|
771
|
+
guestId,
|
|
772
|
+
title,
|
|
773
|
+
url,
|
|
774
|
+
style,
|
|
775
|
+
disableSandbox,
|
|
776
|
+
sandboxValues,
|
|
777
|
+
customSandboxValues,
|
|
778
|
+
permissionPolicy,
|
|
779
|
+
onLoad,
|
|
780
|
+
onError
|
|
781
|
+
}) => {
|
|
812
782
|
const frame = targetElementDocument.createElement("iframe");
|
|
813
783
|
frame.setAttribute("id", guestId);
|
|
814
784
|
const onFrameLoad = () => {
|
|
815
|
-
|
|
816
|
-
try {
|
|
817
|
-
onLoad?.(guestId);
|
|
818
|
-
} catch (error) {
|
|
819
|
-
this.#logger.debug(
|
|
820
|
-
`Error occurred in onLoad for guest with id '${guestId}': ${error.message}`
|
|
821
|
-
);
|
|
822
|
-
}
|
|
823
|
-
}, 0);
|
|
785
|
+
this.#scheduleGuestLifecycleCallback(onLoad, guestId, "onLoad");
|
|
824
786
|
this.#logger.debug(`frame loaded for guest with id '${guestId}'`);
|
|
825
787
|
frame.removeEventListener("load", onFrameLoad);
|
|
826
788
|
};
|
|
827
789
|
const onFrameLoadFailure = () => {
|
|
828
|
-
|
|
829
|
-
try {
|
|
830
|
-
onError?.(guestId);
|
|
831
|
-
} catch (error) {
|
|
832
|
-
this.#logger.debug(
|
|
833
|
-
`Error occurred in onError for guest with id '${guestId}': ${error.message}`
|
|
834
|
-
);
|
|
835
|
-
}
|
|
836
|
-
}, 0);
|
|
790
|
+
this.#scheduleGuestLifecycleCallback(onError, guestId, "onError");
|
|
837
791
|
this.#logger.error(`frame load failed for guest with id '${guestId}'`);
|
|
838
792
|
frame.removeEventListener("error", onFrameLoadFailure);
|
|
839
793
|
};
|
|
@@ -852,6 +806,41 @@ class SSFHost {
|
|
|
852
806
|
frame.setAttribute("title", title);
|
|
853
807
|
frame.setAttribute("src", url);
|
|
854
808
|
if (permissionPolicy) frame.setAttribute("allow", permissionPolicy);
|
|
809
|
+
return frame;
|
|
810
|
+
};
|
|
811
|
+
#mountEmbedGuest = ({
|
|
812
|
+
guestId,
|
|
813
|
+
url,
|
|
814
|
+
title,
|
|
815
|
+
searchParams,
|
|
816
|
+
targetElement,
|
|
817
|
+
targetElementDocument,
|
|
818
|
+
onLoad,
|
|
819
|
+
onError,
|
|
820
|
+
options
|
|
821
|
+
}) => {
|
|
822
|
+
const {
|
|
823
|
+
fitToContent = false,
|
|
824
|
+
disableSandbox = false,
|
|
825
|
+
sandboxValues = [],
|
|
826
|
+
customSandboxValues = [],
|
|
827
|
+
style = "",
|
|
828
|
+
permissionPolicy = ""
|
|
829
|
+
} = options;
|
|
830
|
+
if (fitToContent) this.#subscribeToGuestResizeEvent();
|
|
831
|
+
const frame = this.#createEmbedGuestFrame({
|
|
832
|
+
targetElementDocument,
|
|
833
|
+
guestId,
|
|
834
|
+
title,
|
|
835
|
+
url,
|
|
836
|
+
style,
|
|
837
|
+
disableSandbox,
|
|
838
|
+
sandboxValues,
|
|
839
|
+
customSandboxValues,
|
|
840
|
+
permissionPolicy,
|
|
841
|
+
onLoad,
|
|
842
|
+
onError
|
|
843
|
+
});
|
|
855
844
|
targetElement.appendChild(frame);
|
|
856
845
|
const guestFrameEle = targetElementDocument.getElementById(
|
|
857
846
|
guestId
|
|
@@ -866,6 +855,31 @@ class SSFHost {
|
|
|
866
855
|
openMode: OpenMode.Embed
|
|
867
856
|
});
|
|
868
857
|
};
|
|
858
|
+
#openEmbedGuest = (param) => {
|
|
859
|
+
const {
|
|
860
|
+
url,
|
|
861
|
+
title,
|
|
862
|
+
targetElement,
|
|
863
|
+
searchParams,
|
|
864
|
+
guestId,
|
|
865
|
+
onLoad,
|
|
866
|
+
onError,
|
|
867
|
+
options = {}
|
|
868
|
+
} = param;
|
|
869
|
+
if (!title) throw new Error("title is required");
|
|
870
|
+
const targetElementDocument = targetElement.ownerDocument ?? document;
|
|
871
|
+
return this.#mountEmbedGuest({
|
|
872
|
+
guestId,
|
|
873
|
+
url,
|
|
874
|
+
title,
|
|
875
|
+
searchParams,
|
|
876
|
+
targetElement,
|
|
877
|
+
targetElementDocument,
|
|
878
|
+
onLoad,
|
|
879
|
+
onError,
|
|
880
|
+
options
|
|
881
|
+
});
|
|
882
|
+
};
|
|
869
883
|
#getGuestUrl = (url, params) => {
|
|
870
884
|
let querystring = "";
|
|
871
885
|
Object.keys(params).forEach((queryParam) => {
|
|
@@ -916,9 +930,7 @@ class SSFHost {
|
|
|
916
930
|
eventOptions
|
|
917
931
|
}) => this.dispatchEvent({
|
|
918
932
|
event,
|
|
919
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
920
933
|
eventParams,
|
|
921
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
922
934
|
eventOptions
|
|
923
935
|
});
|
|
924
936
|
const token = propValue.subscribe(
|
|
@@ -928,17 +940,18 @@ class SSFHost {
|
|
|
928
940
|
propValue.unsubscribe(token);
|
|
929
941
|
});
|
|
930
942
|
} else {
|
|
931
|
-
const
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
943
|
+
const v1Proxy = propValue;
|
|
944
|
+
const token = v1Proxy.subscribe?.(
|
|
945
|
+
(_obj, params, options) => {
|
|
946
|
+
void this.dispatchEvent({
|
|
947
|
+
event,
|
|
948
|
+
eventParams: params,
|
|
949
|
+
eventOptions: options
|
|
950
|
+
});
|
|
951
|
+
}
|
|
939
952
|
);
|
|
940
953
|
unsubscribers.push(() => {
|
|
941
|
-
|
|
954
|
+
if (token) v1Proxy.unsubscribe?.(token);
|
|
942
955
|
});
|
|
943
956
|
}
|
|
944
957
|
} else if (isFunction(propValue)) {
|
|
@@ -1001,6 +1014,30 @@ class SSFHost {
|
|
|
1001
1014
|
`host is closed. hostId: ${this.hostId}, correlationId: ${this.#correlationId}`
|
|
1002
1015
|
);
|
|
1003
1016
|
};
|
|
1017
|
+
#buildEventObject = ({
|
|
1018
|
+
scriptingObject,
|
|
1019
|
+
eventName,
|
|
1020
|
+
eventParams,
|
|
1021
|
+
eventHandler,
|
|
1022
|
+
timeout
|
|
1023
|
+
}) => {
|
|
1024
|
+
const eventObj = {
|
|
1025
|
+
object: scriptingObject._toJSON(),
|
|
1026
|
+
eventName,
|
|
1027
|
+
eventParams,
|
|
1028
|
+
eventHandler,
|
|
1029
|
+
eventOptions: {
|
|
1030
|
+
allowsFeedback: false
|
|
1031
|
+
}
|
|
1032
|
+
};
|
|
1033
|
+
if (timeout && !Number.isNaN(timeout)) {
|
|
1034
|
+
eventObj.eventOptions = {
|
|
1035
|
+
allowsFeedback: true,
|
|
1036
|
+
timeout: Number(timeout)
|
|
1037
|
+
};
|
|
1038
|
+
}
|
|
1039
|
+
return eventObj;
|
|
1040
|
+
};
|
|
1004
1041
|
#dispatchEventToMatchingGuests = ({
|
|
1005
1042
|
targetGuest,
|
|
1006
1043
|
guestCapabilities,
|
|
@@ -1053,22 +1090,13 @@ class SSFHost {
|
|
|
1053
1090
|
);
|
|
1054
1091
|
return Promise.resolve([]);
|
|
1055
1092
|
}
|
|
1056
|
-
const eventObj = {
|
|
1057
|
-
|
|
1058
|
-
object: scriptingObject._toJSON(),
|
|
1093
|
+
const eventObj = this.#buildEventObject({
|
|
1094
|
+
scriptingObject,
|
|
1059
1095
|
eventName: name,
|
|
1060
1096
|
eventParams,
|
|
1061
1097
|
eventHandler,
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
}
|
|
1065
|
-
};
|
|
1066
|
-
if (timeout && !Number.isNaN(timeout)) {
|
|
1067
|
-
eventObj.eventOptions = {
|
|
1068
|
-
allowsFeedback: true,
|
|
1069
|
-
timeout: Number(timeout)
|
|
1070
|
-
};
|
|
1071
|
-
}
|
|
1098
|
+
timeout
|
|
1099
|
+
});
|
|
1072
1100
|
const guestPromises = [];
|
|
1073
1101
|
let eventTimingToken;
|
|
1074
1102
|
const dispatchToGuest = (guest) => {
|
|
@@ -1138,6 +1166,14 @@ class SSFHost {
|
|
|
1138
1166
|
* @returns scripting object
|
|
1139
1167
|
*/
|
|
1140
1168
|
getScriptingObject = (objectId, params) => this.#soManager.getObject(objectId, params?.guest);
|
|
1169
|
+
#resolveUniqueGuestInstanceId = (guestId) => {
|
|
1170
|
+
if (!this.#guests.has(guestId)) return guestId;
|
|
1171
|
+
let counter = 1;
|
|
1172
|
+
while (this.#guests.has(`${guestId}-${counter}`)) {
|
|
1173
|
+
counter += 1;
|
|
1174
|
+
}
|
|
1175
|
+
return `${guestId}-${counter}`;
|
|
1176
|
+
};
|
|
1141
1177
|
/**
|
|
1142
1178
|
* loads guest application inside sandboxed iframe
|
|
1143
1179
|
* @param {LoadGuestParam} param - parameters for loading the guest application
|
|
@@ -1156,21 +1192,14 @@ class SSFHost {
|
|
|
1156
1192
|
metadata
|
|
1157
1193
|
} = param;
|
|
1158
1194
|
if (!guestId) throw new Error("id for guest application is required");
|
|
1159
|
-
|
|
1160
|
-
if (this.#guests.has(instanceId)) {
|
|
1161
|
-
let counter = 1;
|
|
1162
|
-
while (this.#guests.has(`${guestId}-${counter}`)) {
|
|
1163
|
-
counter += 1;
|
|
1164
|
-
}
|
|
1165
|
-
instanceId = `${guestId}-${counter}`;
|
|
1166
|
-
}
|
|
1195
|
+
const instanceId = this.#resolveUniqueGuestInstanceId(guestId);
|
|
1167
1196
|
const { openMode = OpenMode.Embed, popupWindowFeatures = {} } = options;
|
|
1168
1197
|
const srcUrl = this.#getGuestUrl(url, searchParams);
|
|
1169
|
-
let guest = null;
|
|
1170
1198
|
this.#perfTracker.start("SSF.Guest.Load", {
|
|
1171
1199
|
appId: instanceId,
|
|
1172
1200
|
appUrl: srcUrl
|
|
1173
1201
|
});
|
|
1202
|
+
let guest;
|
|
1174
1203
|
if (openMode === OpenMode.Popup) {
|
|
1175
1204
|
guest = this.#openPopupGuest({
|
|
1176
1205
|
guestId: instanceId,
|
package/dist/esm/tests/utils.js
CHANGED
|
@@ -49,8 +49,16 @@ const initGuest = (guestId, capabilities = { eventFeedback: true }) => {
|
|
|
49
49
|
const releaseJSThread = () => new Promise((resolve) => {
|
|
50
50
|
setTimeout(resolve, 0);
|
|
51
51
|
});
|
|
52
|
+
const getCallContext = (fn) => {
|
|
53
|
+
const callContext = fn.callContext;
|
|
54
|
+
if (!callContext) {
|
|
55
|
+
throw new Error("callContext not set on function");
|
|
56
|
+
}
|
|
57
|
+
return callContext;
|
|
58
|
+
};
|
|
52
59
|
export {
|
|
53
60
|
createHost,
|
|
61
|
+
getCallContext,
|
|
54
62
|
initGuest,
|
|
55
63
|
postMessage,
|
|
56
64
|
releaseJSThread
|
package/dist/esm/utils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><title>CallChain E2E Test - Root Host</title><script src="https://cdn.tailwindcss.com?plugins=forms"></script><script src="https://cdn.mortgagetech.q1.ice.com/pui-diagnostics@3"></script><script defer="defer" src="js/emuiSsfHost.
|
|
1
|
+
<!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><title>CallChain E2E Test - Root Host</title><script src="https://cdn.tailwindcss.com?plugins=forms"></script><script src="https://cdn.mortgagetech.q1.ice.com/pui-diagnostics@3"></script><script defer="defer" src="js/emuiSsfHost.4b00d8e6203361c7da33.js"></script></head><body class="bg-gray-50"><header class="bg-indigo-600 text-white px-4 py-3 flex items-center justify-between"><h1 class="text-lg font-semibold">CallChain E2E Test — Root Host (A)</h1><a href="./index.html" class="text-indigo-200 hover:text-white text-sm">← Back to main</a></header><main class="mx-auto max-w-7xl px-4 py-4"><div class="grid grid-cols-2 gap-4 mb-4"><div class="bg-blue-50 border border-blue-200 rounded-md p-3"><h2 class="text-sm font-bold text-blue-900 mb-2">Architecture</h2><pre class="text-xs text-blue-800 leading-relaxed">
|
|
2
2
|
Root Host (A) [localhost:4000]
|
|
3
3
|
├─ Exposes: <strong>TestService</strong> scripting object
|
|
4
4
|
├─ Loads guest <strong>"intermediateHost"</strong>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><title>Intermediate Guest+Host (B)</title><script src="https://cdn.tailwindcss.com?plugins=forms"></script><script src="https://cdn.mortgagetech.q1.ice.com/pui-diagnostics@3"></script><script src="http://localhost:4001/index.js"></script><script defer="defer" src="js/emuiSsfHost.
|
|
1
|
+
<!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><title>Intermediate Guest+Host (B)</title><script src="https://cdn.tailwindcss.com?plugins=forms"></script><script src="https://cdn.mortgagetech.q1.ice.com/pui-diagnostics@3"></script><script src="http://localhost:4001/index.js"></script><script defer="defer" src="js/emuiSsfHost.4b00d8e6203361c7da33.js"></script></head><body class="bg-orange-50 p-2"><h2 class="text-sm font-semibold text-orange-800 mb-1">Intermediate (B) — Guest + Host</h2><div data-testid="intermediate-status" id="status" class="text-xs bg-orange-100 rounded p-2 mb-2 min-h-[30px]">Initializing...</div><div data-testid="grandchild-container" id="grandchild-container" class="border border-dashed border-orange-400 rounded h-[250px]"></div><script type="module">import{Analytics}from"./analytics-object-v2.js";import{getGuestBaseUrl,getHost}from"./utils.js";const statusEl=document.getElementById("status"),log=t=>{const e=(new Date).toLocaleTimeString();statusEl.innerHTML+=`<div>[${e}] ${t}</div>`};(async()=>{try{log("Connecting to Root Host (A) as V2 guest...");const t=new ice.guest.SSFGuest({logger:{index:"intermediate-guest",team:"ui platform",appName:"intermediate-b"},keepAlive:!1});await t.connect(),log("Connected to Root Host (A)");const e=await t.getObject("TestService");log("Got TestService proxy from Root Host (A)");const o=new Analytics,a=getHost(o);if(!a)return void log("ERROR: Failed to create intermediate SSFHost");log("Created intermediate SSFHost (B)");const n=a.cloneScriptingObject(e);a.addScriptingObject(n),log("Cloned TestService for grandchild guests");const i=await getGuestBaseUrl();a.loadGuest({id:"grandchildGuest",url:new URL("./callchain-grandchild.html",i).href,title:"Grandchild Guest (C)",targetElement:document.getElementById("grandchild-container"),metadata:{role:"validator",region:"US-East"},onLoad:()=>log("Grandchild guest (C) loaded"),onError:()=>log("ERROR: Grandchild guest (C) failed to load")}),log("Intermediate (B) ready")}catch(t){log(`ERROR: ${t.message}`)}})()</script></body></html>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><title>SSF E2E — Comprehensive Host Test</title><script src="https://cdn.tailwindcss.com?plugins=forms"></script><script src="https://cdn.mortgagetech.q1.ice.com/pui-diagnostics@3"></script><script defer="defer" src="js/emuiSsfHost.13ebecc9684f2da752d9.js"></script></head><body class="bg-gray-50 text-sm"><header class="bg-indigo-700 text-white px-4 py-3 flex items-center justify-between"><h1 class="text-lg font-semibold">Comprehensive E2E Host Test</h1><a href="./e2e-index.html" class="text-indigo-200 hover:text-white text-sm">← Test Suite</a></header><main class="mx-auto max-w-7xl px-4 py-3"><div class="grid grid-cols-2 gap-3 mb-3"><div class="bg-blue-50 border border-blue-200 rounded-md p-3"><h2 class="text-sm font-bold text-blue-900 mb-1">How to Use This Page</h2><ol class="text-xs text-blue-800 space-y-1 list-decimal list-inside"><li>Start the host dev server (port 4000) and guest dev server (port 4001).</li><li>Buttons in <strong>Column 1</strong> (left) execute host-side actions.</li><li><strong>Column 2</strong> (center) shows embedded guest iframes — interact with them to invoke methods, subscribe to events, etc.</li><li><strong>Column 3</strong> (right) shows live results: Event Log, callContext, dispatch results, and the guest list.</li><li>Work through the buttons <strong>top to bottom</strong> for the recommended flow. Each button is labelled with a test case ID (TC-xxx).</li></ol></div><div class="bg-amber-50 border border-amber-200 rounded-md p-3"><h2 class="text-sm font-bold text-amber-900 mb-1">Recommended Flow</h2><ol class="text-xs text-amber-800 space-y-1 list-decimal list-inside"><li><strong>Load guests</strong>: TC-LOAD-01 (embed) → TC-LOAD-02 (popup) → TC-LOAD-04 (with params). Check Event Log for "loaded" messages.</li><li><strong>Scripting objects</strong>: TC-SO-01 (add Inventory). In the guest iframe, call <code>getObject("Inventory")</code> and invoke <code>getStock()</code>. Check return value and callContext.</li><li><strong>Events</strong>: In the guest, subscribe to <code>Loan.onPreSave</code>. Then click TC-EVT-01 on the host. Guest should receive the event.</li><li><strong>Lifecycle</strong>: TC-LIFE-01 (unload), TC-LIFE-03 (close host). Verify guests are removed and host is destroyed.</li></ol></div></div><div class="grid grid-cols-3 gap-3"><div class="space-y-3"><div class="bg-white rounded-lg shadow p-3"><h2 class="font-semibold text-gray-700 mb-2 border-b pb-1">Guest Loading</h2><div class="space-y-2"><button data-testid="btn-load-embed" id="btnLoadEmbed" class="w-full rounded bg-indigo-600 px-3 py-1.5 text-xs text-white hover:bg-indigo-700">TC-LOAD-01: Load Embedded Guest</button><p class="text-[10px] text-gray-400 -mt-1">Expected: guest iframe appears in center column, log shows "loaded"</p><button data-testid="btn-load-popup" id="btnLoadPopup" class="w-full rounded bg-indigo-600 px-3 py-1.5 text-xs text-white hover:bg-indigo-700">TC-LOAD-02: Load Popup Guest</button><p class="text-[10px] text-gray-400 -mt-1">Expected: new browser popup window opens</p><button data-testid="btn-load-multiple" id="btnLoadMultiple" class="w-full rounded bg-indigo-600 px-3 py-1.5 text-xs text-white hover:bg-indigo-700">TC-LOAD-03: loadGuests (3 instances)</button><p class="text-[10px] text-gray-400 -mt-1">Expected: 3 guest iframes load, "List all guests" shows 3+ entries</p><button data-testid="btn-load-with-params" id="btnLoadWithParams" class="w-full rounded bg-indigo-600 px-3 py-1.5 text-xs text-white hover:bg-indigo-700">TC-LOAD-04: Load with searchParams</button><p class="text-[10px] text-gray-400 -mt-1">Expected: guest shows URL params in its "Params:" line</p><button data-testid="btn-load-with-metadata" id="btnLoadWithMetadata" class="w-full rounded bg-indigo-600 px-3 py-1.5 text-xs text-white hover:bg-indigo-700">TC-META-01: Load with metadata</button><p class="text-[10px] text-gray-400 -mt-1">Expected: when guest invokes a method, callContext.callChain shows metadata</p><button data-testid="btn-load-bad-url" id="btnLoadBadUrl" class="w-full rounded bg-red-600 px-3 py-1.5 text-xs text-white hover:bg-red-700">TC-LOAD-05: Load invalid URL (onError)</button><p class="text-[10px] text-gray-400 -mt-1">Expected: log shows "ERROR" or onError callback fires</p></div></div><div class="bg-white rounded-lg shadow p-3"><h2 class="font-semibold text-gray-700 mb-2 border-b pb-1">Scripting Object Management</h2><div class="space-y-2"><button data-testid="btn-add-so" id="btnAddSO" class="w-full rounded bg-green-600 px-3 py-1.5 text-xs text-white hover:bg-green-700">TC-SO-01: Add "Inventory" Object</button><p class="text-[10px] text-gray-400 -mt-1">Expected: guest can now <code>getObject("Inventory")</code> and invoke its methods</p><button data-testid="btn-add-guest-so" id="btnAddGuestSO" class="w-full rounded bg-green-600 px-3 py-1.5 text-xs text-white hover:bg-green-700">TC-SO-04: Add Guest-Scoped Object</button><p class="text-[10px] text-gray-400 -mt-1">Expected: only the target guest can access this object, others get "not available"</p><button data-testid="btn-remove-so" id="btnRemoveSO" class="w-full rounded bg-yellow-600 px-3 py-1.5 text-xs text-white hover:bg-yellow-700">TC-SO-02: Remove "Inventory" Object</button><p class="text-[10px] text-gray-400 -mt-1">Expected: guest's <code>getObject("Inventory")</code> now fails</p><button data-testid="btn-remove-all-so" id="btnRemoveAllSO" class="w-full rounded bg-yellow-600 px-3 py-1.5 text-xs text-white hover:bg-yellow-700">TC-SO-02b: Remove All Objects</button><p class="text-[10px] text-gray-400 -mt-1">Expected: all getObject calls fail until objects are re-added</p></div></div><div class="bg-white rounded-lg shadow p-3"><h2 class="font-semibold text-gray-700 mb-2 border-b pb-1">Event Dispatching</h2><div class="space-y-2"><button data-testid="btn-dispatch-all" id="btnDispatchAll" class="w-full rounded bg-purple-600 px-3 py-1.5 text-xs text-white hover:bg-purple-700">TC-EVT-01: Dispatch onPreSave to all</button><p class="text-[10px] text-gray-400 -mt-1">Expected: all guests subscribed to onPreSave receive the event</p><button data-testid="btn-dispatch-targeted" id="btnDispatchTargeted" class="w-full rounded bg-purple-600 px-3 py-1.5 text-xs text-white hover:bg-purple-700">TC-EVT-02: Dispatch to specific guest</button><p class="text-[10px] text-gray-400 -mt-1">Expected: only the targeted guest receives the event</p><button data-testid="btn-dispatch-feedback" id="btnDispatchFeedback" class="w-full rounded bg-purple-600 px-3 py-1.5 text-xs text-white hover:bg-purple-700">TC-EVT-03: Dispatch with timeout (feedback)</button><p class="text-[10px] text-gray-400 -mt-1">Expected: Dispatch Results shows the guest's feedback return value</p><button data-testid="btn-dispatch-amount" id="btnDispatchAmount" class="w-full rounded bg-purple-600 px-3 py-1.5 text-xs text-white hover:bg-purple-700">TC-EVT-04: Dispatch onAmountChanged (criteria)</button><p class="text-[10px] text-gray-400 -mt-1">Expected: only guests subscribed with matching criteria receive it</p></div></div><div class="bg-white rounded-lg shadow p-3"><h2 class="font-semibold text-gray-700 mb-2 border-b pb-1">Guest Lifecycle</h2><div class="space-y-2"><button data-testid="btn-unload-guest" id="btnUnloadGuest" class="w-full rounded bg-orange-600 px-3 py-1.5 text-xs text-white hover:bg-orange-700">TC-LIFE-01: Unload first embedded guest</button><p class="text-[10px] text-gray-400 -mt-1">Expected: guest iframe removed, "List all guests" count decreases</p><button data-testid="btn-register-close" id="btnRegisterClose" class="w-full rounded bg-orange-600 px-3 py-1.5 text-xs text-white hover:bg-orange-700">TC-LIFE-02: Register onGuestClose</button><p class="text-[10px] text-gray-400 -mt-1">Expected: log shows callback registered; fires when guest calls close()</p><button data-testid="btn-list-guests" id="btnListGuests" class="w-full rounded bg-gray-600 px-3 py-1.5 text-xs text-white hover:bg-gray-700">List all guests</button><p class="text-[10px] text-gray-400 -mt-1">Expected: Guest List panel shows all currently loaded guests</p><button data-testid="btn-set-loglevel" id="btnSetLogLevel" class="w-full rounded bg-gray-600 px-3 py-1.5 text-xs text-white hover:bg-gray-700">Set Log Level (Debug)</button> <button data-testid="btn-close-host" id="btnCloseHost" class="w-full rounded bg-red-700 px-3 py-1.5 text-xs text-white hover:bg-red-800">TC-LIFE-03: Close host</button><p class="text-[10px] text-gray-400 -mt-1">Expected: all guests unloaded, host destroyed, further actions fail</p></div></div><div class="bg-white rounded-lg shadow p-3"><h2 class="font-semibold text-gray-700 mb-2 border-b pb-1">Sandbox Configuration</h2><div class="space-y-2"><button data-testid="btn-sandbox-default" id="btnSandboxDefault" class="w-full rounded bg-teal-600 px-3 py-1.5 text-xs text-white hover:bg-teal-700">TC-SB-01: Default sandbox</button><p class="text-[10px] text-gray-400 -mt-1">Expected: iframe has standard sandbox attributes</p><button data-testid="btn-sandbox-custom" id="btnSandboxCustom" class="w-full rounded bg-teal-600 px-3 py-1.5 text-xs text-white hover:bg-teal-700">TC-SB-02: Custom sandbox values</button><p class="text-[10px] text-gray-400 -mt-1">Expected: iframe sandbox attribute reflects custom permissions</p><button data-testid="btn-sandbox-disabled" id="btnSandboxDisabled" class="w-full rounded bg-teal-600 px-3 py-1.5 text-xs text-white hover:bg-teal-700">TC-SB-03: Sandbox disabled</button><p class="text-[10px] text-gray-400 -mt-1">Expected: iframe has no sandbox attribute (full permissions)</p></div></div></div><div class="space-y-3"><div class="bg-white rounded-lg shadow p-3"><h2 class="font-semibold text-gray-700 mb-2 border-b pb-1">Embedded Guests</h2><div data-testid="embed-container" id="embedContainer" class="border-2 border-dashed border-indigo-300 rounded min-h-[300px] space-y-2"></div></div><div class="bg-white rounded-lg shadow p-3"><h2 class="font-semibold text-gray-700 mb-2 border-b pb-1">Sandbox Test Container</h2><div data-testid="sandbox-container" id="sandboxContainer" class="border-2 border-dashed border-teal-300 rounded min-h-[150px] space-y-2"></div></div></div><div class="space-y-3"><div class="bg-white rounded-lg shadow p-3"><h2 class="font-semibold text-gray-700 mb-2 border-b pb-1">Event Log</h2><div data-testid="event-log" id="eventLog" class="text-xs bg-gray-100 rounded p-2 min-h-[200px] max-h-[350px] overflow-y-auto font-mono"></div><button data-testid="btn-clear-log" id="btnClearLog" class="mt-1 text-xs text-gray-400 hover:text-gray-600">Clear</button></div><div class="bg-white rounded-lg shadow p-3"><h2 class="font-semibold text-gray-700 mb-2 border-b pb-1">callContext (last invocation)</h2><div data-testid="callcontext-panel"><h3 class="text-xs text-gray-500">callContext.guest</h3><pre data-testid="callcontext-guest" id="callContextGuest" class="text-xs bg-gray-100 rounded p-1 mb-1 whitespace-pre-wrap min-h-[30px]">
|
|
1
|
+
<!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><title>SSF E2E — Comprehensive Host Test</title><script src="https://cdn.tailwindcss.com?plugins=forms"></script><script src="https://cdn.mortgagetech.q1.ice.com/pui-diagnostics@3"></script><script defer="defer" src="js/emuiSsfHost.4b00d8e6203361c7da33.js"></script></head><body class="bg-gray-50 text-sm"><header class="bg-indigo-700 text-white px-4 py-3 flex items-center justify-between"><h1 class="text-lg font-semibold">Comprehensive E2E Host Test</h1><a href="./e2e-index.html" class="text-indigo-200 hover:text-white text-sm">← Test Suite</a></header><main class="mx-auto max-w-7xl px-4 py-3"><div class="grid grid-cols-2 gap-3 mb-3"><div class="bg-blue-50 border border-blue-200 rounded-md p-3"><h2 class="text-sm font-bold text-blue-900 mb-1">How to Use This Page</h2><ol class="text-xs text-blue-800 space-y-1 list-decimal list-inside"><li>Start the host dev server (port 4000) and guest dev server (port 4001).</li><li>Buttons in <strong>Column 1</strong> (left) execute host-side actions.</li><li><strong>Column 2</strong> (center) shows embedded guest iframes — interact with them to invoke methods, subscribe to events, etc.</li><li><strong>Column 3</strong> (right) shows live results: Event Log, callContext, dispatch results, and the guest list.</li><li>Work through the buttons <strong>top to bottom</strong> for the recommended flow. Each button is labelled with a test case ID (TC-xxx).</li></ol></div><div class="bg-amber-50 border border-amber-200 rounded-md p-3"><h2 class="text-sm font-bold text-amber-900 mb-1">Recommended Flow</h2><ol class="text-xs text-amber-800 space-y-1 list-decimal list-inside"><li><strong>Load guests</strong>: TC-LOAD-01 (embed) → TC-LOAD-02 (popup) → TC-LOAD-04 (with params). Check Event Log for "loaded" messages.</li><li><strong>Scripting objects</strong>: TC-SO-01 (add Inventory). In the guest iframe, call <code>getObject("Inventory")</code> and invoke <code>getStock()</code>. Check return value and callContext.</li><li><strong>Events</strong>: In the guest, subscribe to <code>Loan.onPreSave</code>. Then click TC-EVT-01 on the host. Guest should receive the event.</li><li><strong>Lifecycle</strong>: TC-LIFE-01 (unload), TC-LIFE-03 (close host). Verify guests are removed and host is destroyed.</li></ol></div></div><div class="grid grid-cols-3 gap-3"><div class="space-y-3"><div class="bg-white rounded-lg shadow p-3"><h2 class="font-semibold text-gray-700 mb-2 border-b pb-1">Guest Loading</h2><div class="space-y-2"><button data-testid="btn-load-embed" id="btnLoadEmbed" class="w-full rounded bg-indigo-600 px-3 py-1.5 text-xs text-white hover:bg-indigo-700">TC-LOAD-01: Load Embedded Guest</button><p class="text-[10px] text-gray-400 -mt-1">Expected: guest iframe appears in center column, log shows "loaded"</p><button data-testid="btn-load-popup" id="btnLoadPopup" class="w-full rounded bg-indigo-600 px-3 py-1.5 text-xs text-white hover:bg-indigo-700">TC-LOAD-02: Load Popup Guest</button><p class="text-[10px] text-gray-400 -mt-1">Expected: new browser popup window opens</p><button data-testid="btn-load-multiple" id="btnLoadMultiple" class="w-full rounded bg-indigo-600 px-3 py-1.5 text-xs text-white hover:bg-indigo-700">TC-LOAD-03: loadGuests (3 instances)</button><p class="text-[10px] text-gray-400 -mt-1">Expected: 3 guest iframes load, "List all guests" shows 3+ entries</p><button data-testid="btn-load-with-params" id="btnLoadWithParams" class="w-full rounded bg-indigo-600 px-3 py-1.5 text-xs text-white hover:bg-indigo-700">TC-LOAD-04: Load with searchParams</button><p class="text-[10px] text-gray-400 -mt-1">Expected: guest shows URL params in its "Params:" line</p><button data-testid="btn-load-with-metadata" id="btnLoadWithMetadata" class="w-full rounded bg-indigo-600 px-3 py-1.5 text-xs text-white hover:bg-indigo-700">TC-META-01: Load with metadata</button><p class="text-[10px] text-gray-400 -mt-1">Expected: when guest invokes a method, callContext.callChain shows metadata</p><button data-testid="btn-load-bad-url" id="btnLoadBadUrl" class="w-full rounded bg-red-600 px-3 py-1.5 text-xs text-white hover:bg-red-700">TC-LOAD-05: Load invalid URL (onError)</button><p class="text-[10px] text-gray-400 -mt-1">Expected: log shows "ERROR" or onError callback fires</p></div></div><div class="bg-white rounded-lg shadow p-3"><h2 class="font-semibold text-gray-700 mb-2 border-b pb-1">Scripting Object Management</h2><div class="space-y-2"><button data-testid="btn-add-so" id="btnAddSO" class="w-full rounded bg-green-600 px-3 py-1.5 text-xs text-white hover:bg-green-700">TC-SO-01: Add "Inventory" Object</button><p class="text-[10px] text-gray-400 -mt-1">Expected: guest can now <code>getObject("Inventory")</code> and invoke its methods</p><button data-testid="btn-add-guest-so" id="btnAddGuestSO" class="w-full rounded bg-green-600 px-3 py-1.5 text-xs text-white hover:bg-green-700">TC-SO-04: Add Guest-Scoped Object</button><p class="text-[10px] text-gray-400 -mt-1">Expected: only the target guest can access this object, others get "not available"</p><button data-testid="btn-remove-so" id="btnRemoveSO" class="w-full rounded bg-yellow-600 px-3 py-1.5 text-xs text-white hover:bg-yellow-700">TC-SO-02: Remove "Inventory" Object</button><p class="text-[10px] text-gray-400 -mt-1">Expected: guest's <code>getObject("Inventory")</code> now fails</p><button data-testid="btn-remove-all-so" id="btnRemoveAllSO" class="w-full rounded bg-yellow-600 px-3 py-1.5 text-xs text-white hover:bg-yellow-700">TC-SO-02b: Remove All Objects</button><p class="text-[10px] text-gray-400 -mt-1">Expected: all getObject calls fail until objects are re-added</p></div></div><div class="bg-white rounded-lg shadow p-3"><h2 class="font-semibold text-gray-700 mb-2 border-b pb-1">Event Dispatching</h2><div class="space-y-2"><button data-testid="btn-dispatch-all" id="btnDispatchAll" class="w-full rounded bg-purple-600 px-3 py-1.5 text-xs text-white hover:bg-purple-700">TC-EVT-01: Dispatch onPreSave to all</button><p class="text-[10px] text-gray-400 -mt-1">Expected: all guests subscribed to onPreSave receive the event</p><button data-testid="btn-dispatch-targeted" id="btnDispatchTargeted" class="w-full rounded bg-purple-600 px-3 py-1.5 text-xs text-white hover:bg-purple-700">TC-EVT-02: Dispatch to specific guest</button><p class="text-[10px] text-gray-400 -mt-1">Expected: only the targeted guest receives the event</p><button data-testid="btn-dispatch-feedback" id="btnDispatchFeedback" class="w-full rounded bg-purple-600 px-3 py-1.5 text-xs text-white hover:bg-purple-700">TC-EVT-03: Dispatch with timeout (feedback)</button><p class="text-[10px] text-gray-400 -mt-1">Expected: Dispatch Results shows the guest's feedback return value</p><button data-testid="btn-dispatch-amount" id="btnDispatchAmount" class="w-full rounded bg-purple-600 px-3 py-1.5 text-xs text-white hover:bg-purple-700">TC-EVT-04: Dispatch onAmountChanged (criteria)</button><p class="text-[10px] text-gray-400 -mt-1">Expected: only guests subscribed with matching criteria receive it</p></div></div><div class="bg-white rounded-lg shadow p-3"><h2 class="font-semibold text-gray-700 mb-2 border-b pb-1">Guest Lifecycle</h2><div class="space-y-2"><button data-testid="btn-unload-guest" id="btnUnloadGuest" class="w-full rounded bg-orange-600 px-3 py-1.5 text-xs text-white hover:bg-orange-700">TC-LIFE-01: Unload first embedded guest</button><p class="text-[10px] text-gray-400 -mt-1">Expected: guest iframe removed, "List all guests" count decreases</p><button data-testid="btn-register-close" id="btnRegisterClose" class="w-full rounded bg-orange-600 px-3 py-1.5 text-xs text-white hover:bg-orange-700">TC-LIFE-02: Register onGuestClose</button><p class="text-[10px] text-gray-400 -mt-1">Expected: log shows callback registered; fires when guest calls close()</p><button data-testid="btn-list-guests" id="btnListGuests" class="w-full rounded bg-gray-600 px-3 py-1.5 text-xs text-white hover:bg-gray-700">List all guests</button><p class="text-[10px] text-gray-400 -mt-1">Expected: Guest List panel shows all currently loaded guests</p><button data-testid="btn-set-loglevel" id="btnSetLogLevel" class="w-full rounded bg-gray-600 px-3 py-1.5 text-xs text-white hover:bg-gray-700">Set Log Level (Debug)</button> <button data-testid="btn-close-host" id="btnCloseHost" class="w-full rounded bg-red-700 px-3 py-1.5 text-xs text-white hover:bg-red-800">TC-LIFE-03: Close host</button><p class="text-[10px] text-gray-400 -mt-1">Expected: all guests unloaded, host destroyed, further actions fail</p></div></div><div class="bg-white rounded-lg shadow p-3"><h2 class="font-semibold text-gray-700 mb-2 border-b pb-1">Sandbox Configuration</h2><div class="space-y-2"><button data-testid="btn-sandbox-default" id="btnSandboxDefault" class="w-full rounded bg-teal-600 px-3 py-1.5 text-xs text-white hover:bg-teal-700">TC-SB-01: Default sandbox</button><p class="text-[10px] text-gray-400 -mt-1">Expected: iframe has standard sandbox attributes</p><button data-testid="btn-sandbox-custom" id="btnSandboxCustom" class="w-full rounded bg-teal-600 px-3 py-1.5 text-xs text-white hover:bg-teal-700">TC-SB-02: Custom sandbox values</button><p class="text-[10px] text-gray-400 -mt-1">Expected: iframe sandbox attribute reflects custom permissions</p><button data-testid="btn-sandbox-disabled" id="btnSandboxDisabled" class="w-full rounded bg-teal-600 px-3 py-1.5 text-xs text-white hover:bg-teal-700">TC-SB-03: Sandbox disabled</button><p class="text-[10px] text-gray-400 -mt-1">Expected: iframe has no sandbox attribute (full permissions)</p></div></div></div><div class="space-y-3"><div class="bg-white rounded-lg shadow p-3"><h2 class="font-semibold text-gray-700 mb-2 border-b pb-1">Embedded Guests</h2><div data-testid="embed-container" id="embedContainer" class="border-2 border-dashed border-indigo-300 rounded min-h-[300px] space-y-2"></div></div><div class="bg-white rounded-lg shadow p-3"><h2 class="font-semibold text-gray-700 mb-2 border-b pb-1">Sandbox Test Container</h2><div data-testid="sandbox-container" id="sandboxContainer" class="border-2 border-dashed border-teal-300 rounded min-h-[150px] space-y-2"></div></div></div><div class="space-y-3"><div class="bg-white rounded-lg shadow p-3"><h2 class="font-semibold text-gray-700 mb-2 border-b pb-1">Event Log</h2><div data-testid="event-log" id="eventLog" class="text-xs bg-gray-100 rounded p-2 min-h-[200px] max-h-[350px] overflow-y-auto font-mono"></div><button data-testid="btn-clear-log" id="btnClearLog" class="mt-1 text-xs text-gray-400 hover:text-gray-600">Clear</button></div><div class="bg-white rounded-lg shadow p-3"><h2 class="font-semibold text-gray-700 mb-2 border-b pb-1">callContext (last invocation)</h2><div data-testid="callcontext-panel"><h3 class="text-xs text-gray-500">callContext.guest</h3><pre data-testid="callcontext-guest" id="callContextGuest" class="text-xs bg-gray-100 rounded p-1 mb-1 whitespace-pre-wrap min-h-[30px]">
|
|
2
2
|
—</pre><h3 class="text-xs text-gray-500">callContext.callChain</h3><pre data-testid="callcontext-chain" id="callContextChain" class="text-xs bg-gray-100 rounded p-1 mb-1 whitespace-pre-wrap min-h-[30px]">
|
|
3
3
|
—</pre></div></div><div class="bg-white rounded-lg shadow p-3"><h2 class="font-semibold text-gray-700 mb-2 border-b pb-1">Dispatch Results</h2><pre data-testid="dispatch-result" id="dispatchResult" class="text-xs bg-gray-100 rounded p-2 min-h-[60px] whitespace-pre-wrap">
|
|
4
4
|
—</pre></div><div class="bg-white rounded-lg shadow p-3"><h2 class="font-semibold text-gray-700 mb-2 border-b pb-1">Guest List</h2><pre data-testid="guest-list" id="guestList" class="text-xs bg-gray-100 rounded p-2 min-h-[60px] whitespace-pre-wrap">
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><title>SSF E2E Test Suite</title><script src="https://cdn.tailwindcss.com?plugins=forms"></script><script defer="defer" src="js/emuiSsfHost.
|
|
1
|
+
<!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><title>SSF E2E Test Suite</title><script src="https://cdn.tailwindcss.com?plugins=forms"></script><script defer="defer" src="js/emuiSsfHost.4b00d8e6203361c7da33.js"></script></head><body class="bg-gray-50"><header class="bg-gray-900 text-white px-6 py-4"><h1 class="text-xl font-bold">SSF End-to-End Test Suite</h1><p class="text-sm text-gray-400 mt-1">Comprehensive blackbox tests for SSF Host & Guest. Each page includes test steps, expected values, and a verification checklist.</p></header><main class="mx-auto max-w-5xl px-6 py-6"><section class="mb-6 bg-yellow-50 border border-yellow-200 rounded-lg p-4"><h2 class="text-sm font-semibold text-yellow-800 mb-2">Setup Instructions</h2><ol class="text-xs text-yellow-700 list-decimal ml-4 space-y-1"><li>Install dependencies: <code class="bg-yellow-100 px-1 rounded">pnpm install</code></li><li>Start SSF Host dev server: <code class="bg-yellow-100 px-1 rounded">pnpm nx run ssf-host:start-server</code> (port 4000)</li><li>Start SSF Guest dev server: <code class="bg-yellow-100 px-1 rounded">pnpm nx run ssf-guest:start</code> (port 4001)</li><li>Open <code class="bg-yellow-100 px-1 rounded">http://localhost:4000/e2e-index.html</code> in the browser</li><li>Each test page has <code class="bg-yellow-100 px-1 rounded">data-testid</code> attributes for Playwright/Cypress selectors</li></ol></section><section class="mb-6"><h2 class="text-lg font-semibold text-gray-800 border-b pb-1 mb-3">1. Core Host-Guest Communication</h2><div class="grid grid-cols-1 md:grid-cols-2 gap-3"><a href="./e2e-host.html" data-testid="link-e2e-host" class="block bg-white rounded-lg shadow p-4 hover:shadow-md transition"><h3 class="font-medium text-indigo-700">Comprehensive E2E Host</h3><p class="text-xs text-gray-500 mt-1">All host-guest scenarios: guest loading, scripting objects, events, lifecycle, metadata, sandbox, guest-scoped objects.</p><p class="text-xs text-gray-400 mt-2"><strong>What to verify:</strong> Guests load in iframes/popups. Scripting objects can be added/removed/invoked. Events reach subscribed guests. Unload/close cleans up properly. Sandbox attrs applied.</p><div class="mt-2 text-xs text-gray-400"><strong>Test Cases:</strong> TC-LOAD-01..05 • TC-SO-01..08 • TC-EVT-01..04 • TC-LIFE-01..03 • TC-META-01 • TC-SB-01..03</div></a><a href="./index.html" data-testid="link-main-demo" class="block bg-white rounded-lg shadow p-4 hover:shadow-md transition"><h3 class="font-medium text-indigo-700">Main Demo App</h3><p class="text-xs text-gray-500 mt-1">Original Loan Application demo with embedded and popup guests, events, scripting objects.</p><p class="text-xs text-gray-400 mt-2"><strong>What to verify:</strong> Loan form data flows to guests. Events (onLoanAmountChanged, etc.) update guest UIs. Popup guests open and interact with the Loan object.</p></a></div></section><section class="mb-6"><h2 class="text-lg font-semibold text-gray-800 border-b pb-1 mb-3">2. Call Chain & Metadata Propagation</h2><div class="grid grid-cols-1 md:grid-cols-2 gap-3"><a href="./callchain-host.html" data-testid="link-callchain" class="block bg-white rounded-lg shadow p-4 hover:shadow-md transition"><h3 class="font-medium text-indigo-700">Nested CallChain Test (A → B → C)</h3><p class="text-xs text-gray-500 mt-1">Root Host (A) → Intermediate Guest+Host (B) → Grandchild Guest (C). Verifies callContext.callChain and metadata propagation.</p><p class="text-xs text-gray-400 mt-2"><strong>What to verify:</strong> Click buttons in Grandchild C. Host A should show <code>callContext.guest</code> = B and <code>callChain</code> containing C and B with their metadata. Return values should flow back to C.</p><div class="mt-2 text-xs text-gray-400"><strong>Test Cases:</strong> TC-CC-01..07</div></a></div></section><section class="mb-6"><h2 class="text-lg font-semibold text-gray-800 border-b pb-1 mb-3">3. Popup Guest Behavior</h2><div class="grid grid-cols-1 md:grid-cols-2 gap-3"><a href="./popup-focus-host.html" data-testid="link-popup-focus" class="block bg-white rounded-lg shadow p-4 hover:shadow-md transition"><h3 class="font-medium text-indigo-700">Popup Focus & Lifecycle</h3><p class="text-xs text-gray-500 mt-1">Open, close, and refocus popup guests. Tests trusted vs untrusted domain behavior.</p><p class="text-xs text-gray-400 mt-2"><strong>What to verify:</strong> Trusted popups (localhost): re-open brings existing popup to front. Untrusted popups: opener is nulled, focus falls back to WindowProxy. Closed popup detection updates guest status.</p><div class="mt-2 text-xs text-gray-400"><strong>Test Cases:</strong> TC-POP-01..11</div></a></div></section><section class="mb-6"><h2 class="text-lg font-semibold text-gray-800 border-b pb-1 mb-3">4. V1 / V2 Interoperability</h2><div class="grid grid-cols-1 md:grid-cols-2 gap-3"><a href="./v2-host-v1-guest.html" data-testid="link-v2-host-v1-guest" class="block bg-white rounded-lg shadow p-4 hover:shadow-md transition"><h3 class="font-medium text-indigo-700">V2 Host → V1 Guest</h3><p class="text-xs text-gray-500 mt-1">V2 host loads V1 guest. Loan object, save flow, event feedback.</p><p class="text-xs text-gray-400 mt-2"><strong>What to verify:</strong> V1 guest connects, gets objects, subscribes to events, and returns feedback correctly.</p><div class="mt-2 text-xs text-gray-400"><strong>Test Cases:</strong> TC-INTEROP-01..04</div></a><a href="./v2-host-v1-guest.html?nestV1GuestV2Host=true" data-testid="link-v2-v1-v2-chain" class="block bg-white rounded-lg shadow p-4 hover:shadow-md transition"><h3 class="font-medium text-indigo-700">V2 Host → V1 Guest → V2 Host → V2 Guest</h3><p class="text-xs text-gray-500 mt-1">Full mixed-version chain. V1 guest acts as intermediate host for a V2 grandchild.</p><p class="text-xs text-gray-400 mt-2"><strong>What to verify:</strong> Scripting objects are cloned across V1/V2 boundary. Events flow through all layers.</p><div class="mt-2 text-xs text-gray-400"><strong>Test Cases:</strong> TC-INTEROP-05..07</div></a></div><div class="grid grid-cols-1 md:grid-cols-2 gap-3 mt-3"><a href="./v1-host.html" data-testid="link-v1-host" class="block bg-white rounded-lg shadow p-4 hover:shadow-md transition"><h3 class="font-medium text-indigo-700">V1 Host → V1 Guest → V2 Host → V2 Guest</h3><p class="text-xs text-gray-500 mt-1">Starting from V1 host. Exercises the full V1-to-V2 upgrade path.</p><p class="text-xs text-gray-400 mt-2"><strong>What to verify:</strong> V1 host initializes. V1 guest connects. V2 host/guest chain works through V1 intermediate.</p></a></div></section></main></body></html>
|