I have an extension that allows users to change the home page and new tab page. I do so by changing the values of some preferences (e.g. browser.startup.homepage, browser.newtab.url).
I want to reset the values of these preferences to previous values(not default) when the user uninstalls the extension.
How to reset the preference to its previous value?
Thanks.
const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
const ps = Cc['#mozilla.org/preferences-service;1'].getService(Ci.nsIPrefBranch);
ps.clearUserPref('full.path.to.pref.here');
Note: This reset pref to default value, if no default value is set the pref is deleted.
Related
Project - mobile automation,
tools - appium, pagefactory
I have an field which returns Account balance for logged in user. My test checks for new balance after successful transaction.
to assert amount calcualtion I am storing balanceBeforeTransaction and balanceAfterTransaction
#AndroidFindBy(xpath="//*[contains(#text,\'balance\')]")
public WebElement balance;
balanceBeforeTransaction = balance.getText();
transaction()
balanceAfterTransaction = balance.getText();
My transaction is succesfull and I can see new balance in mobile app but my code is returning same (old) value for both the fields i.e balanceBeforeTransaction and balanceAfterTransaction. Not sure why it is not picking latest value.
Note: I havent used #CahceLookup, If pagefactory uses it by default then how can I disable it
I'd like to write an electron app, which is based on a number of windows.
Using this app, I'd like to be able to log in into a web-app using different roles in different windows.
Therefore, I need a feature to store cookies in different windows of the app at different locations. HTML, JS code and cookies data of window A should not see that of windows B.
Alternatively, I could image to somehow trap set-cookie requests and keep them in memory, thus not using app global cookie storage on HD.
Could someone provide code for this feature?
I'm aware of this post, which explains how to app.setPath() of userData. Unfortunately userData is app-global, not e.g. window local.
If I would be now able to trap each cookie-set operation of each BrowserWindow, I would be able to use app.setPath() and switch the cookie storage based on the window, the trap was fired.
I did find a solution:
First create a partition. Let name it SomeNameForMySession :
const partition = 'persist:SomeNameForMySession'
Then pass the partition to a BrowserWindow like so at creation time:
var ctrlWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
partition: partition
}
})
If another BrowserWindow gets another partition with another name, the windows have fully separated cookies.
If another BrowserWindow gets the same partition, the windows share cookie storage.
Using this, you may for example trace, what cookie events happen in session of the named partition:
// First find the correct session based on the partitions name
const ses2 = session.fromPartition( partition2 )
// Then, add a listener
ses2.cookies.addListener( 'changed', function ( event, cookie, cause, removed ) {
console.log('COOKIE: ' + cookie.name + ' :: ' + cookie.value )
})
I have a problem with Neo4j database. When I add new Data to database and update the value of it (default : 0.0), it will recorded in database and then when I refresh the page, the data will not changed.
But, when I relaunch the program (Stop - Star or Restart) the program, the value of new Data will back to its original value (0.0). I already try to tracing all event that related to change the value, but none of the breakpoint is executed to change the value.
Is there any bug that can revert the value to its default value? Because the value of my new Data, same like the default value after I added it to database (Before update).
This is my simple code to create new data
LineItem newLineItem = new LineItem(engine, previousLineItem.getNo() + 1, previousLineItem.getSection(), "ACTIVITY ENGINE", previousLineItem.getActivityCode(), "ENGINE", 0.0,
"",checked, "");
lineItems.add(newLineItem);
lineItemService.save(lineItems);
And this is how I updated my data
LineItem lineItem = lineItemService.findById(id);
if(lineItem != null){
if(name != null)lineItem.setName(name);
if(duration != null)lineItem.setDuration(roundUpToNearestQuarter(duration));
lineItemService.save(lineItem);
return lineItemList;
}
return new ArrayList<LineItem>();
The problem is, When I just refresh the page, and never Relaunch it, the duration data is same like the newest data, but after I relaunch the program, the duration data will revert back to default value (0.0)
There is no code that revert back my data to its original, because I already search global and give breakpoint on each code that have possibility to changed the value.
This bug related to my other bug, Argument mistype. Link : Spring Data Neo4j - Argument Type Mismatch
It will revert all my values to default because when I relaunch the program, it will get the default data that I set before.
Just need to check the attribute data and data saved on database, is it correct data or wrong type data.
I had an app that worked fine with sdk 2.0rc3 namely updating a preference value with more strings. Recently this stopped working and when I investigated it turned out that if pref does not exist PrefManager.update method creates one with requested value correctly. But if I want to update already existing one then it fails to apply any sort of update.
Does anyone know if this is caused by the latest Rally changes on the platform?
Or maybe an idea what might be wrong?
_saveNewPrefs : function (prefValue){
var sortedPrefs = prefValue;//_.sortby(prefValue,'keyword');
var appPrefValueEncoded = Ext.JSON.encode(sortedPrefs);
// resave entire pref again with new build
var newPref = {};
newPref[this.appPrefName] = appPrefValueEncoded;
console.log ('workspace', this.appWorkspace);
console.log('newPref', newPref);
Rally.data.PreferenceManager.update({
settings: newPref,
workspace: this.appWorkspace,
success: function(updatedRecords, notUpdatedRecords) {
console.log ('Pair saved', updatedRecords);
console.log('this',this);
this._displayGrid();
},
scope : this
});
},
Error thrown is this
"Validation error: Preference.Name conflicts with buildList55 where buildList55 is the pre-existing pref name
Finally fixed it - so the issues was twofold - I needed to add the appID AND I needed to recreate the pref as the old one was someone locked for any updates since was updated without passing appID to the Pref Manager.
I have written an Outlook plugin that basically allows emails being received through Outlook to be linked with a website so that the email can also be view in the communications feature of the website. I store additional details within the ItemProperties of a MailItem, these details are basically things like the id of the user the email relates to within a website.
The problem I'm having is any ItemProperties I add to a MailItem are being printed when the email is printed. Does anyone know how to exclude custom ItemProperties when printing an email?
Here is the code that is creating the custom ItemProperty:
// Try and access the required property.
Microsoft.Office.Interop.Outlook.ItemProperty property = mailItem.ItemProperties[name];
// Required property doesnt exist so we'll create it on the fly.
if (property == null) property = mailItem.ItemProperties.Add(name, Microsoft.Office.Interop.Outlook.OlUserPropertyType.olText);
// Set the value.
property.Value = value;
I'm working on Outlook extension and sometimes ago we had the same issue.
One of our team members found a solution. You can create some method which is responsible for disable printing. You can see peace of our code below:
public void DisablePrint()
{
long printablePropertyFlag = 0x4; // PDO_PRINT_SAVEAS
string printablePropertyCode = "[DispID=107]";
Type customPropertyType = _customProperty.GetType();
// Get current flags.
object rawFlags = customPropertyType.InvokeMember(printablePropertyCode , BindingFlags.GetProperty, null, _customProperty, null);
long flags = long.Parse(rawFlags.ToString());
// Remove printable flag.
flags &= ~printablePropertyFlag;
object[] newParameters = new object[] { flags };
// Set current flags.
customPropertyType.InvokeMember(printablePropertyCode, BindingFlags.SetProperty, null, _customProperty, newParameters);
}
Make sure that _customProperty it is your property which you created by the following code: mailItem.ItemProperties.Add(name,Microsoft.Office.Interop.Outlook.OlUserPropertyType.olText);
On the low (Extended MAPI) level, each user property definition has a flag that determines whether it is printable (namely, PDO_PRINT_SAVEAS). That flag however is not exposed through the Outlook Object Model.
You can either parse the user properties blob and manually set that flag (user properties blob format is documented, and you can see it in OutlookSpy (I am its author) if you click the IMessage button) or you can use Redemption (I am also its author) and its RDOUserProperty.Printable property.
The following script (VB) will reset the printable property for all user propeties of the currently selected message:
set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set Msg = Session.GetMessageFromID(Application.ActiveExplorer.Selection(1).EntryID)
for each prop in Msg.UserProperties
Debug.Print prop.Name
prop.Printable = false
next
Msg.Save