forked from mirrors/gecko-dev
		
	MozReview-Commit-ID: 3HXcvTYpAkA --HG-- rename : testing/web-platform/tests/fonts/matching/README.md => testing/web-platform/tests/css-fonts/matching/README.md rename : testing/web-platform/tests/fonts/matching/fixed-stretch-style-over-weight-ref.html => testing/web-platform/tests/css-fonts/matching/fixed-stretch-style-over-weight-ref.html rename : testing/web-platform/tests/fonts/matching/fixed-stretch-style-over-weight.html => testing/web-platform/tests/css-fonts/matching/fixed-stretch-style-over-weight.html rename : testing/web-platform/tests/fonts/matching/font-matching.css => testing/web-platform/tests/css-fonts/matching/font-matching.css rename : testing/web-platform/tests/fonts/matching/resources/variabletest_matching.ttf => testing/web-platform/tests/css-fonts/matching/resources/variabletest_matching.ttf rename : testing/web-platform/tests/fonts/matching/stretch-distance-over-weight-distance-ref.html => testing/web-platform/tests/css-fonts/matching/stretch-distance-over-weight-distance-ref.html rename : testing/web-platform/tests/fonts/matching/stretch-distance-over-weight-distance.html => testing/web-platform/tests/css-fonts/matching/stretch-distance-over-weight-distance.html rename : testing/web-platform/tests/fonts/matching/style-ranges-over-weight-direction-ref.html => testing/web-platform/tests/css-fonts/matching/style-ranges-over-weight-direction-ref.html rename : testing/web-platform/tests/fonts/matching/style-ranges-over-weight-direction.html => testing/web-platform/tests/css-fonts/matching/style-ranges-over-weight-direction.html rename : testing/web-platform/tests/payment-request/OWNERS => testing/web-platform/tests/payment-method-id/OWNERS rename : testing/web-platform/tests/storage/interfaces.worker.js => testing/web-platform/tests/storage/interfaces.https.worker.js rename : testing/web-platform/tests/tools/browserutils/requirements.txt => testing/web-platform/tests/tools/wpt/requirements.txt rename : testing/web-platform/tests/tools/browserutils/utils.py => testing/web-platform/tests/tools/wpt/utils.py rename : testing/web-platform/tests/tools/wptrunner/wptrunner/executors/reftest-wait.js => testing/web-platform/tests/tools/wptrunner/wptrunner/executors/reftest-wait_marionette.js rename : testing/web-platform/tests/uievents/keyboard/key-manual.css => testing/web-platform/tests/uievents/keyboard/key.css rename : testing/web-platform/tests/uievents/keyboard/key-manual.js => testing/web-platform/tests/uievents/keyboard/key.js
		
			
				
	
	
		
			101 lines
		
	
	
	
		
			2.7 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			101 lines
		
	
	
	
		
			2.7 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
'use strict';
 | 
						|
 | 
						|
// Helper assertion functions to validate dictionary fields
 | 
						|
// on dictionary objects returned from APIs
 | 
						|
 | 
						|
function assert_unsigned_int_field(object, field) {
 | 
						|
  const num = object[field];
 | 
						|
  assert_true(Number.isInteger(num) && (num >= 0),
 | 
						|
    `Expect dictionary.${field} to be unsigned integer`);
 | 
						|
}
 | 
						|
 | 
						|
function assert_int_field(object, field) {
 | 
						|
  const num = object[field];
 | 
						|
  assert_true(Number.isInteger(num),
 | 
						|
    `Expect dictionary.${field} to be integer`);
 | 
						|
}
 | 
						|
 | 
						|
function assert_string_field(object, field) {
 | 
						|
  const str = object[field];
 | 
						|
  assert_equals(typeof str, 'string',
 | 
						|
    `Expect dictionary.${field} to be string`);
 | 
						|
}
 | 
						|
 | 
						|
function assert_number_field(object, field) {
 | 
						|
  const num = object[field];
 | 
						|
  assert_equals(typeof num, 'number',
 | 
						|
    `Expect dictionary.${field} to be number`);
 | 
						|
}
 | 
						|
 | 
						|
function assert_boolean_field(object, field) {
 | 
						|
  const bool = object[field];
 | 
						|
  assert_equals(typeof bool, 'boolean',
 | 
						|
    `Expect dictionary.${field} to be boolean`);
 | 
						|
}
 | 
						|
 | 
						|
function assert_array_field(object, field) {
 | 
						|
  assert_true(Array.isArray(object[field]),
 | 
						|
    `Expect dictionary.${field} to be array`);
 | 
						|
}
 | 
						|
 | 
						|
function assert_dict_field(object, field) {
 | 
						|
  assert_equals(typeof object[field], 'object',
 | 
						|
    `Expect dictionary.${field} to be plain object`);
 | 
						|
 | 
						|
  assert_not_equals(object[field], null,
 | 
						|
    `Expect dictionary.${field} to not be null`);
 | 
						|
}
 | 
						|
 | 
						|
function assert_enum_field(object, field, validValues) {
 | 
						|
  assert_string_field(object, field);
 | 
						|
  assert_true(validValues.includes(object[field]),
 | 
						|
    `Expect dictionary.${field} to have one of the valid enum values: ${validValues}`);
 | 
						|
}
 | 
						|
 | 
						|
function assert_optional_unsigned_int_field(object, field) {
 | 
						|
  if(object[field] !== undefined) {
 | 
						|
    assert_unsigned_int_field(object, field);
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
function assert_optional_int_field(object, field) {
 | 
						|
  if(object[field] !== undefined) {
 | 
						|
    assert_int_field(object, field);
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
function assert_optional_string_field(object, field) {
 | 
						|
  if(object[field] !== undefined) {
 | 
						|
    assert_string_field(object, field);
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
function assert_optional_number_field(object, field) {
 | 
						|
  if(object[field] !== undefined) {
 | 
						|
    assert_number_field(object, field);
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
function assert_optional_boolean_field(object, field) {
 | 
						|
  if(object[field] !== undefined) {
 | 
						|
    assert_boolean_field(object, field);
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
function assert_optional_array_field(object, field) {
 | 
						|
  if(object[field] !== undefined) {
 | 
						|
    assert_array_field(object, field);
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
function assert_optional_dict_field(object, field) {
 | 
						|
  if(object[field] !== undefined) {
 | 
						|
    assert_dict_field(object, field);
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
function assert_optional_enum_field(object, field, validValues) {
 | 
						|
  if(object[field] !== undefined) {
 | 
						|
    assert_enum_field(object, field, validValues);
 | 
						|
  }
 | 
						|
}
 |