Skip to content

Commit a6f6cdb

Browse files
committed
Clone windowcapability before returning to user
1 parent 38a0ced commit a6f6cdb

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

lib/js/src/manager/SystemCapabilityManager.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,11 @@ class SystemCapabilityManager extends _SubManagerBase {
194194
currentWindowId = PredefinedWindows.DEFAULT_WINDOW;
195195
}
196196
if (currentWindowId === windowId) {
197-
windowCapability.setWindowID(windowId);
198-
return windowCapability;
197+
// Clone WindowCapability to prevent modification of stored WindowCapability in SystemCapabilityManager
198+
const windowCapabilityCopy = new WindowCapability(JSON.parse(JSON.stringify(windowCapability.getParameters())));
199+
// A null windowID is assumed to be the DefaultWindow according to the spec, but that can be hard for developers to check, so set it explicitly.
200+
windowCapabilityCopy.setWindowID(windowId);
201+
return windowCapabilityCopy;
199202
}
200203
}
201204
return null;

0 commit comments

Comments
 (0)