Bug 357832 - Error invoking service from old plugin
diff --git a/bundles/org.eclipse.orion.client.core/web/orion/pluginregistry.js b/bundles/org.eclipse.orion.client.core/web/orion/pluginregistry.js
index 60c0b01..d4ec1e3 100644
--- a/bundles/org.eclipse.orion.client.core/web/orion/pluginregistry.js
+++ b/bundles/org.eclipse.orion.client.core/web/orion/pluginregistry.js
@@ -222,7 +222,10 @@
 	window.addEventListener("message", function(event) {
 		for (var i = 0, source = event.source; i < _channels.length; i++) {
 			if (source === _channels[i].target) {
-				_channels[i].handler(typeof event.data !== "string" ? event.data : JSON.parse(event.data));
+				if (typeof _channels[i].useStructuredClone === "undefined") {
+					_channels[i].useStructuredClone = typeof event.data !== "string";
+				}
+				_channels[i].handler(_channels[i].useStructuredClone ? event.data : JSON.parse(event.data));
 				break;
 			}
 		}
@@ -364,7 +367,7 @@
 				_pluginEventTarget.dispatchEvent("pluginUpdated", plugin);
 			},
 			postMessage: function(message, channel) {
-				channel.target.postMessage((window.ArrayBuffer ? message : JSON.stringify(message)), channel.url);
+				channel.target.postMessage((channel.useStructuredClone ? message : JSON.stringify(message)), channel.url);
 			}
 	};