Bug 917322 part.23 Store nsITextInputProcessor instance into WeakMap instead of window r=smaug
--- a/testing/mochitest/tests/SimpleTest/EventUtils.js
+++ b/testing/mochitest/tests/SimpleTest/EventUtils.js
@@ -869,30 +869,37 @@ const COMPOSITION_ATTR_RAW_CLAUSE =
_EU_Ci.nsITextInputProcessor.ATTR_RAW_CLAUSE;
const COMPOSITION_ATTR_SELECTED_RAW_CLAUSE =
_EU_Ci.nsITextInputProcessor.ATTR_SELECTED_RAW_CLAUSE;
const COMPOSITION_ATTR_CONVERTED_CLAUSE =
_EU_Ci.nsITextInputProcessor.ATTR_CONVERTED_CLAUSE;
const COMPOSITION_ATTR_SELECTED_CLAUSE =
_EU_Ci.nsITextInputProcessor.ATTR_SELECTED_CLAUSE;
+var TIPMap = new WeakMap();
+
function _getTIP(aWindow, aCallback)
{
if (!aWindow) {
aWindow = window;
}
- if (!aWindow._EU_TIP) {
- aWindow._EU_TIP =
+ var tip;
+ if (TIPMap.has(aWindow)) {
+ tip = TIPMap.get(aWindow);
+ } else {
+ tip =
_EU_Cc["@mozilla.org/text-input-processor;1"].
createInstance(_EU_Ci.nsITextInputProcessor);
+ TIPMap.set(aWindow, tip);
}
- if (!aWindow._EU_TIP.initForTests(aWindow, aCallback)) {
- aWindow._EU_TIP = null;
+ if (!tip.initForTests(aWindow, aCallback)) {
+ tip = null;
+ TIPMap.delete(aWindow);
}
- return aWindow._EU_TIP;
+ return tip;
}
/**
* Synthesize a composition event.
*
* @param aEvent The composition event information. This must
* have |type| member. The value must be
* "compositionstart", "compositionend",