Merge m-c to inbound.

This commit is contained in:
Ryan VanderMeulen 2012-11-02 20:38:14 -04:00
commit 902212e8a0
12 changed files with 286 additions and 42 deletions

View File

@ -33,7 +33,6 @@ log("\n\n======================= identity.js =======================\n\n");
// This script may be injected more than once into an iframe.
// Ensure we don't redefine contstants
if (typeof kIdentityJSLoaded === 'undefined') {
const kReceivedIdentityAssertion = "received-id-assertion";
const kIdentityDelegateWatch = "identity-delegate-watch";
const kIdentityDelegateRequest = "identity-delegate-request";
const kIdentityDelegateLogout = "identity-delegate-logout";
@ -66,33 +65,10 @@ function identityCall(message) {
* destroys our context.
*/
function closeIdentityDialog() {
let randomId = uuidgen.generateUUID().toString();
let id = kReceivedIdentityAssertion + "-" + randomId;
let browser = Services.wm.getMostRecentWindow("navigator:browser");
let detail = {
type: kReceivedIdentityAssertion,
id: id,
showUI: showUI
};
// In order to avoid race conditions, we wait for the UI to notify that
// it has successfully closed the identity flow and has recovered the
// caller app, before notifying the parent process.
content.addEventListener("mozContentEvent", function closeIdentityDialogFinished(evt) {
content.removeEventListener("mozContentEvent", closeIdentityDialogFinished);
if (evt.detail.id == id && aCallback) {
aCallback();
}
});
// tell gecko we're done. fire and forget.
log('ready to close');
// tell gecko we're done.
func = null; options = null;
sendAsyncMessage(kIdentityDelegateFinished);
// tell gaia to shut us down
browser.shell.sendChromeEvent(detail);
}
/*

View File

@ -92,6 +92,7 @@ const kOpenIdentityDialog = "open-id-dialog";
const kCloseIdentityDialog = "close-id-dialog";
// Observer messages to communicate to shim
const kReceivedIdentityAssertion = "received-id-assertion";
const kIdentityDelegateWatch = "identity-delegate-watch";
const kIdentityDelegateRequest = "identity-delegate-request";
const kIdentityDelegateLogout = "identity-delegate-logout";
@ -218,9 +219,20 @@ let Pipe = {
// If we receive a "finished" event, then the delegate is done, so
// we shut down the pipe and clean up.
mm.addMessageListener(kIdentityControllerDoMethod, aMessageCallback);
mm.addMessageListener(kIdentityDelegateFinished, function identityDelegateFinished(message) {
mm.addMessageListener(kIdentityDelegateFinished, function identityDelegateFinished() {
// clean up listeners
mm.removeMessageListener(kIdentityDelegateFinished, identityDelegateFinished);
mm.removeMessageListener(kIdentityControllerDoMethod, aMessageCallback);
let id = kReceivedIdentityAssertion + "-" + getRandomId();
let detail = {
type: kReceivedIdentityAssertion,
showUI: aGaiaOptions.showUI || false,
id: id
};
log('tell gaia to close the dialog');
// tell gaia to close the dialog
GaiaInterface.sendChromeEvent(detail);
});
mm.sendAsyncMessage(aGaiaOptions.message, aRpOptions);

View File

@ -120,6 +120,7 @@ BrowserElementChild.prototype = {
addMessageListener('browser-element-api:' + msg, handler.bind(self));
}
addMsgListener("purge-history", this._recvPurgeHistory);
addMsgListener("get-screenshot", this._recvGetScreenshot);
addMsgListener("set-visible", this._recvSetVisible);
addMsgListener("send-mouse-event", this._recvSendMouseEvent);
@ -451,6 +452,20 @@ BrowserElementChild.prototype = {
sendAsyncMsg("scroll", { top: win.scrollY, left: win.scrollX });
},
_recvPurgeHistory: function(data) {
debug("Received purgeHistory message: (" + data.json.id + ")");
let history = docShell.QueryInterface(Ci.nsIWebNavigation).sessionHistory;
try {
if (history && history.count) {
history.PurgeHistory(history.count);
}
} catch(e) {}
sendAsyncMsg('got-purge-history', { id: data.json.id, successRv: true });
},
_recvGetScreenshot: function(data) {
debug("Received getScreenshot message: (" + data.json.id + ")");

View File

@ -215,6 +215,7 @@ function BrowserElementParent(frameLoader, hasRemoteFrame) {
addMessageListener("firstpaint", this._fireEventFromMsg);
addMessageListener("keyevent", this._fireKeyEvent);
addMessageListener("showmodalprompt", this._handleShowModalPrompt);
addMessageListener('got-purge-history', this._gotDOMRequestResult);
addMessageListener('got-screenshot', this._gotDOMRequestResult);
addMessageListener('got-can-go-back', this._gotDOMRequestResult);
addMessageListener('got-can-go-forward', this._gotDOMRequestResult);
@ -254,6 +255,7 @@ function BrowserElementParent(frameLoader, hasRemoteFrame) {
defineMethod('goForward', this._goForward);
defineMethod('reload', this._reload);
defineMethod('stop', this._stop);
defineMethod('purgeHistory', this._purgeHistory);
defineMethod('getScreenshot', this._getScreenshot);
defineDOMRequestMethod('getCanGoBack', 'get-can-go-back');
defineDOMRequestMethod('getCanGoForward', 'get-can-go-forward');
@ -576,6 +578,10 @@ BrowserElementParent.prototype = {
this._sendAsyncMsg('stop');
},
_purgeHistory: function() {
return this._sendDOMRequest('purge-history');
},
_getScreenshot: function(_width, _height) {
let width = parseInt(_width);
let height = parseInt(_height);

View File

@ -150,6 +150,8 @@ MOCHITEST_FILES = \
file_post_request.html \
test_browserElement_inproc_ReloadPostRequest.html \
browserElement_ReloadPostRequest.js \
browserElement_PurgeHistory.js \
test_browserElement_inproc_PurgeHistory.html \
$(NULL)
# Disabled due to https://bugzilla.mozilla.org/show_bug.cgi?id=774100
@ -216,6 +218,7 @@ MOCHITEST_FILES += \
test_browserElement_oop_ExposableURI.html \
test_browserElement_oop_FrameWrongURI.html \
test_browserElement_oop_ReloadPostRequest.html \
test_browserElement_oop_PurgeHistory.html \
$(NULL)
endif #}
endif #}

View File

@ -0,0 +1,87 @@
/* Any copyright is dedicated to the public domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// Bug 807056 - [Browser] Clear History doesn't clear back/forward history in open tabs
// <iframe mozbrowser>.
"use strict";
SimpleTest.waitForExplicitFinish();
var iframe;
function addOneShotIframeEventListener(event, fn) {
function wrapper(e) {
iframe.removeEventListener(event, wrapper);
fn(e);
};
iframe.addEventListener(event, wrapper);
}
function runTest() {
browserElementTestHelpers.setEnabledPref(true);
browserElementTestHelpers.addPermission();
iframe = document.createElement('iframe');
iframe.mozbrowser = true;
addOneShotIframeEventListener('mozbrowserloadend', function() {
SimpleTest.executeSoon(test2);
});
iframe.src = browserElementTestHelpers.emptyPage1;
document.body.appendChild(iframe);
}
function purgeHistory(nextTest) {
var seenCanGoBackResult = false;
var seenCanGoForwardResult = false;
iframe.purgeHistory().onsuccess = function(e) {
ok(true, "The history has been purged");
iframe.getCanGoBack().onsuccess = function(e) {
is(e.target.result, false, "Iframe cannot go back");
seenCanGoBackResult = true;
maybeRunNextTest();
};
iframe.getCanGoForward().onsuccess = function(e) {
is(e.target.result, false, "Iframe cannot go forward");
seenCanGoForwardResult = true;
maybeRunNextTest();
};
};
function maybeRunNextTest() {
if (seenCanGoBackResult && seenCanGoForwardResult) {
nextTest();
}
}
}
function test2() {
purgeHistory(test3);
}
function test3() {
addOneShotIframeEventListener('mozbrowserloadend', function() {
purgeHistory(test4);
});
SimpleTest.executeSoon(function() {
iframe.src = browserElementTestHelpers.emptyPage2;
});
}
function test4() {
addOneShotIframeEventListener('mozbrowserlocationchange', function(e) {
is(e.detail, browserElementTestHelpers.emptyPage3);
purgeHistory(SimpleTest.finish);
});
SimpleTest.executeSoon(function() {
iframe.src = browserElementTestHelpers.emptyPage3;
});
}
runTest();

View File

@ -0,0 +1,13 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test of browser element.</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="browserElementTestHelpers.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<script type="application/javascript;version=1.7" src="browserElement_PurgeHistory.js">
</script>
</body>
</html>

View File

@ -0,0 +1,13 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test of browser element.</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="browserElementTestHelpers.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<script type="application/javascript;version=1.7" src="browserElement_PurgeHistory.js">
</script>
</body>
</html>

View File

@ -77,6 +77,9 @@ enum {
CAMERA_PARAM_FOCUSDISTANCEOPTIMUM,
CAMERA_PARAM_FOCUSDISTANCEFAR,
CAMERA_PARAM_EXPOSURECOMPENSATION,
CAMERA_PARAM_THUMBNAILWIDTH,
CAMERA_PARAM_THUMBNAILHEIGHT,
CAMERA_PARAM_THUMBNAILQUALITY,
CAMERA_PARAM_SUPPORTED_PREVIEWSIZES,
CAMERA_PARAM_SUPPORTED_VIDEOSIZES,
@ -93,7 +96,8 @@ enum {
CAMERA_PARAM_SUPPORTED_MAXEXPOSURECOMPENSATION,
CAMERA_PARAM_SUPPORTED_EXPOSURECOMPENSATIONSTEP,
CAMERA_PARAM_SUPPORTED_ZOOM,
CAMERA_PARAM_SUPPORTED_ZOOMRATIOS
CAMERA_PARAM_SUPPORTED_ZOOMRATIOS,
CAMERA_PARAM_SUPPORTED_JPEG_THUMBNAIL_SIZES
};
#ifdef PR_LOGGING

View File

@ -29,6 +29,7 @@
#include "nsThread.h"
#include <media/MediaProfiles.h>
#include "mozilla/FileUtils.h"
#include "nsAlgorithm.h"
#include <media/mediaplayer.h>
#include "nsDirectoryServiceDefs.h" // for NS_GetSpecialDirectory
#include "nsPrintfCString.h"
@ -72,6 +73,13 @@ static const char* getKeyText(uint32_t aKey)
return CameraParameters::KEY_FOCUS_DISTANCES;
case CAMERA_PARAM_EXPOSURECOMPENSATION:
return CameraParameters::KEY_EXPOSURE_COMPENSATION;
case CAMERA_PARAM_THUMBNAILWIDTH:
return CameraParameters::KEY_JPEG_THUMBNAIL_WIDTH;
case CAMERA_PARAM_THUMBNAILHEIGHT:
return CameraParameters::KEY_JPEG_THUMBNAIL_HEIGHT;
case CAMERA_PARAM_THUMBNAILQUALITY:
return CameraParameters::KEY_JPEG_THUMBNAIL_QUALITY;
case CAMERA_PARAM_SUPPORTED_PREVIEWSIZES:
return CameraParameters::KEY_SUPPORTED_PREVIEW_SIZES;
case CAMERA_PARAM_SUPPORTED_VIDEOSIZES:
@ -104,6 +112,8 @@ static const char* getKeyText(uint32_t aKey)
return CameraParameters::KEY_ZOOM_SUPPORTED;
case CAMERA_PARAM_SUPPORTED_ZOOMRATIOS:
return CameraParameters::KEY_ZOOM_RATIOS;
case CAMERA_PARAM_SUPPORTED_JPEG_THUMBNAIL_SIZES:
return CameraParameters::KEY_SUPPORTED_JPEG_THUMBNAIL_SIZES;
default:
return nullptr;
}
@ -174,6 +184,8 @@ nsGonkCameraControl::nsGonkCameraControl(uint32_t aCameraId, nsIThread* aCameraT
, mDeferConfigUpdate(false)
, mWidth(0)
, mHeight(0)
, mLastPictureWidth(0)
, mLastPictureHeight(0)
, mFormat(PREVIEW_FORMAT_UNKNOWN)
, mFps(30)
, mDiscardedFrameCount(0)
@ -208,6 +220,7 @@ nsGonkCameraControl::Init()
const char* const BAD_PREVIEW_FORMAT = "yuv420sp";
mParams.setPreviewFormat(PREVIEW_FORMAT);
mParams.setPreviewFrameRate(mFps);
PushParametersImpl();
// Check that our settings stuck
PullParametersImpl();
@ -402,14 +415,50 @@ nsGonkCameraControl::GetParameter(uint32_t aKey, nsTArray<CameraRegion>& aRegion
r = aRegions.AppendElement();
if (sscanf(p, "(%d,%d,%d,%d,%u)", &r->top, &r->left, &r->bottom, &r->right, &r->weight) != 5) {
DOM_CAMERA_LOGE("%s:%d : region tuple has bad format: '%s'\n", __func__, __LINE__, p);
goto GetParameter_error;
aRegions.Clear();
return;
}
}
return;
}
GetParameter_error:
aRegions.Clear();
void
nsGonkCameraControl::GetParameter(uint32_t aKey, nsTArray<CameraSize>& aSizes)
{
const char* key = getKeyText(aKey);
if (!key) {
return;
}
RwAutoLockRead lock(mRwLock);
const char* value = mParams.get(key);
DOM_CAMERA_LOGI("key='%s' --> value='%s'\n", key, value);
if (!value) {
return;
}
const char* p = value;
CameraSize* s;
// The 'value' string is in the format "w1xh1,w2xh2,w3xh3,..."
while (p) {
s = aSizes.AppendElement();
if (sscanf(p, "%dx%d", &s->width, &s->height) != 2) {
DOM_CAMERA_LOGE("%s:%d : size tuple has bad format: '%s'\n", __func__, __LINE__, p);
aSizes.Clear();
return;
}
// Look for the next record...
p = strchr(p, ',');
if (p) {
// ...skip the comma too
++p;
}
}
return;
}
nsresult
@ -524,6 +573,20 @@ nsGonkCameraControl::SetParameter(uint32_t aKey, const nsTArray<CameraRegion>& a
PushParameters();
}
void
nsGonkCameraControl::SetParameter(uint32_t aKey, int aValue)
{
const char* key = getKeyText(aKey);
if (!key) {
return;
}
{
RwAutoLockWrite lock(mRwLock);
mParams.set(key, aValue);
}
PushParameters();
}
nsresult
nsGonkCameraControl::GetPreviewStreamImpl(GetPreviewStreamTask* aGetPreviewStream)
{
@ -615,6 +678,45 @@ nsGonkCameraControl::AutoFocusImpl(AutoFocusTask* aAutoFocus)
return NS_OK;
}
void
nsGonkCameraControl::SetupThumbnail(uint32_t aPictureWidth, uint32_t aPictureHeight, uint32_t aPercentQuality)
{
/**
* Use the smallest non-0x0 thumbnail size that matches
* the aspect ratio of our parameters...
*/
uint32_t smallestArea = UINT_MAX;
uint32_t smallestIndex = UINT_MAX;
nsAutoTArray<CameraSize, 8> thumbnailSizes;
GetParameter(CAMERA_PARAM_SUPPORTED_JPEG_THUMBNAIL_SIZES, thumbnailSizes);
for (uint32_t i = 0; i < thumbnailSizes.Length(); ++i) {
uint32_t area = thumbnailSizes[i].width * thumbnailSizes[i].height;
if (area != 0
&& area < smallestArea
&& thumbnailSizes[i].width * aPictureHeight / thumbnailSizes[i].height == aPictureWidth
) {
smallestArea = area;
smallestIndex = i;
}
}
aPercentQuality = clamped<uint32_t>(aPercentQuality, 1, 100);
SetParameter(CAMERA_PARAM_THUMBNAILQUALITY, static_cast<int>(aPercentQuality));
if (smallestIndex != UINT_MAX) {
uint32_t w = thumbnailSizes[smallestIndex].width;
uint32_t h = thumbnailSizes[smallestIndex].height;
DOM_CAMERA_LOGI("Using thumbnail size: %ux%u, quality: %u %%\n", w, h, aPercentQuality);
if (w > INT_MAX || h > INT_MAX) {
DOM_CAMERA_LOGE("Thumbnail dimension is too big, will use defaults\n");
return;
}
SetParameter(CAMERA_PARAM_THUMBNAILWIDTH, static_cast<int>(w));
SetParameter(CAMERA_PARAM_THUMBNAILHEIGHT, static_cast<int>(h));
}
}
nsresult
nsGonkCameraControl::TakePictureImpl(TakePictureTask* aTakePicture)
{
@ -641,16 +743,24 @@ nsGonkCameraControl::TakePictureImpl(TakePictureTask* aTakePicture)
// batch-update camera configuration
mDeferConfigUpdate = true;
/**
* height and width: some drivers are less friendly about getting one of
* these set to zero, so if either is not specified, ignore both and go
* with current or default settings.
*/
if (aTakePicture->mSize.width && aTakePicture->mSize.height) {
nsCString s;
s.AppendPrintf("%dx%d", aTakePicture->mSize.width, aTakePicture->mSize.height);
DOM_CAMERA_LOGI("setting picture size to '%s'\n", s.get());
SetParameter(CameraParameters::KEY_PICTURE_SIZE, s.get());
if (aTakePicture->mSize.width != mLastPictureWidth || aTakePicture->mSize.height != mLastPictureHeight) {
/**
* height and width: some drivers are less friendly about getting one of
* these set to zero, so if either is not specified, ignore both and go
* with current or default settings.
*/
if (aTakePicture->mSize.width && aTakePicture->mSize.height) {
nsCString s;
s.AppendPrintf("%ux%u", aTakePicture->mSize.width, aTakePicture->mSize.height);
DOM_CAMERA_LOGI("setting picture size to '%s'\n", s.get());
SetParameter(CameraParameters::KEY_PICTURE_SIZE, s.get());
// Choose an appropriate thumbnail size and quality (from 1..100)
SetupThumbnail(aTakePicture->mSize.width, aTakePicture->mSize.height, 60);
}
mLastPictureWidth = aTakePicture->mSize.width;
mLastPictureHeight = aTakePicture->mSize.height;
}
// Picture format -- need to keep it for the callback.

View File

@ -47,10 +47,12 @@ public:
const char* GetParameterConstChar(uint32_t aKey);
double GetParameterDouble(uint32_t aKey);
void GetParameter(uint32_t aKey, nsTArray<dom::CameraRegion>& aRegions);
void GetParameter(uint32_t aKey, nsTArray<CameraSize>& aSizes);
void SetParameter(const char* aKey, const char* aValue);
void SetParameter(uint32_t aKey, const char* aValue);
void SetParameter(uint32_t aKey, double aValue);
void SetParameter(uint32_t aKey, const nsTArray<dom::CameraRegion>& aRegions);
void SetParameter(uint32_t aKey, int aValue);
nsresult GetVideoSizes(nsTArray<CameraSize>& aVideoSizes);
nsresult PushParameters();
@ -79,6 +81,7 @@ protected:
already_AddRefed<GonkRecorderProfileManager> GetGonkRecorderProfileManager();
void SetPreviewSize(uint32_t aWidth, uint32_t aHeight);
void SetupThumbnail(uint32_t aPictureWidth, uint32_t aPictureHeight, uint32_t aPercentQuality);
uint32_t mHwHandle;
double mExposureCompensationMin;
@ -88,6 +91,8 @@ protected:
android::CameraParameters mParams;
uint32_t mWidth;
uint32_t mHeight;
uint32_t mLastPictureWidth;
uint32_t mLastPictureHeight;
enum {
PREVIEW_FORMAT_UNKNOWN,

View File

@ -16,7 +16,7 @@ qemu = true
#[test_outgoing_busy.js]
#expectedfailure = true
[test_outgoing_reject.js]
[test_voicemail_statuschanged.py]
# [test_voicemail_statuschanged.py] - Bug 806138
[test_voicemail_number.js]
[test_incoming_hold_resume.js]
# Bug 790463