[Pkg-mozext-commits] [autofill-forms] 03/10: possible fix for the recent crash reports

David Prévot taffit at moszumanska.debian.org
Fri May 27 19:28:28 UTC 2016


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository autofill-forms.

commit 63f12110d209eb58b7642348a68982abf4944ec5
Author: Sarah Avilov <sarah.avilov at gmail.com>
Date:   Wed May 25 01:39:27 2016 +0430

    possible fix for the recent crash reports
---
 aff.xpi                         | Bin 153786 -> 153876 bytes
 chrome/content/autofillForms.js |  85 +++++++++++++++++++++++-----------------
 install.rdf                     |   2 +-
 3 files changed, 50 insertions(+), 37 deletions(-)

diff --git a/aff.xpi b/aff.xpi
index 8d23539..dab0381 100644
Binary files a/aff.xpi and b/aff.xpi differ
diff --git a/chrome/content/autofillForms.js b/chrome/content/autofillForms.js
index 1854ac5..86e791f 100644
--- a/chrome/content/autofillForms.js
+++ b/chrome/content/autofillForms.js
@@ -100,53 +100,66 @@ var autofillForms = {
   version: "1.0.4",
 
   action: function (elem, cmd, val) {
-    console.error(cmd);
     elem.setAttribute('data-aff-' + cmd, val);
-
-    var doc = elem.ownerDocument;
-
-    function oldMethod () {
-      console.error('old Method');
-      var wm = Components.classes['@mozilla.org/appshell/window-mediator;1']
+    let doc = elem.ownerDocument;
+    try {
+      let contentWindow = doc.defaultView || doc.parentWindow;
+      let sandbox = Components.utils.Sandbox(contentWindow, {
+        sandboxPrototype: contentWindow,
+        wantXrays: true
+      });
+      Components.utils.evalInSandbox(`
+        function onChange (element) {
+          element.dispatchEvent(new Event('change'));
+          element.dispatchEvent(new Event('keydown'));
+          element.dispatchEvent(new Event('keyup'));
+          element.dispatchEvent(new Event('keychange'));
+        }
+        var list = Array.from(document.querySelectorAll("[${'data-aff-' + cmd}]"));
+        list.forEach( function(element, index) {
+          if ('${cmd}' === 'click') {
+            element.click();
+          }
+          if ('${cmd}' === 'submit') {
+            element.submit();
+          }
+          if ('${cmd}' === 'focus') {
+            console.error('ffff');
+            element.focus();
+            onChange(element);
+          }
+          if ('${cmd}' === 'change') {
+            onChange(element);
+          }
+          if ('${cmd}' === 'value') {
+            element.value = element.dataset.affValue;
+            onChange(element);
+          }
+          if ('${cmd}' === 'selectionEnd') {
+            element.selectionEnd = element.dataset.affSelectionend;
+          }
+          if ('${cmd}' === 'selectionStart') {
+            element.selectionStart = element.dataset.affSelectionstart;
+          }
+        });
+        list.forEach( function(element, index) {
+          element.removeAttribute('${'data-aff-' + cmd}');
+        });
+      `, sandbox);
+    } catch (e) {
+      let wm = Components.classes['@mozilla.org/appshell/window-mediator;1']
         .getService(Components.interfaces.nsIWindowMediator);
-      var browser = wm.getMostRecentWindow('navigator:browser').gBrowser.selectedBrowser;
-      var mm = browser.messageManager;
+      let browser = wm.getMostRecentWindow('navigator:browser').gBrowser.selectedBrowser;
+      let mm = browser.messageManager;
       if (!browser.slScript) {
         mm.loadFrameScript('chrome://autofillforms/content/inject.js', true);
         browser.slScript = true;
       }
       mm.sendAsyncMessage(cmd);
     }
-
-    if ('Worker' in autofillForms.require && doc) {
-      var contentWindow = doc.defaultView || doc.parentWindow;
-      if (contentWindow) {
-        var tab = autofillForms.require.utils.getTabForContentWindow(contentWindow);
-        if (tab) {
-          var tabId = autofillForms.require.utils.getTabId(tab);
-          for each (let sdkTab in autofillForms.require.tabs) {
-            if (sdkTab && sdkTab.id === tabId) {
-              let worker = sdkTab.attach({
-                contentScriptFile: 'resource://autofillforms/sdk.js',
-              });
-              worker.port.on('done', function () {
-                worker.destroy();
-              });
-              worker.port.emit(cmd, val);
-              return;
-            }
-          }
-        }
-      }
-      oldMethod();
-    }
-    else {
-      oldMethod();
-    }
   },
 
   initialize: function () {
-
     // Save the reference to the Autofill Forms preferences branch:
     this.autofillFormsPrefs = this.getPrefManager().getBranch('extensions.autofillForms at blueimp.net.');
 
diff --git a/install.rdf b/install.rdf
index 10fe722..168c539 100644
--- a/install.rdf
+++ b/install.rdf
@@ -9,7 +9,7 @@
     <em:iconURL>chrome://autofillForms/skin/icon.png</em:iconURL>
     <em:optionsURL>chrome://autofillForms/content/autofillFormsOptions.xul</em:optionsURL>
     <em:homepageURL>http://firefox.add0n.com/autofill-forms.html</em:homepageURL>
-    <em:version>1.1.3b1</em:version>
+    <em:version>1.1.3b2</em:version>
     <em:type>2</em:type>
     <em:targetApplication>
       <Description>

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/autofill-forms.git



More information about the Pkg-mozext-commits mailing list