Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Side by Side Diff: mojo/public/js/new_bindings/validator.js

Issue 2891193002: Mojo JS bindings: switch all mojo/ layout tests to use the new mode. (Closed)
Patch Set: . Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 (function() { 5 (function() {
6 var internal = mojo.internal; 6 var internal = mojo.internal;
7 7
8 var validationError = { 8 var validationError = {
9 NONE: 'VALIDATION_ERROR_NONE', 9 NONE: 'VALIDATION_ERROR_NONE',
10 MISALIGNED_OBJECT: 'VALIDATION_ERROR_MISALIGNED_OBJECT', 10 MISALIGNED_OBJECT: 'VALIDATION_ERROR_MISALIGNED_OBJECT',
(...skipping 16 matching lines...) Expand all
27 INVALID_UNION_SIZE: 'VALIDATION_ERROR_INVALID_UNION_SIZE', 27 INVALID_UNION_SIZE: 'VALIDATION_ERROR_INVALID_UNION_SIZE',
28 UNEXPECTED_NULL_UNION: 'VALIDATION_ERROR_UNEXPECTED_NULL_UNION', 28 UNEXPECTED_NULL_UNION: 'VALIDATION_ERROR_UNEXPECTED_NULL_UNION',
29 UNKNOWN_ENUM_VALUE: 'VALIDATION_ERROR_UNKNOWN_ENUM_VALUE', 29 UNKNOWN_ENUM_VALUE: 'VALIDATION_ERROR_UNKNOWN_ENUM_VALUE',
30 }; 30 };
31 31
32 var NULL_MOJO_POINTER = "NULL_MOJO_POINTER"; 32 var NULL_MOJO_POINTER = "NULL_MOJO_POINTER";
33 var gValidationErrorObserver = null; 33 var gValidationErrorObserver = null;
34 34
35 function reportValidationError(error) { 35 function reportValidationError(error) {
36 if (gValidationErrorObserver) { 36 if (gValidationErrorObserver) {
37 gValidationErrorObserver.setLastError(error); 37 gValidationErrorObserver.lastError = error;
38 } else {
39 console.warn('Invalid message: ' + error);
38 } 40 }
39 } 41 }
40 42
41 var ValidationErrorObserverForTesting = (function() { 43 var ValidationErrorObserverForTesting = (function() {
42 function Observer() { 44 function Observer() {
43 this.lastError = validationError.NONE; 45 this.lastError = validationError.NONE;
44 this.callback = null;
45 } 46 }
46 47
47 Observer.prototype.setLastError = function(error) { 48 Observer.prototype.reset = function() {
48 this.lastError = error;
49 if (this.callback) {
50 this.callback(error);
51 }
52 };
53
54 Observer.prototype.reset = function(error) {
55 this.lastError = validationError.NONE; 49 this.lastError = validationError.NONE;
56 this.callback = null;
57 }; 50 };
58 51
59 return { 52 return {
60 getInstance: function() { 53 getInstance: function() {
61 if (!gValidationErrorObserver) { 54 if (!gValidationErrorObserver) {
62 gValidationErrorObserver = new Observer(); 55 gValidationErrorObserver = new Observer();
63 } 56 }
64 return gValidationErrorObserver; 57 return gValidationErrorObserver;
65 } 58 }
66 }; 59 };
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 }; 669 };
677 670
678 internal.validationError = validationError; 671 internal.validationError = validationError;
679 internal.Validator = Validator; 672 internal.Validator = Validator;
680 internal.ValidationErrorObserverForTesting = 673 internal.ValidationErrorObserverForTesting =
681 ValidationErrorObserverForTesting; 674 ValidationErrorObserverForTesting;
682 internal.reportValidationError = reportValidationError; 675 internal.reportValidationError = reportValidationError;
683 internal.isTestingMode = isTestingMode; 676 internal.isTestingMode = isTestingMode;
684 internal.clearTestingMode = clearTestingMode; 677 internal.clearTestingMode = clearTestingMode;
685 })(); 678 })();
OLDNEW
« no previous file with comments | « mojo/public/js/new_bindings/router.js ('k') | mojo/public/tools/bindings/generators/js_templates/interface_definition.tmpl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698