Weinre style inspection not working with AngularJS - angularjs

I'm trying to use Weinre to debug an AngularJS application, but the style inspection isn't working. I can use Weinre to select elements on the page, but it never shows the associated style information coming from CSS selectors. I've narrowed it down to simply including AngularJS (I'm using version 1.2.5) on the page breaks Weinre style inspection. I've found a few references online to Weinre not working with AngularJS (https://issues.apache.org/jira/browse/CB-2651) but the JIRAs say that it's resolved. Any ideas?

Include the following function, and run it early on your page:
function whackWebkitMatchesSelector() {
var oldMatches = Element.prototype.webkitMatchesSelector
function newMatches(selector) {
try {
return oldMatches.call(this, selector)
}
catch (err) {
return false
}
}
Element.prototype.webkitMatchesSelector = newMatches
}
whackWebkitMatchesSelector()
As suggested in https://issues.apache.org/jira/browse/CB-6161
I can now inspect most (probably not all) styles.

They "fixed" it by catching the exception and continuing on. Apparently the issue is caused by (what webkit thinks) are invalid CSS selectors.

I know this issue is old but I've come across the same one when debugging under Internet Explorer 11. I've updated the previous whackWebkitMatchesSelector to include the IE case:
function whackWebkitMatchesSelector() {
var oldMatches;
if (Element.prototype.msMatchesSelector) {
oldMatches = Element.prototype.msMatchesSelector;
Element.prototype.msMatchesSelector = function(selector) {
try { return oldMatches.call(this, selector); }
catch (err) { return false; }
};
} else if (Element.prototype.webkitMatchesSelector) {
oldMatches = Element.prototype.webkitMatchesSelector;
Element.prototype.webkitMatchesSelector = function(selector) {
try { return oldMatches.call(this, selector); }
catch (err) { return false; }
};
}
}
whackWebkitMatchesSelector();

Related

Duplicate 'ScreenView' in Firebase DebugView

Basically, my 'ScreenView' tracks are being duplicated when I use IOS.
Looking for the same problem, I saw that Firabase advised not to use 'setCurrentScreen', but here we use 'logEvent' for the track.
static screenView = async (info: FirebaseActualScreen) => {
try {
await FirebaseAnalytics.logEvent(LogTypes.SCREEN_VIEW, {
page_name: info?.name ?? '',
});
} catch (e) {
crashlytics().recordError(new Error(`Error to get actual screen - ${e}`));
}
};
Firebase DebugView
I have tried using the 'setCurrentScreen', even though it is not advisable, but the problem persists.

Property `deleteVisual` doesn't exist on type Page

I have a powerbi report embedded using Angular. I want to delete Visuals of the report. Here is the code I implemented for deleteVisual function.
deleteVisual() {
// Get report
const report = await this.reportObj.getReport();
if (!report){
console.log(“Report Not available”);
return;
}
// Get all the pages of the report
const pages = await report.getPages();
// Check if all the pages of the report deleted
if (pages.length === 0) {
console.log(“No pages found”);
return;
}
// Get active page of the report
const activePage = pages.find((page) => page.isActive);
if (activePage)
// Get all visuals in the active page of the report
const visuals = await activePage.getVisuals();
if (visuals.length === 0) {
console.log('No visuals found.');
return;
}
// Get first visible visual
const visual = visuals.find((v) => v.layout.displayState?.mode ===
models.VisualContainerDisplayMode.Visible);
if (!visual) {
console.log('No visible visual available to delete.');
return;
}
try {
// Delete the visual using powerbi-report-authoring
const response = await activePage.deleteVisual(visual.name);
console.log(`${visual.type} , visual was deleted.`);
return response;
} catch (error) {
console.error(error);
}
}
I am getting error saying Property deleteVisual doesn't exist on type Page. Also why getVisuals, getReport , even deletePage working fine but getting error while using this deleteVisual. I want to attach the ss of error but i dont have enough reputation to post images.Can anyone help me to solve this problem.
To use deleteVisual please install powerbi-report-authoring library.
Using npm you can install by this command
npm i powerbi-report-authoring
References:
https://learn.microsoft.com/javascript/api/overview/powerbi/remove-visual
https://www.npmjs.com/package/powerbi-report-authoring

Reactjs Integration Testing Cognito Native Crypto Module Could Not Be Used To Get Secure Random Number

I have an integration test that uses the AWS Cognito library; specifically, I'm calling CognitoUser.authenticateUser(). When I start my webpage this all works fine: however, in my tests I'm getting the following error:
Error: Native crypto module could not be used to get secure random number.
at cryptoSecureRandomInt (/source/project/master/website/node_modules/amazon-cognito-identity-js/lib/utils/cryptoSecureRandomInt.web.js:38:9)
at WordArray.random (/source/project/master/website/node_modules/amazon-cognito-identity-js/lib/utils/WordArray.js:50:56)
at randomBytes (/source/project/master/website/node_modules/amazon-cognito-identity-js/lib/AuthenticationHelper.js:47:58)
at AuthenticationHelper.generateRandomSmallA (/source/project/master/website/node_modules/amazon-cognito-identity-js/lib/AuthenticationHelper.js:113:21)
at new AuthenticationHelper (/source/project/master/website/node_modules/amazon-cognito-identity-js/lib/AuthenticationHelper.js:67:29)
at CognitoUser.authenticateUserDefaultAuth (/source/project/master/website/node_modules/amazon-cognito-identity-js/lib/CognitoUser.js:264:32)
at CognitoUser.authenticateUser (/source/project/master/website/node_modules/amazon-cognito-identity-js/lib/CognitoUser.js:237:19)
Researching for answers I came across many posts suggesting:
Object.defineProperty(global.self, 'crypto', {
value: {
getRandomValues: arr => crypto.randomBytes(arr.length),
}
});
Unfortunatley that does not work.
Looking at the crypto source:
function cryptoSecureRandomInt() {
if (crypto) {
// Use getRandomValues method (Browser)
if (typeof crypto.getRandomValues === 'function') {
try {
return crypto.getRandomValues(new Uint32Array(1))[0];
} catch (err) {}
} // Use randomBytes method (NodeJS)
if (typeof crypto.randomBytes === 'function') {
try {
return crypto.randomBytes(4).readInt32LE();
} catch (err) {}
}
}
throw new Error('Native crypto module could not be used to get secure random number.');
}
I can see where this error is being thrown. I'm guessing that under normal circumstances the crypto package is loaded by the browser which obviously doesn't exist when testing.
Any suggestions?
Update 1
Stepped through using the debugger and in the crypto source it's getting undefined for the 'crypto' variable on this line
if (crypto) {
This means that the Object.defineProperty is not working. I tried attaching it to the window but that doesn't work either
Object.defineProperty(window, 'crypto', {
value: {
getRandomValues: (arr) => crypto.randomBytes(arr.length)
}
});

Mongoose adding select prevent returning to client

Got the following code:
On AngularJS client:
var getDocs = function() {
return $http.get('/api/docs/list')
.then(function(result) {
return result.data; // bookmark1 line
});
}
On Node.Js BE:
function getDocs() {
return Doc.find({}).exec()
.then(function success(docs) {
return res.send(docs);
});
}
Works perfectly.
When I change the first line in getDocs() to
return Doc.find({}).select('-field1 -field2').exec()
I see the docs after the query execution without the fields (as expected) but for some reason The http is pending and chrome debugger is not stopping on the success callback of the client (bookmark1 line).
Edit:
Changed to
return Cv.find({}).select('-field1 -field2').exec(function success(err, cvs) {
return res.send(cvs);
});
Got the following error in client:
Solution:
Well It turn out I had another field which depends on field1
docSchema.virtual('field3').get(function () {
return this.field1.toString("base64");
});
It fails and for some reason it didnt appear on my IDE.
I Added a null check and that solve the problem.
Not sure if I should remove this question or maybe it has value for other people. Feel free to say what you think.

Sencha + Windows phone 8 : Launch function is not invoked

I have built a sencha application using Sencha cmd.
I have integrated it to windows phone using cordova.
Now, when launching the app, after splash screen, a white screen comes and stays for ever.
I trying putting an alert in the launch function (in app.js where view is created) and found out that the launch function does not fire.
What could be the reason of this behaviour?
I found the cause of the issue that I was facing. The sencha app is using a store with SQL proxy. But since SQL proxy is not supported on Windows phone (but supported on other platforms viz. iOS, Android), so the launch function was not getting called.
I had a similar problem with a JSON proxy and I had to modify the following lines of code in cordovalib/XHRHelper.cs file.
var funk = function () {
window.__onXHRLocalCallback = function (responseCode, responseText) {
alias.status = responseCode;
if (responseCode == '200') {
alias.responseText = responseText;
try {
JSON.parse(responseText);
} catch (e) {
Object.defineProperty(alias, 'responseXML', {
get: function () {
return new DOMParser().parseFromString(this.responseText, 'text/xml');
}
});
}
Object.defineProperty(alias, 'responseJSON', {
get: function () {
return new DOMParser().parseFromString(this.responseText, 'text/json');
}
});
}else {
alias.onerror && alias.onerror(responseCode);
}

Resources