diff --git a/src/client/sandbox/node/window.js b/src/client/sandbox/node/window.js index e84e1b4e7..d6a78986e 100644 --- a/src/client/sandbox/node/window.js +++ b/src/client/sandbox/node/window.js @@ -674,9 +674,12 @@ export default class WindowSandbox extends SandboxBase { }, setter: function (value) { if (this.type.toLowerCase() !== 'file') { + nativeMethods.inputValueSetter.call(this, value); - if (!isShadowUIElement(this) && isTextEditableElementAndEditingAllowed(this)) + const valueChanged = value !== nativeMethods.inputValueGetter.call(this); + + if (valueChanged && !isShadowUIElement(this) && isTextEditableElementAndEditingAllowed(this)) windowSandbox.elementEditingWatcher.restartWatchingElementEditing(this); } else diff --git a/test/client/fixtures/sandbox/event/focus-blur-change-test.js b/test/client/fixtures/sandbox/event/focus-blur-change-test.js index b484907ca..73ed1ec42 100644 --- a/test/client/fixtures/sandbox/event/focus-blur-change-test.js +++ b/test/client/fixtures/sandbox/event/focus-blur-change-test.js @@ -1,13 +1,14 @@ var SHADOW_UI_CLASSNAME = hammerhead.get('./../shadow-ui/class-name'); -var Promise = hammerhead.Promise; -var browserUtils = hammerhead.utils.browser; -var styleUtil = hammerhead.utils.style; -var activeWindowTracker = hammerhead.sandbox.event.focusBlur.activeWindowTracker; -var eventSimulator = hammerhead.sandbox.event.eventSimulator; -var focusBlur = hammerhead.sandbox.event.focusBlur; -var nativeMethods = hammerhead.nativeMethods; -var iframeSandbox = hammerhead.sandbox.iframe; +var Promise = hammerhead.Promise; +var browserUtils = hammerhead.utils.browser; +var styleUtil = hammerhead.utils.style; +var activeWindowTracker = hammerhead.sandbox.event.focusBlur.activeWindowTracker; +var eventSimulator = hammerhead.sandbox.event.eventSimulator; +var focusBlur = hammerhead.sandbox.event.focusBlur; +var nativeMethods = hammerhead.nativeMethods; +var elementEditingWatcher = hammerhead.sandbox.event.elementEditingWatcher; +var iframeSandbox = hammerhead.sandbox.iframe; var input1 = null; var input2 = null; @@ -550,6 +551,26 @@ asyncTest('blurring body with blur handler', function () { }); }); +test('should raise change event', function () { + var input = document.createElement('input'); + var changeRaised = false; + + input.className = TEST_ELEMENT_CLASS; + + input.onchange = function () { + changeRaised = true; + }; + + document.body.appendChild(input); + input.focus(); + nativeMethods.inputValueSetter.call(input, 'A'); + + input.value = 'A'; + + elementEditingWatcher.processElementChanging(input); + ok(changeRaised); +}); + module('native methods replacing'); asyncTest('focus() called by client script when browser window is on background', function () {