|
@@ -1,158 +0,0 @@
|
|
|
-<html>
|
|
|
- <head>
|
|
|
- <title>Test running...</title>
|
|
|
- </head>
|
|
|
- <body>
|
|
|
- This is a test for checking repeated authentication dialog problem in draw.io. It will execute a request every 10 seconds.<br>
|
|
|
- <br>
|
|
|
- <div id="status" style="font-size:18pt;padding:20px;border:1px solid black;display:inline-block;">Loading page...</div>
|
|
|
- <br><br>
|
|
|
- <script type="text/javascript">
|
|
|
- function logEvent(data)
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
- var img = new Image();
|
|
|
- img.src = 'https://www.draw.io/images/1x1.png?' + 'q=auth-test&id=' + encodeURIComponent(id) + '&data=' + encodeURIComponent(JSON.stringify(data));
|
|
|
- }
|
|
|
- catch (e)
|
|
|
- {
|
|
|
- // ignore
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- var id = (function()
|
|
|
- {
|
|
|
- function s4()
|
|
|
- {
|
|
|
- return Math.floor((1 + Math.random()) * 0x10000)
|
|
|
- .toString(16)
|
|
|
- .substring(1);
|
|
|
- }
|
|
|
-
|
|
|
- return s4() + s4();
|
|
|
- })();
|
|
|
-
|
|
|
- function handleClientLoad() {
|
|
|
- document.getElementById('status').innerHTML = 'Loading client...';
|
|
|
- logEvent({event: 'init', useragent: navigator.userAgent});
|
|
|
-
|
|
|
- // Loads the client library and the auth2 library together for efficiency.
|
|
|
- // Loading the auth2 library is optional here since `gapi.client.init` function will load
|
|
|
- // it if not already loaded. Loading it upfront can save one network request.
|
|
|
- gapi.load('client:auth2', function()
|
|
|
- {
|
|
|
- gapi.client.load('drive', 'v2', function()
|
|
|
- {
|
|
|
- initClient();
|
|
|
- });
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- function initClient() {
|
|
|
- // Initialize the client with API key and People API, and initialize OAuth with an
|
|
|
- // OAuth 2.0 client ID and scopes (space delimited string) to request access.
|
|
|
- gapi.client.init({
|
|
|
- clientId: '671128082532.apps.googleusercontent.com',
|
|
|
- scope: 'profile'
|
|
|
- }).then(function () {
|
|
|
- // Listen for sign-in state changes.
|
|
|
- gapi.auth2.getAuthInstance().isSignedIn.listen(updateSigninStatus);
|
|
|
-
|
|
|
- // Handle the initial sign-in state.
|
|
|
- updateSigninStatus(gapi.auth2.getAuthInstance().isSignedIn.get());
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- function updateSigninStatus(isSignedIn) {
|
|
|
-
|
|
|
- logEvent({event: 'update', isSignedIn: isSignedIn});
|
|
|
- // When signin status changes, this function is called.
|
|
|
- // If the signin status is changed to signedIn, we make an API call.
|
|
|
- if (isSignedIn) {
|
|
|
- runTest();
|
|
|
- document.getElementById('status').style.display = 'inline-block';
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- document.getElementById('status').innerHTML = 'Please click below to sign-in!';
|
|
|
- document.getElementById('status').style.display = 'none';
|
|
|
- document.getElementById('signin-button').style.display = 'block';
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- function handleSignInClick(event) {
|
|
|
- // Ideally the button should only show up after gapi.client.init finishes, so that this
|
|
|
- // handler won't be called before OAuth is initialized.
|
|
|
- gapi.auth2.getAuthInstance().signIn();
|
|
|
- }
|
|
|
-
|
|
|
- function handleSignOutClick(event) {
|
|
|
- gapi.auth2.getAuthInstance().signOut();
|
|
|
- }
|
|
|
-
|
|
|
- var thread = null;
|
|
|
-
|
|
|
- var start = new Date().getTime();
|
|
|
- var counter = 0;
|
|
|
-
|
|
|
-
|
|
|
- function update()
|
|
|
- {
|
|
|
- if (thread != null)
|
|
|
- {
|
|
|
- var now = new Date().getTime();
|
|
|
- document.getElementById('status').innerHTML = 'RUNNING test: #' + counter + ' uptime: ' + Math.ceil((now - start) / 1000) + ' secs';
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- window.setInterval(update, 1000);
|
|
|
- update();
|
|
|
-
|
|
|
- function runTest() {
|
|
|
- if (thread != null)
|
|
|
- {
|
|
|
- window.clearInterval(thread);
|
|
|
- }
|
|
|
-
|
|
|
- start = new Date().getTime();
|
|
|
- counter = 0;
|
|
|
-
|
|
|
- logEvent({event: 'start'});
|
|
|
- document.getElementById('signin-button').style.display = 'none';
|
|
|
-
|
|
|
- function test()
|
|
|
- {
|
|
|
- var now = new Date().getTime();
|
|
|
- counter++;
|
|
|
- try
|
|
|
- {
|
|
|
- gapi.client.drive.about.get().execute(function(resp) {
|
|
|
- //console.log('resp', resp);
|
|
|
- // Permisison is logged to detect change of user
|
|
|
- logEvent({event: 'result', error: resp.error, user: resp.user,
|
|
|
- counter: counter, uptime: Math.ceil((now - start) / 1000)});
|
|
|
- });
|
|
|
- }
|
|
|
- catch (e)
|
|
|
- {
|
|
|
- //console.log('err',e);
|
|
|
- logEvent({event: 'error', error: e, counter: counter, uptime: Math.ceil((now - start) / 1000)});
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- thread = window.setInterval(test, 10000);
|
|
|
- test();
|
|
|
- }
|
|
|
- </script>
|
|
|
- <script async defer src="https://apis.google.com/js/api.js"
|
|
|
- onload="this.onload=function(){};handleClientLoad()"
|
|
|
- onreadystatechange="if (this.readyState === 'complete') this.onload()">
|
|
|
- </script>
|
|
|
- <button id="signin-button" onclick="handleSignInClick()" style="font-size:20pt;font-weight:bold;display:none;">Please click here to sign in!</button>
|
|
|
- Run this test for at least the time
|
|
|
- it normally takes for the dialog to appear twice, if you can leave it open for longer, that helps us.
|
|
|
- <br><br>
|
|
|
- <b>Please do not close this window or tab!</b>
|
|
|
- </body>
|
|
|
-</html>
|