From 70800020bb6731136f1df1fd42f7de1607cd2767 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Sat, 28 May 2011 13:18:44 +0200 Subject: Use new tab.attach() internal page-mod method of creating new upstream bug. Fixes #100 --- data/internalMods/createBugElsewhere.js | 6 ++++++ lib/libbugzilla.js | 22 ++++++++++++++-------- 2 files changed, 20 insertions(+), 8 deletions(-) create mode 100644 data/internalMods/createBugElsewhere.js diff --git a/data/internalMods/createBugElsewhere.js b/data/internalMods/createBugElsewhere.js new file mode 100644 index 0000000..a20257f --- /dev/null +++ b/data/internalMods/createBugElsewhere.js @@ -0,0 +1,6 @@ +function fillTheForm(data) { + var elems = document.forms.namedItem('Create').elements; + elems.namedItem('short_desc').value = data.subject; + elems.namedItem('comment').value = data.comment; + self.postMessage("done!"); +}; diff --git a/lib/libbugzilla.js b/lib/libbugzilla.js index c2ee51d..b49e776 100644 --- a/lib/libbugzilla.js +++ b/lib/libbugzilla.js @@ -274,17 +274,23 @@ var openURLInNewTab = exports.openURLInNewTab = function openURLInNewTab(url) { }); }; -exports.createUpstreamBug = function createUpstreamBug(urlStr, subject, comment) { +exports.createUpstreamBug = function createUpstreamBug(urlStr, subjectStr, commentStr) { + var payload = JSON.stringify({ + subject: subjectStr, + comment: commentStr + }); tabs.open({ url: urlStr, inBackground: true, - onReady: function (t) { - var otherElems = t.contentDocument.forms.namedItem("Create").elements; - // Summary - otherElems.namedItem("short_desc").value = subject; - // Comment - otherElems.namedItem("comment").value = collectComments(); - t.activate(); + onReady: function (tab) { + tab.attach({ + contentScriptFile: selfMod.data.url("internalMods/createBugElsewhere.js"), + contentScript: "fillTheForm(" + payload + ");", + onMessage: function(str) { + tab.activate(); + } + }); + } }); }; -- cgit