summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoic Dachary <loic@dachary.org>2011-10-19 17:36:05 +0200
committerLoic Dachary <loic@dachary.org>2011-10-19 17:36:05 +0200
commit8bdae74b1e1549aa8ddb1b1c6cbc5de894ee83eb (patch)
treec117f4ccb40b4f31554b96f2c11c50e057ae0233
parent00e2742998bb1fd9645f75eeffd5b62f4088efc2 (diff)
Fixes https://bugassistant.libreoffice.org/show_bug.cgi?id=41832
Each bugzilla url is prefixed with $.bug.url which defaults to the empty string. That ensures that bug.html keeps working on a virtualhost configured as instructed in http://wiki.documentfoundation.org/Bug_Submission_Assistant#System_Administration. Add the frame() function that sets the $.bug.url string with the content of the bugzilla_url variable found in the parent window javascript context, if any. The document enclosing the iframe is loaded from the origin server (the one used to check for same origin policy) and it therefore knows which URL is set as a proxypass to bugzilla. The Bug Submission Assistant itself cannot know this because it may be included in a number of different contexts.
-rw-r--r--bug/bug/bug.js19
-rw-r--r--bug/bug/test.js15
2 files changed, 30 insertions, 4 deletions
diff --git a/bug/bug/bug.js b/bug/bug/bug.js
index fd70b79..30c9b7f 100644
--- a/bug/bug/bug.js
+++ b/bug/bug/bug.js
@@ -18,6 +18,8 @@
$.bug = {
+ window: window,
+
ajax: function(type, url, args) {
return $.ajax({
type: type,
@@ -75,6 +77,8 @@
$('.error-container').show();
},
+ url: '',
+
state_signin_error_regexps: ['class="throw_error">([^<]*)'],
state_signin_success_regexp: 'Log&nbsp;out</a>([^<]*)',
@@ -83,7 +87,7 @@
$('.go', element).click(function() {
$("body").css("cursor", "progress");
$.bug.error_clear();
- $.bug.ajax('POST', '/index.cgi', {
+ $.bug.ajax('POST', $.bug.url + '/index.cgi', {
Bugzilla_login: $('.user', element).val(),
Bugzilla_password: $('.password', element).val()
}).pipe(function(data) {
@@ -248,7 +252,7 @@
$('.submission').hide();
var element = $('.state_success');
var bug = $('.state_submit .bug').text();
- $('.bug', element).attr('href', '/show_bug.cgi?id=' + bug);
+ $('.bug', element).attr('href', $.bug.url + '/show_bug.cgi?id=' + bug);
element.show();
},
@@ -258,7 +262,7 @@
logged_in: function() {
$("body").css("cursor", "progress");
- return $.bug.ajax('GET', '/enter_bug.cgi').pipe(function(data) {
+ return $.bug.ajax('GET', $.bug.url + '/enter_bug.cgi').pipe(function(data) {
$("body").css("cursor", "default");
return data.indexOf($.bug.logged_in_false) < 0;
});
@@ -268,7 +272,7 @@
$('.related_bugs').empty();
var component = $('.state_component .chosen').attr('data').replace('_','%20');
var subcomponent = $('.state_subcomponent .active_subcomponent .chosen').attr('data');
- var list = '/buglist.cgi?columnlist=short_desc&component=' + component + '&product=LibreOffice&query_format=advanced&short_desc_type=allwordssubstr&ctype=csv&short_desc=' + subcomponent;
+ var list = $.bug.url + '/buglist.cgi?columnlist=short_desc&component=' + component + '&product=LibreOffice&query_format=advanced&short_desc_type=allwordssubstr&ctype=csv&short_desc=' + subcomponent;
$.bug.ajax('GET', list).pipe(function(data) {
var lines = data.split('\n');
var bug_urls = [];
@@ -283,8 +287,15 @@
$('.left .step:last-child').addClass('last-child'); // cross browser compatibility
},
+ frame: function() {
+ if($.bug.window != $.bug.window.top && $.bug.window.parent.bugzilla_url !== undefined) {
+ $.bug.url = $.bug.window.parent.bugzilla_url;
+ }
+ },
+
main: function() {
$.bug.compatibility();
+ $.bug.frame();
$.bug.logged_in().done(function(status) {
if(status) {
$.bug.state_component();
diff --git a/bug/bug/test.js b/bug/bug/test.js
index cb87f93..576fc7d 100644
--- a/bug/bug/test.js
+++ b/bug/bug/test.js
@@ -16,6 +16,21 @@
//
module("bug");
+test("frame", function() {
+ expect(2);
+
+ bugzilla_url = 'BUGZILLA_URL';
+
+ $.bug.window = {
+ top: 'something',
+ parent: { bugzilla_url: bugzilla_url }
+ };
+
+ equal($.bug.url, '');
+ $.bug.frame();
+ equal($.bug.url, bugzilla_url);
+});
+
test("ajax", function() {
expect(4);