Difficult in debugging Google Drive App - javascript

I am build programs by Google Script, and can use its debugger well.
Now, I am building my 1st Google Drive App. The normal operation flow is:
User select files in Google Drive and then call my App => Selected files are passed to my App as State Parameter => doGet() to create/open Client's HTML => User select options in that HTML and submit => Server receive the submitted form and do somethings.
However, debugging Drive App for me is difficult than normal Web Apps and Container-bounded Apps, due to its "State Parameter". I need to publish the Drive App first, and then debug Client's HTML & JScript by Javascript console and Server's GScript by Google Script Editor separately. Is it normal for Web programming? Or have I missed anything? Can I simulate the "State Parameter" for testing, so that I don't need to debug AFTER publish (even using test link) ?
N.B. Since above flow is clear enough, I haven't post demo code here.

You can run an Apps Script in development mode. You can make infinite number of changes to your Apps Script, run it in development mode, and test it without deploying the App. You will see "dev" on end of the URL:
https://script.google.com/macros/s/Aew678900-wdfgyj/dev
When you open up the Publish Your Web App Window, click the:
Test web app for your latest code.
To run it in development mode.

Related

automatically access default browser by os and copy the value from input field to my program

i've created electron app that will asking for authorization to my google drive account. my application is very simple, it will display the list of files from my google drive account. Here's the link
To get the authorization key, manually i have to click authorize button from my electron app, then it will open new tab in my default browser. i need to give the permission to accessing my google drive data. Then google drive will provide the authorization key to me then i can get and enter the key to my app.
How do I run the above scenario automatically?
You really don't want this to be the default flow for your users' code so I am assuming you are asking for test automation so you can test this works. You would basically:
Install the chromedriver package.
You would create a script that downloads and launches chromedriver then use something like webdriver.io to launch a Chrome session.
In the session, you would configure the user data directory to the user's real directory. You can find the locations in different operating systems here.
You now have a fully automated Chrome with the user's data.
Now, you use electron to request permissions, which will open a tab on the browser with an active selenium session.
Call browser.click('...') on whatever element you want in the page to accept the request.
I want to make it very clear this is only acceptable and will work when testing. "In the wild" controlling the user's browser without explicit permission through a third-party executable is a sure-fire way to get flagged by every anti-malware product in the market and liable for data breaches.

Testing Chrome Extension APIs Locally

This is a pretty general question with a couple examples. I'm fairly new to writing chrome extensions and I seem to keep running into cases that are impossible to test without deploying to the webstore (which takes ~60m each time). This is an impossible workflow. Am I missing something?
Case 1 inline installation
Trying to set up inline installation from my site to a chrome extension. When I run the site locally i get the following.
Error downloading extension: Inline installs can only be initiated for Chrome Web Store items that have one or more verified sites.
But I cannot seem to add localhost website property in chrome's developer dashboard. What is the recommended way to do this in a dev environment. I tried using local.mywebsite.com and adding a local alias for localhost, but now chrome cannot find the verification file you are required to serve...
Case 2 Chrome Extension OAuth
Attempting to use chrome.identity.launchWebAuthFlow to setup user credentials in my extension for my website, but of course the callback url provided https://<ext-id>.chromium.org/provider-cb does not redirect to my local deploy of the extension.
Is there no way to test these things??
Regarding your error "Inline installs can only be initiated for Chrome Web Store items that have one or more verified sites.", you may follow the instructions given in this page.
You need to:
Go to the Webmaster Tools.
Add the site to your sites.
Obtain and embed a verification code into your site.
Complete verification in Webmaster Tools.
Go to your Developer Dashboard (must be under the same Google account) and edit your Web Store item.
Select your site in "Verify that this is an official item for a website you own:"
Here are some references which might help in testing extensions:
Testing browser extensions
How to test chrome extensions?

Validity of data stored in a HTML element in a Cordova app

Say the cordova app has a div element "text" built-in.
<div id="text"></div>
Now during app execution, if value was written to the div using js
document.getElementById('text').innerHTML = "123456";
How long will the data survive?
Until app close? Until device boot?
And how safe is the data stored? Can any other app access this data?
On deploying your code from cordova to android device, following observations are made -
Data Longevity - The data will survive only till the app is exited (by clearing from background apps or running apps). If we switch to it from recent apps the data will be same.
OnReboot - Once you reboot the device the data '123456' is lost. You have to run the script again to restore the data.
Security - Other apps can't access the data from java script unless you allow any external scripts run in the app. (ex- while using iframes for external contents).
Read more about Security in Cordova Security Guide .

Can I embed a chrome extension app as part of my main AngularJS app?

I have been doing a lot of reading and studying to figure out.
I basically just want my main AngularJS application to run, but also include an embedded Chrome Extension app - in this case, have regularly scheduled alarms (using the chrome.alarm API).
I want all users of my AngularJS app to have automatic access to the Chrome extension app, embedded in the main clientside one with lots of other Angular features.
It seems like I have to manually enable my Chrome app in Developer mode on my browser and even drag my Chrome app specifically to a location in my Chrome browser. I don't understand how end users can just automatically use my Chrome app then.
I need to add here I have never really used jQuery, only AngularJS but AngularJS extensively. My AngularJS app is the frontend, the backend is provided by Rails.
Some advice would be really helpful. I hope I am not downvoted as it is strange how sometimes questions get downvoted and I am not sure why...I don't really know where else to go with this question.
EDIT:
Ok some code to demonstrate:
myangularapp.controller('myappcontroller', function($scope, $http) {
var delayvar = 5;
chrome.alarms.create("arandomalarm", {delay: delayvar});
};
This doesn't just work as part of my AngularJS, I tried creating a manifest.json file in the app/assets folder too. As well as a background.js file there and my-chrome-app.js file. "chrome.alarms" is undefined, but I haven't enabled Developer mode yet. But still, how are end users supposed to use it if just to make me use it I need to do so much specific browser configuration?
You should have a look at Content Scripts and then at Message Passing which explains you how to communicate between a web page and an Chrome extension.
its not possible to automatically install a chrome extension. the user must install it from the chrome store.
you may make it easier for them to install it by providing an inline installation from your webpage. its in the official documentation and you can see an example on this page with the "add to chrome" button:
http://plusfortrello.com (one of my chrome extensions which has inline installation inside that page).
that example button is further customized to display a message instead if the user is not on chrome desktop.
if your extension also has permission to your webpage then you can also detect from your webpage if the extension is already install it (to hide the button, send messages to it and such).

How to run a script from the Web in a Windows 8 app?

My organization already developed iOS and Android apps, and is starting to develop an app for Windows 8. In case it matters, the app is using Phonegap a.k.a. Cordova.
On the existing apps, the user downloads a very "slim" app from the store, containing a minimal HTML page. The user logs into a server, and then script tags are dynamically added pointing to locations on that server. Similar to web apps, scripts are downloaded to the client and then executed.
Windows 8's new security model blocks this behavior. Since the app runs in the local context and the script is on the web, I get the error "An app can’t load remote web content in the local context."
Is there a way to get around this restriction?
I'm open to "creative" suggestions and hacks, up to a point. I've already tried a few things, such as fetching a script with plain XHR calls and then injecting the response to a pre-defined script tag. Windows blocked this and all other attempts.
I also considered rendering everything in an iframe with a "ms-appx-web:" scheme (learned about this scheme here, "Schemas and contexts" section). This might allow me to load remote scripts, but would prevent code from accessing APIs of the locally-running JavaScript code -- Cordova and Windows Runtime. This access is necessary for my app. If there's a way to access Cordova and Windows Runtime from the web context, that might be useful too.
I very much doubt it.
The whole point of the MS Windows Store certification model is that they can test your code for malware/ crashes. If you can change the code on the fly, you could ship a perfectly harmless app, have it certified by MS, and then change it to something dreadful after the user installs it.

Categories

Resources