private WebkitRemoteObject getIndexAt(WebkitRemoteObject listObject, int offset) throws IOException { final WebkitRemoteObject[] results = new WebkitRemoteObject[1]; final CountDownLatch latch = new CountDownLatch(1); getConnection() .getRuntime() .callFunctionOn( listObject.getObjectId(), "function(){return this[" + offset + "];}", null, false, new WebkitCallback<WebkitRemoteObject>() { @Override public void handleResult(WebkitResult<WebkitRemoteObject> result) { results[0] = result.getResult(); latch.countDown(); } }); try { latch.await(3, TimeUnit.SECONDS); } catch (InterruptedException e) { return null; } return results[0]; }
@Override public IVariable getVariable(int offset) throws DebugException { try { WebkitRemoteObject result = getIndexAt(value, offset); if (result == null) { result = WebkitRemoteObject.createNull(); } return new WebkitDebugVariable( getTarget(), WebkitPropertyDescriptor.createIndexProperty(offset, result)); } catch (IOException e) { throw createDebugException(e); } }