Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #16341 from KevinGrandon/bug_971268_search_browser…
Browse files Browse the repository at this point in the history
…_bookmarking

Bug 971268 - Enable bookmark icon for results launched from search app r=ran, amirn
  • Loading branch information
KevinGrandon committed Feb 18, 2014
2 parents a419c6c + 0614962 commit ac06cfb
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 6 deletions.
10 changes: 8 additions & 2 deletions apps/search/js/providers/webresults.js
Expand Up @@ -20,7 +20,11 @@
click: function(e) {
var url = e.target && e.target.dataset.url;
if (url) {
Search.navigate(url);
Search.navigate(url, {
icon: e.target.dataset.icon,
originUrl: url,
originName: e.target.dataset.title
});
}
},

Expand All @@ -42,7 +46,9 @@
title: app.name,
icon: app.icon,
dataset: {
url: app.appUrl
title: app.name,
url: app.appUrl,
icon: app.icon
}
};
});
Expand Down
21 changes: 19 additions & 2 deletions apps/search/js/search.js
Expand Up @@ -146,9 +146,26 @@

/**
* Opens a browser to a URL
* @param {String} url The url to navigate to
* @param {Object} config Optional configuration.
*/
navigate: function(url) {
window.open(url, '_blank', 'remote=true,useAsyncPanZoom=true');
navigate: function(url, config) {
var features = {
remote: true,
useAsyncPanZoom: true
};

config = config || {};
for (var i in config) {
features[i] = config[i];
}

var featureStr = Object.keys(features)
.map(function(key) {
return encodeURIComponent(key) + '=' +
encodeURIComponent(features[key]);
}).join(',');
window.open(url, '_blank', featureStr);
},

/**
Expand Down
9 changes: 7 additions & 2 deletions apps/search/test/unit/providers/webresults_test.js
Expand Up @@ -40,11 +40,16 @@ suite('search/providers/webresults', function() {
subject.click({
target: {
dataset: {
url: 'http://mozilla.org'
url: 'http://mozilla.org',
icon: 'http://mozilla.org/img'
}
}
});
assert.ok(stub.calledWith('http://mozilla.org'));
assert.ok(stub.calledWith('http://mozilla.org', {
icon: 'http://mozilla.org/img',
originName: undefined,
originUrl: 'http://mozilla.org'
}));
});
});

Expand Down
11 changes: 11 additions & 0 deletions apps/search/test/unit/search_test.js
Expand Up @@ -199,6 +199,17 @@ suite('search/search', function() {
Search.navigate(url);
assert.ok(stub.calledWith(url));
});

test('parses features', function() {
var url = 'http://mozilla.org';
var stub = this.sinon.stub(window, 'open');
Search.navigate(url, {
a: 1,
b: 2
});
assert.ok(stub.calledWith(url, '_blank',
'remote=true,useAsyncPanZoom=true,a=1,b=2'));
});
});

suite('expandSearch', function() {
Expand Down

0 comments on commit ac06cfb

Please sign in to comment.