Bug 1030719 - Properly restore form data for contenteditables r=smacleod

This commit is contained in:
Tim Taubert 2014-06-26 15:55:16 +02:00
Родитель c053698239
Коммит 4c60fb3eae
2 изменённых файлов: 31 добавлений и 8 удалений

Просмотреть файл

@ -204,9 +204,22 @@ add_task(function test_design_mode() {
// Modify the document content.
yield sendMessage(browser, "ss-test:sendKeyEvent", {key: "m"});
// Duplicate the modified tab.
let tab2 = gBrowser.duplicateTab(tab);
yield promiseTabRestored(tab2);
// Close and restore the tab.
gBrowser.removeTab(tab);
tab = ss.undoCloseTab(window, 0);
browser = tab.linkedBrowser;
yield promiseTabRestored(tab);
// Check that the innerHTML value was restored.
let html = yield getInnerHTML(browser);
let expected = "<h1>Mmozilla</h1><script>document.designMode='on'</script>";
is(html, expected, "editable document has been restored correctly");
// Close and restore the tab.
gBrowser.removeTab(tab);
tab = ss.undoCloseTab(window, 0);
browser = tab.linkedBrowser;
yield promiseTabRestored(tab);
// Check that the innerHTML value was restored.
let html = yield getInnerHTML(browser);
@ -214,7 +227,6 @@ add_task(function test_design_mode() {
is(html, expected, "editable document has been restored correctly");
// Cleanup.
gBrowser.removeTab(tab2);
gBrowser.removeTab(tab);
});

Просмотреть файл

@ -226,6 +226,7 @@ let FormDataInternal = {
setTimeout(() => {
if (doc.body && doc.designMode == "on" && doc.documentURI == savedURL) {
doc.body.innerHTML = data.innerHTML;
this.fireEvent(doc.body, "input");
}
});
}
@ -311,13 +312,23 @@ let FormDataInternal = {
// Fire events for this node if applicable
if (eventType) {
let doc = aNode.ownerDocument;
let event = doc.createEvent("UIEvents");
event.initUIEvent(eventType, true, true, doc.defaultView, 0);
aNode.dispatchEvent(event);
this.fireEvent(aNode, eventType);
}
},
/**
* Dispatches an event of type |type| to the given |node|.
*
* @param node (DOMNode)
* @param type (string)
*/
fireEvent: function (node, type) {
let doc = node.ownerDocument;
let event = doc.createEvent("UIEvents");
event.initUIEvent(type, true, true, doc.defaultView, 0);
node.dispatchEvent(event);
},
/**
* Restores form data for the current frame hierarchy starting at |root|
* using the given form |data|.